dont make freenodey exceptions

This commit is contained in:
vulpine 2020-10-16 18:58:14 -04:00
parent ade910a925
commit 10fc91a65d
2 changed files with 16 additions and 4 deletions

16
bot.py
View File

@ -26,13 +26,13 @@ class Server(BaseServer):
print(f"connected to {self.name}")
await self.send(build("JOIN", [self.lc]))
if line.command == "PRIVMSG":
if 'batch' in line.tags and line.tags['batch'] == '1':
if line.tags and 'batch' in line.tags and line.tags['batch'] == '1':
return
if line.params[1] == '!reload':
importlib.reload(filts)
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.send_raw(line.params[1][9:])
await self.linelog(str(await aexec(self,line.params[1][9:])))
if line.command == "INVITE":
await self.send(build("JOIN",[line.params[1]]))
@ -57,5 +57,17 @@ async def main():
await bot.run()
async def aexec(self, code):
# Make an async function with the code and `exec` it
exec(
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__":
asyncio.run(main())

View File

@ -13,10 +13,10 @@ async def line_read(self,line):
async def on_join(self,line):
reason = []
if not line.tags or 'account' not in line.tags and self.name != 'freenode':
if self.name != 'freenode' and not line.tags or 'account' not in line.tags:
reason.append('NO_NS_ACCOUNT')
if line.tags and 'account' in line.tags and self.name != 'freenode':
if self.name != 'freenode' and line.tags and 'account' in line.tags:
account = line.tags['account']