Fixed bug that broke IRC integration with external services
This commit is contained in:
parent
a28241c718
commit
957160b686
7
app.py
7
app.py
|
@ -20,13 +20,6 @@ arguments = parser.parse_args()
|
|||
bot = Bot("127.0.0.1", 6667)
|
||||
responses = Responses(bot)
|
||||
tasks = Tasks(bot)
|
||||
|
||||
# for coro in coroutines:
|
||||
# worker = coro["worker"]
|
||||
# interval = coro["interval"]
|
||||
# state = coro.get("state", None)
|
||||
# coro_state = state if state is not None else (bot,)
|
||||
# tasks.add_coroutine(worker, interval, coro_state)
|
||||
tasks.coroutines = coroutines
|
||||
|
||||
for action in actions:
|
||||
|
|
|
@ -68,7 +68,6 @@ class Bot:
|
|||
while magic_string not in message:
|
||||
message = self.ircsock.recv(self.recv_size).decode()
|
||||
# message = message.strip(self.splitter)
|
||||
print(message)
|
||||
self.logger.debug(message)
|
||||
|
||||
list_pattern = re.compile("[@=] {} :".format(chan))
|
||||
|
@ -168,7 +167,6 @@ class Bot:
|
|||
self.memories = json.loads(f.read())
|
||||
|
||||
def thread(self, fn, *args):
|
||||
print((self, *args))
|
||||
t = Thread(target=fn, args=args)
|
||||
t.start()
|
||||
|
||||
|
|
|
@ -9,9 +9,10 @@ class Tasks:
|
|||
self.thread = Thread(target=self.worker, args=(self,))
|
||||
self.coroutines = list()
|
||||
self.states = dict()
|
||||
self.halt = False
|
||||
|
||||
def periodic(self, scheduler, interval, action, index, state=dict()):
|
||||
if not self.states[index]:
|
||||
if self.halt:
|
||||
return
|
||||
|
||||
self.states[index] = action(state)
|
||||
|
@ -20,6 +21,7 @@ class Tasks:
|
|||
))
|
||||
|
||||
def worker(self, tasks):
|
||||
print(tasks.coroutines)
|
||||
for c, coro in enumerate(tasks.coroutines):
|
||||
interval = coro["interval"]
|
||||
worker = coro["worker"]
|
||||
|
@ -36,6 +38,7 @@ class Tasks:
|
|||
})
|
||||
|
||||
def stop(self):
|
||||
self.halt = True
|
||||
list(map(self.scheduler.cancel, self.scheduler.queue))
|
||||
for key, value in self.states.items():
|
||||
self.states[key] = False
|
||||
|
@ -43,4 +46,4 @@ class Tasks:
|
|||
|
||||
def run(self):
|
||||
self.thread.daemon = True
|
||||
self.thread.start()
|
||||
self.thread.start()
|
||||
|
|
Loading…
Reference in New Issue