From 64d24eb942c45410825fbdce97015e4f1f8d1ca1 Mon Sep 17 00:00:00 2001 From: xfnw Date: Sun, 4 Oct 2020 12:26:20 -0400 Subject: [PATCH] aliases for kim and stuff --- modules/admin.py | 25 +++++++++++++++++++++---- modules/channels.py | 8 +++++++- 2 files changed, 28 insertions(+), 5 deletions(-) diff --git a/modules/admin.py b/modules/admin.py index 0a63f9c..f0c6d21 100644 --- a/modules/admin.py +++ b/modules/admin.py @@ -38,14 +38,14 @@ async def join(self, chan, source, msg): async def joins(self, chan, source, msg): await self.message(chan, '[\x036admin\x0f] I will drop commands for some seconds to ignore chanhistory...') for i in self.chandb.all(): - self.t = time.time() + 2 + self.t = time.time() + 5 try: await self.join(i['name']) - await asyncio.sleep(2) + await asyncio.sleep(3) print('joined {}'.format(i['name'])) except pydle.client.AlreadyInChannel: print('I am already in {}'.format(i['name'])) - await asyncio.sleep(2) + await asyncio.sleep(3) await self.message(chan, '[\x036admin\x0f] Sucess!') async def aexec(self, code): @@ -83,6 +83,22 @@ async def schans(self, c, n, m): self.chandb.insert(dict(name=i)) await self.message(c, '[\x036admin\x0f] Ok') +async def addalias(self,c,n,m): + al = m.split(' ')[0] + m = m[len(al)+1:] # dont use the list since i want trailing spaces + if al in self.cmd: + await self.message(c,'[\x036admin\x0f] no dont overwrite a command dummy') + return + self.cmd[al]=Alias(m).alias + + await self.message(c,'[\x036admin\x0f] added "{}" alias for "{}"'.format(al,m)) + + +class Alias(): + def __init__(self, ms): + self.ms = str(ms) + async def alias(alself,self,c,n,m): + asyncio.create_task(self.parseCommand(c,n,alself.ms.format(m))) @@ -96,7 +112,8 @@ commands = { 'send': send, 'joins': joins, 'shut': shut, - 'schans': schans + 'schans': schans, + 'addalias': addalias } async def adminHandle(self, chan, source, msg): diff --git a/modules/channels.py b/modules/channels.py index f33e20b..c78da3d 100644 --- a/modules/channels.py +++ b/modules/channels.py @@ -1,10 +1,16 @@ +async def action(self,c,n,m): + await self.message(c,'\x01ACTION {}\x01'.format(m[:400])) + - +async def echo(self,c,n,m): + await self.message(c,'[\x036channels\x0f] {}'.format(m[:400])) async def init(self): self.chansjoin = ['#bots'] + self.cmd['echo']=echo + self.cmd['action']=action