mirror of
https://github.com/nichkara/InfinitumBotty.git
synced 2026-06-11 06:36:24 +02:00
Initalize repo
This commit is contained in:
21
FaustBot/Communication/MagicNumberObservable.py
Normal file
21
FaustBot/Communication/MagicNumberObservable.py
Normal file
@@ -0,0 +1,21 @@
|
||||
import _thread
|
||||
|
||||
from FaustBot.Communication.Observable import Observable
|
||||
|
||||
|
||||
class MagicNumberObservable(Observable):
|
||||
def input(self, raw_data, connection):
|
||||
data = {}
|
||||
data['raw'] = raw_data
|
||||
prefix, numeric, rest = data['raw'].split(' ',2)
|
||||
data['number'] = numeric
|
||||
data['arguments'] = rest
|
||||
self.notify_observers(data, connection)
|
||||
|
||||
def notify_observers(self, data, connection):
|
||||
for observer in self._observers:
|
||||
try:
|
||||
_thread.start_new_thread(observer.__class__.update_on_magic_number, (observer, data, connection))
|
||||
except Exception:
|
||||
import traceback
|
||||
print (traceback.format_exc())
|
||||
Reference in New Issue
Block a user