min/modules/admin.py

70 lines
1.8 KiB
Python
Raw Normal View History

2020-04-05 23:05:07 +00:00
2020-04-05 23:27:06 +00:00
import importlib
2020-04-05 23:52:31 +00:00
async def commit(self, chan, source, msg):
await self.quit('{} told me to commit {}'.format(source,msg))
2020-04-05 23:27:06 +00:00
async def quit(self, chan, source, msg):
await self.quit('{} told me to {}'.format(source,msg))
2020-04-05 23:52:31 +00:00
2020-04-05 23:27:06 +00:00
async def reloadmods(self, chan, source, msg):
await self.message(chan, 'reloading modules...')
self.cmd = {}
self.raw = {}
self.help = {}
for i in self.modules:
importlib.reload(self.modules[i])
await self.modules[i].init(self)
await self.message(chan, 'done! did something break? if so you might need to restart')
2020-04-06 20:32:51 +00:00
2020-04-06 00:21:10 +00:00
async def part(self, chan, source, msg):
await self.message(chan, 'bye {}'.format(msg))
await self.part(msg)
2020-04-05 23:27:06 +00:00
2020-04-06 00:21:10 +00:00
async def join(self, chan, source, msg):
await self.message(chan, 'joined {}'.format(msg))
await self.join(msg)
2020-04-05 23:27:06 +00:00
2020-04-06 20:32:51 +00:00
async def joins(self, chan, source, msg):
for i in self.joins:
await self.join(i)
async def ev(self, chan, source, msg):
msg = msg.split(' ')
setattr(self,msg.pop(0), eval(' '.join(msg)))
await self.message(chan, 'ok')
2020-04-05 23:27:06 +00:00
commands = {
'quit': quit,
2020-04-05 23:52:31 +00:00
'reload': reloadmods,
2020-04-06 00:21:10 +00:00
'commit': commit,
'part': part,
2020-04-06 20:32:51 +00:00
'join': join,
'eval': ev,
'joins': joins
2020-04-05 23:27:06 +00:00
}
2020-04-05 23:05:07 +00:00
async def adminHandle(self, chan, source, msg):
2020-04-05 23:27:06 +00:00
if await self.is_admin(source):
msg = msg.split(' ')
if len(msg) < 1 or not msg[0] in commands:
await self.message(chan, 'you press the wrong button on the oven and it burns you')
return
2020-04-05 23:52:31 +00:00
print('[ADMIN MODULE] {} told me to {}!!!'.format(source,msg[0]))
2020-04-05 23:27:06 +00:00
await commands[msg.pop(0)](self, chan, source, ' '.join(msg))
else:
await self.message(chan, 'you try to open it, but the oven is locked')
2020-04-05 23:05:07 +00:00
async def init(self):
self.cmd['admin'] = adminHandle
2020-04-06 20:32:51 +00:00
self.joins = ["#chaos", "#lickthecheese", "#windowsloser", "#cminecraft", "#team"]