Compare commits
No commits in common. "4a65d8d07d462313d3a87b57212fdfd856b64ee1" and "a1d76d3badb215160a033738dd04c9432eb55ff0" have entirely different histories.
4a65d8d07d
...
a1d76d3bad
75
main.py
75
main.py
|
@ -155,49 +155,40 @@ class ModuleControlUnit:
|
|||
# synchronous message processor
|
||||
def queue_processor():
|
||||
while True:
|
||||
try:
|
||||
if len(message_queue) > 0:
|
||||
msg = message_queue[0]
|
||||
print("[DEBUG] queue_processor: {}".format(msg)) # debug
|
||||
|
||||
# check for control commands
|
||||
if msg["chat"]["id"] == 575246355:
|
||||
if msg["text"][0] == "$":
|
||||
command = msg["text"][1:].split(" ")
|
||||
|
||||
if len(command) >= 2 and command[0] == "module":
|
||||
if command[1] == "reload":
|
||||
print("[INFO] Module reloading triggered by a command")
|
||||
del mcu.modules[:]
|
||||
mcu.reload_modules()
|
||||
|
||||
del message_queue[0]
|
||||
continue
|
||||
|
||||
# modules are used in here
|
||||
for mod in mcu.modules:
|
||||
if mod.enabled:
|
||||
if mod.version == 1:
|
||||
responce = mod.process(msg)
|
||||
if len(responce) > 0:
|
||||
updater.bot.send_message(chat_id = msg.chat.id, text = responce)
|
||||
print("Responded using module {} ({}) with text: {}".format(mod.path, mod.alias, responce))
|
||||
break
|
||||
|
||||
del message_queue[0]
|
||||
if len(message_queue) > 0:
|
||||
msg = message_queue[0]
|
||||
print("[DEBUG] queue_processor: {}".format(msg)) # debug
|
||||
|
||||
# check for control commands
|
||||
if msg["chat"]["id"] == 575246355:
|
||||
if msg["text"][0] == "$":
|
||||
command = msg["text"][1:].split(" ")
|
||||
|
||||
if len(command) >= 2 and command[0] == "module":
|
||||
if command[1] == "reload":
|
||||
print("[INFO] Module reloading triggered by a command")
|
||||
del mcu.modules[:]
|
||||
mcu.reload_modules()
|
||||
|
||||
del message_queue[0]
|
||||
continue
|
||||
|
||||
# modules are used in here
|
||||
for mod in mcu.modules:
|
||||
if mod.enabled:
|
||||
if mod.version == 1:
|
||||
responce = mod.process(msg)
|
||||
if len(responce) > 0:
|
||||
updater.bot.send_message(chat_id = msg.chat.id, text = responce)
|
||||
print("Responded using module {} ({}) with text: {}".format(mod.path, mod.alias, responce))
|
||||
break
|
||||
|
||||
del message_queue[0]
|
||||
else:
|
||||
if STOP_REQUESTED:
|
||||
break
|
||||
else:
|
||||
if STOP_REQUESTED:
|
||||
break
|
||||
else:
|
||||
time.sleep(1)
|
||||
except Exception as e:
|
||||
print("[ERROR] queue_processor: current message queue: {}".format(message_queue))
|
||||
print("[ERROR] queue_processor: error while processing message, trying to delete it...")
|
||||
try:
|
||||
del message_queue[0]
|
||||
print("[INFO] queue_processor: deleted broken message from the queue")
|
||||
except:
|
||||
print("[WARN] queue_processor: message seems absent, whatever")
|
||||
time.sleep(1)
|
||||
|
||||
print("[INFO] queue_processor thread stops successfully")
|
||||
|
||||
|
|
|
@ -1,12 +0,0 @@
|
|||
if "%" in self.MESSAGE["text"]:
|
||||
tagging_issued = False
|
||||
tags_used = set()
|
||||
tagged_users = set()
|
||||
for i in self.tag_sets:
|
||||
if i in self.MESSAGE["text"]:
|
||||
tagging_issued = True
|
||||
tags_used.add(i)
|
||||
tagged_users |= self.tag_sets[i]
|
||||
|
||||
if tagging_issued:
|
||||
self.RESPONCE = "Користувач використав масовий тег з повідомленням: {}\n\n{}".format(self.MESSAGE["text"], " ".join(tagged_users))
|
|
@ -1,7 +0,0 @@
|
|||
{
|
||||
"version": 1,
|
||||
"index_file": "index.py",
|
||||
"predefine": "predefine.py",
|
||||
"start_on_boot": true,
|
||||
"alias": "mass-tagger"
|
||||
}
|
|
@ -1,4 +0,0 @@
|
|||
self.tag_sets = {
|
||||
"%testing": {"@dmytrofiot23"},
|
||||
"%students": {"@dmytrofiot23", "@Rhinemann", "@Vlad86557", "@nonGratis", "@aposijl", "@Bacant150", "@Investor3221", "@Fvggggu", "@andrux4", "@danya946", "@Antntipo", "@eugeneholovatenko", "@brazoo", "@kozak_yana", "@dfttime", "@forkreros", "@nikitobus1", "@m1x3d0", "@BohdanOstrykov", "@theNightingal3", "@maks1mka_77g", "@victoriavodyana", "@cyberbebebe", "@misha1tigr", "@artemm4ekk", "@jwnsn", "@nstchpnk", "@telegadimki", "@Dedinsyult", "@sashkamg", "@sandrokovi3"}
|
||||
}
|
Loading…
Reference in New Issue