better timing

This commit is contained in:
lickthecheese 2020-04-18 17:26:32 -04:00
parent 4b57d90462
commit 9d1bc6e053
4 changed files with 6 additions and 4 deletions

8
bot.py
View file

@ -43,13 +43,15 @@ class Oven(pydle.Client):
await self.raw[i](self, chan,source,msg) await self.raw[i](self, chan,source,msg)
if msg[:len(self.prefix)] == self.prefix: if msg[:len(self.prefix)] == self.prefix:
if time.time() < self.timeout: if time.time() < self.timeout:
self.timeout += 2 self.timeout += 1
print('messages are being sent too fast!') print('messages are being sent too fast! ({}s)'.format(self.timeout-time.time()))
if await self.is_admin(source) and msg == '{}recv'.format(self.prefix):
self.timeout = 0
return return
if time.time()-1.5 < self.timeout: if time.time()-1.5 < self.timeout:
await self.message(chan, 'woah woah, slow it down there, or il get mad and wont bake your food') await self.message(chan, 'woah woah, slow it down there, or il get mad and wont bake your food')
self.timeout = time.time()+1 self.timeout = time.time()+0.5
msg = msg[len(self.prefix):] msg = msg[len(self.prefix):]
cmd = msg.split(' ')[0] cmd = msg.split(' ')[0]
msg = msg[len(cmd)+1:] msg = msg[len(cmd)+1:]

View file

@ -20,7 +20,7 @@ async def run(cmd):
async def markov(self, c, n, m): async def markov(self, c, n, m):
m = ''.join([i for i in m if i.isalnum()]) m = ''.join([i for i in m if i.isalnum()])
if len(m) > 1: if len(m) > 0:
await self.message(c, (await run("markov '{}'".format(m)))[:-1]) await self.message(c, (await run("markov '{}'".format(m)))[:-1])
return return
await self.message(c, 'the oven went boop') await self.message(c, 'the oven went boop')