74 lines
2.2 KiB
Executable File

#!/usr/bin/env python3
logchan = "#chaos"
import asyncio, importlib
from irctokens import build, Line
from ircrobots import Bot as BaseBot
from ircrobots import Server as BaseServer
from ircrobots import ConnectionParams, SASLUserPass, SASLSCRAM
import filts, auth
#("freenode", ""),
class Server(BaseServer):
async def line_read(self, line: Line):
print(f"{} < {line.format()}")
if line.command == "001": = "#" *( == "freenode") + logchan
print(f"connected to {}")
await self.send(build("JOIN", []))
if line.command == "PRIVMSG":
if line.tags and 'batch' in line.tags and line.tags['batch'] == '1':
if line.params[1] == '!reload':
await self.linelog('reloaded')#sifakis
if line.params[1][0:9] == "Sifakis: " and line.tags and 'account' in line.tags and line.tags['account'] == 'lickthecheese':
await self.linelog(str(await aexec(self,line.params[1][9:])))
if line.command == "INVITE":
await self.send(build("JOIN",[line.params[1]]))
async def line_send(self, line: Line):
print(f"{} > {line.format()}")
async def linelog(self,string):
await self.send(build("NOTICE",[,string]))
class Bot(BaseBot):
def create_server(self, name: str):
return Server(self, name)
async def main():
bot = Bot()
for name, host in SERVERS:
sasl_params = SASLUserPass("Sifakis", auth.password)
params = ConnectionParams("Sifakis", host, 6697, True, sasl = sasl_params)
await bot.add_server(name, params)
async def aexec(self, code):
# Make an async function with the code and `exec` it
f'async def __ex(self): ' +
''.join(f'\n {l}' for l in code.split('\n'))
# Get `__ex` from local variables, call it and return the result
return await locals()['__ex'](self)
if __name__ == "__main__":