move priority constants to root of EventManager namespace

This commit is contained in:
jesopo 2018-07-15 23:53:59 +01:00
parent 66397cb24a
commit 8307a1121a

View file

@ -1,5 +1,10 @@
import traceback
PRIORITY_URGENT = 0
PRIORITY_HIGH = 1
PRIORITY_MEDIUM = 2
PRIORITY_LOW = 3
class Event(object):
def __init__(self, bot, name, **kwargs):
self.bot = bot
@ -16,11 +21,6 @@ class Event(object):
self.eaten = True
class EventCallback(object):
PRIORITY_URGENT = 0
PRIORITY_HIGH = 1
PRIORITY_MEDIUM = 2
PRIORITY_LOW = 3
def __init__(self, function, bot, priority, **kwargs):
self.function = function
self.bot = bot
@ -52,8 +52,7 @@ class EventHook(object):
self._call_notify = None
self._stored_events = []
def hook(self, function, priority=EventCallback.PRIORITY_LOW,
replay=False, **kwargs):
def hook(self, function, priority=PRIORITY_LOW, replay=False, **kwargs):
callback = EventCallback(function, self.bot, priority, **kwargs)
if self._hook_notify:
self._hook_notify(self, callback)