mumbling
This commit is contained in:
parent
c478220bc2
commit
7d45d39e35
14
bot.py
14
bot.py
@ -97,8 +97,7 @@ class IRCBot():
|
|||||||
try:
|
try:
|
||||||
this_time = self.config["times"][channel]
|
this_time = self.config["times"][channel]
|
||||||
except KeyError:
|
except KeyError:
|
||||||
this_time = time()
|
this_time = self.config["times"][channel] = time()
|
||||||
self.config["times"][channel] = this_time
|
|
||||||
self.write_config()
|
self.write_config()
|
||||||
return this_time
|
return this_time
|
||||||
|
|
||||||
@ -114,6 +113,10 @@ class IRCBot():
|
|||||||
self.write_config()
|
self.write_config()
|
||||||
return value
|
return value
|
||||||
|
|
||||||
|
def reset_count(self, channel):
|
||||||
|
self.config["counts"][channel] = 0
|
||||||
|
self.write_config()
|
||||||
|
|
||||||
def command_loop(self):
|
def command_loop(self):
|
||||||
while True:
|
while True:
|
||||||
char = self.s.recv(1)
|
char = self.s.recv(1)
|
||||||
@ -164,11 +167,10 @@ class IRCBot():
|
|||||||
channel_time = self.check_time(channel)
|
channel_time = self.check_time(channel)
|
||||||
now = time()
|
now = time()
|
||||||
count = self.counter(channel)
|
count = self.counter(channel)
|
||||||
if now - channel_time > timeout and count < messages_within_timeout:
|
delta = now - channel_time
|
||||||
self.config["counts"][channel] = 0
|
if delta > timeout and count < messages_within_timeout:
|
||||||
self.write_config()
|
self.reset_count(channel)
|
||||||
self.send("#bots", f"i hear activity in {channel}...")
|
self.send("#bots", f"i hear activity in {channel}...")
|
||||||
# self.send("#tildetown", f"i hear activity in {channel}...")
|
|
||||||
self.set_time(channel, now)
|
self.set_time(channel, now)
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
Loading…
x
Reference in New Issue
Block a user