aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorlassulus <lassulus@lassul.us>2018-09-16 19:24:34 +0200
committerlassulus <lassulus@lassul.us>2018-09-16 19:24:34 +0200
commitc5fb3227930491d025490031d1b0bc02330710c4 (patch)
tree227cb84746e0cf39766ce8efb505f729e541ea72
parentd89b9839252db99e1ff5293d150ffa4aa1b95d62 (diff)
core: run execute_command in a thread0.6.0
-rwxr-xr-xreaktor/core.py25
1 files changed, 21 insertions, 4 deletions
diff --git a/reaktor/core.py b/reaktor/core.py
index fce49ff..072b73a 100755
--- a/reaktor/core.py
+++ b/reaktor/core.py
@@ -13,6 +13,7 @@
import logging
import logging.handlers
import os
+import threading
from asyncore import loop
from os.path import dirname
from re import match
@@ -61,14 +62,22 @@ class Reaktor(asybot):
def on_join(self, prefix, command, params, rest):
for command in self.getconf('on_join', []):
- self.execute_command(command, None, prefix, params)
+ thread = threading.Thread(
+ target=self.execute_command,
+ args=(command, None, prefix, params),
+ )
+ thread.start()
def on_ping(self, prefix, command, params, rest):
for command in self.getconf('on_ping', []):
prefix = '!' # => env = { _prefix: '!', _from: '' }
# TODO why don't we get a list here and use ','.join() ?
params = command.get('targets')
- self.execute_command(command, None, prefix, params)
+ thread = threading.Thread(
+ target=self.execute_command,
+ args=(command, None, prefix, params),
+ )
+ thread.start()
def on_privmsg(self, prefix, command, params, rest):
if not (self.nickname == self.getconf('name')):
@@ -88,12 +97,20 @@ class Reaktor(asybot):
if not self.is_admin(prefix):
self.PRIVMSG(params, 'unauthorized!')
else:
- return self.execute_command(command, y, prefix, params)
+ thread = threading.Thread(
+ target=self.execute_command,
+ args=(command, y, prefix, params),
+ )
+ thread.start()
for command in self.getconf('public_commands'):
y = match(command['pattern'], rest)
if y:
- return self.execute_command(command, y, prefix, params)
+ thread = threading.Thread(
+ target=self.execute_command,
+ args=(command, y, prefix, params),
+ )
+ thread.start()
def execute_command(self, command, match, prefix, target):
from os.path import realpath, dirname, join