Compare commits

...

4 Commits

Author SHA1 Message Date
vulpine 01f606ff89 option to ignore invites while running 2020-10-04 19:29:25 -04:00
vulpine c813e5c986 chai tea 2020-10-04 18:58:27 -04:00
vulpine 4fd2ae9d00 fixed triggers to not be triggered by itself 2020-10-04 15:51:26 -04:00
vulpine ee6792939c triggers! 2020-10-04 15:40:11 -04:00
3 changed files with 54 additions and 4 deletions

3
bot.py
View File

@ -13,6 +13,7 @@ class Balun(pydle.Client):
self.help = {}
self.db = dataset.connect('sqlite:///database.db')
self.t=0
self.acceptInvites=True
print('loading modules...')
await self.loadMods()
@ -35,6 +36,8 @@ class Balun(pydle.Client):
self.modules[i] = m
async def on_invite(self, channel, by):
if not self.acceptInvites:
return
print('{} invited me to {}!'.format(by, channel))
self.t = time.time()+1
await self.join(channel)

View File

@ -94,11 +94,56 @@ async def addalias(self,c,n,m):
await self.message(c,'[\x036admin\x0f] added "{}" alias for "{}"'.format(al,m))
async def addot(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.rawm:
await self.message(c,'[\x036admin\x0f] no dont overwrite a command dummy')
return
self.rawm[al]=Ot(m,al).ot
await self.message(c,'[\x036admin\x0f] added "{}" trigger for "{}"'.format(al,m))
async def addtrigger(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.rawm:
await self.message(c,'[\x036admin\x0f] no dont overwrite a command dummy')
return
self.rawm[al]=Trigger(m,al).trigger
await self.message(c,'[\x036admin\x0f] added "{}" trigger for "{}"'.format(al,m))
class Ot():
def __init__(self, ms, al):
self.ms = str(ms)
self.al = str(al)
async def ot(alself,self,c,n,m):
if alself.al in m and n != self.nickname:
asyncio.create_task(self.on_message(c,n,alself.ms.format(m)))
self.rawm.pop(alself.al)
class Trigger():
def __init__(self, ms, al):
self.ms = str(ms)
self.al = str(al)
async def trigger(alself,self,c,n,m):
if alself.al in m:
asyncio.create_task(self.on_message(c,n,alself.ms.format(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)))
asyncio.create_task(self.on_message(c,n,alself.ms.format(m)))
@ -113,7 +158,9 @@ commands = {
'joins': joins,
'shut': shut,
'schans': schans,
'addalias': addalias
'addalias': addalias,
'addtrigger': addtrigger,
'addot': addot,
}
async def adminHandle(self, chan, source, msg):
@ -123,7 +170,7 @@ async def adminHandle(self, chan, source, msg):
await self.message(chan, '[\x036admin\x0f] Invalid command')
return
print('[ADMIN MODULE] {} told me to {}!!!'.format(source,msg[0]))
await commands[msg.pop(0)](self, chan, source, ' '.join(msg))
asyncio.create_task(commands[msg.pop(0)](self, chan, source, ' '.join(msg)))
else:
await self.message(chan, '[\x036admin\x0f] You do not have permission to do this')

View File

@ -3,7 +3,7 @@ import random
async def coffeeup(self,c,n,m):
if c in ['#coffee','#tea','#water','#CAPS']:
if (c[1:]+"!" in m and c+'!' not in m) or c=='#coffee' and ('latte!' in m or 'espresso!' in m):
if (c[1:]+"!" in m and c+'!' not in m) or c=='#coffee' and ('latte!' in m or 'espresso!' in m) or c=='#tea' and ('chai!' in m):
cc = self.coffee.find_one(name=c)
if cc:
self.coffee.update(dict(name=c,value=cc['value']+1),['name'])