aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar jesopo2019-05-01 17:13:41 +0100
committerGravatar jesopo2019-05-01 17:13:41 +0100
commitaa1b457632ef6709db52fe0b868c8e0f60346f8d (patch)
tree2a8833eb962714e671211c9d72cd9948d43be39e
parentRemove `import pytz` from location.py, we don't use it (diff)
signature
Change TRIGGER_RETURN and TRIGGER_EXCEPTION to an enum
-rw-r--r--src/IRCBot.py15
1 files changed, 8 insertions, 7 deletions
diff --git a/src/IRCBot.py b/src/IRCBot.py
index 8f6fe89c..0c4f2784 100644
--- a/src/IRCBot.py
+++ b/src/IRCBot.py
@@ -1,11 +1,12 @@
-import queue, os, select, socket, threading, time, traceback, typing, uuid
+import enum, queue, os, select, socket, threading, time, traceback, typing, uuid
from src import EventManager, Exports, IRCServer, Logging, ModuleManager
from src import Socket, utils
VERSION = "v1.5.0"
-TRIGGER_RETURN = 1
-TRIGGER_EXCEPTION = 2
+class TriggerResult(enum.Enum):
+ Return = 1
+ Exception = 2
class Bot(object):
def __init__(self, directory, args, cache, config, database, events,
@@ -53,9 +54,9 @@ class Bot(object):
self._trigger_client.send(b"TRIGGER")
type, returned = func_queue.get(block=True)
- if type == TRIGGER_EXCEPTION:
+ if type == TriggerResult.Exception:
raise returned
- elif type == TRIGGER_RETURN:
+ elif type == TriggerResult.Return:
return returned
def add_server(self, server_id: int, connect: bool = True,
@@ -197,10 +198,10 @@ class Bot(object):
for func, func_queue in self._trigger_functions:
try:
returned = func()
- type = TRIGGER_RETURN
+ type = TriggerResult.Return
except Exception as e:
returned = e
- type = TRIGGER_EXCEPTION
+ type = TriggerResult.Exception
func_queue.put([type, returned])
self._trigger_functions.clear()