.
diff --git a/README.md b/README.md
deleted file mode 100644
index e16400b..0000000
--- a/README.md
+++ /dev/null
@@ -1,58 +0,0 @@
-# Modular Bot Framework for Telegram (MBFT)
-Modular bot framework for telegram (MBFT for short) allows you to quickly create stable, modular and highly customizable bots.
-The concept comes from the original project created for Twitch chat that has shown its high stability (it has worked for over 10 months without a single crash).
-Now it is being rewritten for Telegram to serve many different purposes.
-
-## Installing and running the bot
-
-The installation can be easily done by cloning this repository and providing the Telegram bot token using the config/token file.
-In commands, it is done like this:
-```bash
-# cloning the repo
-git clone http://109.86.70.81:3000/dymik739/modular-bot-framework-for-telegram
-cd modular-bot-framework-for-telegram/
-
-# creating "config" folder and providing a token
-mkdir config/
-printf "YOUR_AUTH_TOKEN" > config/token
-
-# running the bot
-python3 main.py
-# or, using the screen utility:
-screen -S mbft python3 main.py
-```
-
-## Writing modules (for modVM v1)
-
-To start making your module, you need to create a folder in the modules/ directory and give it a unique name (just like with any other folder).
-After that, you need to create two files: for code and for metadata.
-
-Firstly, you want to make a file called "meta.json" - it will let the module loader know where you placed your code as well as some other useful metadata. Let's look at a sample meta.json file:
-```
-{
- "index_file": index.py, # locates your source code; index.py by default
- "start_on_boot": true, # tells mod loader to start your module automatically; false by default
- "version": 1, # this points to the specific version of modVM your code needs to run; 1 by default
- "alias": "testapp" # adds an alias to your module which can be later specified in control commands
- "predefine": "predefine.py" # locates your predefine code (it is being run only once on module load
-}
-```
-
-After that you can start writing your code in the index.py file; every code is different, but there are some generic rules to understand and follow:
-- your code receives message that can be accessed at self.MESSAGE
-- message text can be found at self.MESSAGE.text
-- to send a responce, you need to write a string with responce text to self.RESPONCE
-- you can use modules already available to you (json, codecs); please, try to avoid importing unneccesary modules
-- if you need to access files amd folders in your module dicertory, you can easily do so by using self.path + "filename"; self.path always contains your current folder name
-- please, avoid using time.sleep() in any scenario; modules are syncronous, so usage of this method will stall the entire bot
-- in order to define persistent variables you can set them in your predefine file
-
-If you want to submit your code, please check if it works by testing the output (see "testing" section below); if you want to submit the code for someone to do more work on it, you should set "start_on_boot" to "false" in meta.json file (the same should be done for testing/unstable modules)
-
-## Testing modules locally
-In order to test the modules/bot offline you can run the module-testing.py file - it behaves just like the bot, but allows you to enter any message, doesn't require Internet connection and bot token. This is a good way to test your modules before publishing them.
-
-It can be used like this:
-```
-python3 module-testing.py
-```
diff --git a/main.py b/main.py
deleted file mode 100644
index 84f6d20..0000000
--- a/main.py
+++ /dev/null
@@ -1,252 +0,0 @@
-from telegram.ext import Updater, MessageHandler, Filters
-import datetime
-import codecs
-import time
-import json
-import sys
-import os
-import threading
-import importlib
-
-# global variables
-STOP_REQUESTED = False
-
-# some functions that increase readability of the code
-def readfile(filename):
- try:
- return codecs.open(filename, encoding = "utf-8").read()
- except FileNotFoundError:
- return False
- except Exception as e:
- print( "[ERROR] Unexpected error occured in readfile() ({0})".format(e) )
- return False
-
-# module object classes
-class ModuleV1:
- def __init__(self, path, code, enabled, alias, predefine):
- self.version = 1
- self.enabled = enabled
- self.code = code
- self.alias = alias
- self.path = path
- self.predefine = predefine
-
- if self.predefine:
- self.set_predefine()
-
- # set environmental variables
- def set_env(self):
- self.RESPONCE = ""
-
- def set_predefine(self):
- try:
- exec(self.predefine)
- except Exception as e:
- print("[ERROR] module v1: module \"{}\" ({}) raised exception \"{}\" during predefine stage, disabling it...".format(self.path, self.alias, e))
-
- # running the module
- def process(self, msg):
- self.set_env()
-
- self.MESSAGE = msg
- try:
- exec(self.code)
- return self.RESPONCE
- except Exception as e:
- print("[ERROR] module v1: module \"{}\" ({}) raised exception \"{}\"".format(self.path, self.alias, e))
- return ""
-
-class ModuleV2:
- def __init__(self, path, index_file, enabled, alias):
- self.version = 2
- self.enabled = enabled
- self.alias = alias
- self.path = path
- self.index_file = index_file[:-3]
- self.obj = importlib.import_module((path + self.index_file).replace("/", "."))
-
- # running the module
- def process(self, msg):
- try:
- responce = self.obj.process(msg, self.path)
- return responce
- except Exception as e:
- print(f"[ERROR] module v2: module \"{self.path}\" ({self.alias}) raised exception \"{e}\"")
- return None
-
-
-# module control unit
-class ModuleControlUnit:
- def __init__(self):
- self.modules = []
- self.reload_modules()
-
- print("[INFO] ModuleControlUnit: initialized successfully")
-
- def reload_modules(self):
- for folder in os.listdir("modules/"):
- try:
- meta_raw = readfile("modules/{}/meta.json".format(folder))
- if not meta_raw:
- print("[WARN] module_loader: no meta.json found in module folder \"{}\"".format(folder))
- continue
-
- meta = json.loads( meta_raw )
- if "version" in meta:
- if meta["version"] == 1:
- if "index_file" in meta:
- index_file = meta["index_file"]
- else:
- index_file = "index.py"
-
- code = readfile( "modules/{}/{}".format(folder, index_file) )
- if not code: # False both when readfile() returns False and when the code string is empty
- print("[WARN] reload_modules: module {} does not have any code, skipping...".format(folder))
- continue
-
- if "start_on_boot" in meta:
- enabled = meta["start_on_boot"]
- else:
- enabled = False
-
- if "alias" in meta:
- alias = meta["alias"]
- else:
- alias = None
-
- if "predefine" in meta:
- predefine = readfile("modules/{}/{}".format(folder, meta["predefine"]))
- else:
- predefine = False
-
- self.modules.append( ModuleV1( "modules/{}/".format(folder), code, enabled, alias, predefine ) )
-
- print("[INFO] reload_modules: successfully loaded {} as {} (start_on_boot: {})".format(folder, alias, enabled))
-
- elif meta["version"] == 2:
- if "index_file" in meta:
- index_file = meta["index_file"]
- else:
- index_file = "index.py"
-
- if "start_on_boot" in meta:
- enabled = meta["start_on_boot"]
- else:
- enabled = False
-
- if "alias" in meta:
- alias = meta["alias"]
- else:
- alias = None
-
- self.modules.append(ModuleV2(f"modules/{folder}/", index_file, enabled, alias))
-
- print(f"[INFO] reload_modules: successfully loaded {folder} as {alias} (start_on_boot: {enabled})")
-
- else:
- print(f"[WARN] reload_modules: module {folder} requires unsupported version ({meta['version']} > 2), skipping...")
-
- except Exception as e:
- print("[ERROR] module_loader: error while loading module \"{}\" ({})".format(folder, e))
-
-# message queue object to go back to synchronous message processing
-#class MessageQueue:
-# def __init__(self):
-# print("[INFO] Initializing the message queue...")
-# self.queue = []
-
-
-# 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")
-
- # properly reload all v2 modules
- for mod in mcu.modules:
- if mod.version == 2:
- importlib.reload(mod.obj)
-
- 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 or mod.version == 2:
- responce = mod.process(msg)
- if responce:
- updater.bot.send_message(chat_id = msg.chat.id, text = responce, disable_web_page_preview = True)
- print(f"Responded using module {mod.path} ({mod.alias}) with text: {responce}")
- break
-
- del message_queue[0]
-
- time.sleep(0.1)
- 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")
-
- print("[INFO] queue_processor thread stops successfully")
-
-
-# telegram bot processor
-def message_handler(update, context):
- print("[DEBUG] Received new message") # just for testing
- message_queue.append(update.message)
-
-
-# --- Final stage ---
-
-
-# initializing services and queues
-
-message_queue = []
-
-mcu = ModuleControlUnit()
-
-processor_thread = threading.Thread( target = queue_processor, args = [] )
-processor_thread.start()
-
-
-# connecting to Telegram servers and listening for messages
-
-TOKEN = readfile("config/token")
-if not TOKEN:
- print("[CRIT] Token has not been defined, quitting")
- sys.exit(1)
-
-# connect to Telegram servers
-updater = Updater(TOKEN, use_context = True)
-dispatcher = updater.dispatcher
-
-# assign the handler for messages
-dispatcher.add_handler(MessageHandler(Filters.text, message_handler))
-
-# run the bot
-updater.start_polling()
-updater.idle()
diff --git a/module-testing.py b/module-testing.py
deleted file mode 100644
index e31018f..0000000
--- a/module-testing.py
+++ /dev/null
@@ -1,238 +0,0 @@
-import datetime
-import codecs
-import time
-import json
-import sys
-import os
-import threading
-import importlib
-
-from telegram import Message, Chat
-
-# global variables
-STOP_REQUESTED = False
-
-# some functions that increase readability of the code
-def readfile(filename):
- try:
- return codecs.open(filename, encoding = "utf-8").read()
- except FileNotFoundError:
- return False
- except Exception as e:
- print( "[ERROR] Unexpected error occured in readfile() ({0})".format(e) )
- return False
-
-# module object classes
-class ModuleV1:
- def __init__(self, path, code, enabled, alias, predefine):
- self.version = 1
- self.enabled = enabled
- self.code = code
- self.alias = alias
- self.path = path
- self.predefine = predefine
-
- if self.predefine:
- self.set_predefine()
-
- # set environmental variables
- def set_env(self):
- self.RESPONCE = ""
-
- def set_predefine(self):
- try:
- exec(self.predefine)
- except Exception as e:
- print("[ERROR] module v1: module \"{}\" ({}) raised exception \"{}\" during predefine stage, disabling it...".format(self.path, self.alias, e))
-
- # running the module
- def process(self, msg):
- self.set_env()
-
- self.MESSAGE = msg
- try:
- exec(self.code)
- return self.RESPONCE
- except Exception as e:
- print("[ERROR] module v1: module \"{}\" ({}) raised exception \"{}\"".format(self.path, self.alias, e))
- return ""
-
-
-class ModuleV2:
- def __init__(self, path, index_file, enabled, alias):
- self.version = 2
- self.enabled = enabled
- self.alias = alias
- self.path = path
- self.index_file = index_file[:-3]
- self.obj = importlib.import_module((path + self.index_file).replace("/", "."))
-
- # running the module
- def process(self, msg):
- try:
- responce = self.obj.process(msg, self.path)
- return responce
- except Exception as e:
- print(f"[ERROR] module v2: module \"{self.path}\" ({self.alias}) raised exception \"{e}\"")
- return None
-
-
-# module control unit
-class ModuleControlUnit:
- def __init__(self):
- self.modules = []
- self.reload_modules()
-
- print("[INFO] ModuleControlUnit: initialized successfully")
-
- def reload_modules(self):
- for folder in os.listdir("modules/"):
- try:
- meta_raw = readfile("modules/{}/meta.json".format(folder))
- if not meta_raw:
- print("[WARN] module_loader: no meta.json found in module folder \"{}\"".format(folder))
- continue
-
- meta = json.loads( meta_raw )
- if "version" in meta:
- if meta["version"] == 1:
- if "index_file" in meta:
- index_file = meta["index_file"]
- else:
- index_file = "index.py"
-
- code = readfile( "modules/{}/{}".format(folder, index_file) )
- if not code: # False both when readfile() returns False and when the code string is empty
- print("[WARN] reload_modules: module {} does not have any code, skipping...".format(folder))
- continue
-
- if "start_on_boot" in meta:
- enabled = meta["start_on_boot"]
- else:
- enabled = False
-
- if "alias" in meta:
- alias = meta["alias"]
- else:
- alias = None
-
- if "predefine" in meta:
- predefine = readfile("modules/{}/{}".format(folder, meta["predefine"]))
- else:
- predefine = False
-
- self.modules.append( ModuleV1( "modules/{}/".format(folder), code, enabled, alias, predefine ) )
-
- print("[INFO] reload_modules: successfully loaded {} as {} (start_on_boot: {})".format(folder, alias, enabled))
-
- elif meta["version"] == 2:
- if "index_file" in meta:
- index_file = meta["index_file"]
- else:
- index_file = "index.py"
-
- if "start_on_boot" in meta:
- enabled = meta["start_on_boot"]
- else:
- enabled = False
-
- if "alias" in meta:
- alias = meta["alias"]
- else:
- alias = None
-
- self.modules.append(ModuleV2(f"modules/{folder}/", index_file, enabled, alias))
-
- print(f"[INFO] reload_modules: successfully loaded {folder} as {alias} (start_on_boot: {enabled})")
-
- else:
- print(f"[WARN] reload_modules: module {folder} requires unsupported version ({meta['version']} > 2), skipping...")
-
- except Exception as e:
- print("[ERROR] module_loader: error while loading module \"{}\" ({})".format(folder, e))
-
-
-# message queue object to go back to synchronous message processing
-#class MessageQueue:
-# def __init__(self):
-# print("[INFO] Initializing the message queue...")
-# self.queue = []
-
-
-# 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")
-
- # properly reload all v2 modules
- for mod in mcu.modules:
- if mod.version == 2:
- importlib.reload(mod.obj)
-
- 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 or mod.version == 2:
- responce = mod.process(msg)
- if responce:
- print(f"Responded using module {mod.path} ({mod.alias}) with text: {responce}")
- break
-
- del message_queue[0]
- 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")
-
- print("[INFO] queue_processor thread stops successfully")
-
-
-# --- Final stage ---
-
-
-# initializing services and queues
-
-message_queue = []
-
-mcu = ModuleControlUnit()
-
-processor_thread = threading.Thread( target = queue_processor, args = [] )
-processor_thread.start()
-
-
-print("Enter testing messages one by one, end with an empty line")
-
-while True:
- new_msg = input()
- if len(new_msg) == 0:
- break
-
- message_queue.append(Message(9, round(time.time()), Chat(575246355, 'supergroup'), text = new_msg))
diff --git a/modules/auto-schedule-pro/additions.json b/modules/auto-schedule-pro/additions.json
deleted file mode 100644
index e71bbb4..0000000
--- a/modules/auto-schedule-pro/additions.json
+++ /dev/null
@@ -1,27 +0,0 @@
-[
- {
- "12:20": {"name": "Культура мовлення та ділове мовлення", "teacher": "Кушлаба М. П.", "link": "https://bbb.comsys.kpi.ua/b/myk-0iw-red-p01"}
- },
- {
- },
- {
- },
- {
- },
- {
- },
- {},
- {},
- {
- },
- {
- },
- {
- },
- {
- },
- {
- },
- {},
- {}
-]
diff --git a/modules/auto-schedule-pro/index.py b/modules/auto-schedule-pro/index.py
deleted file mode 100644
index 542e781..0000000
--- a/modules/auto-schedule-pro/index.py
+++ /dev/null
@@ -1,186 +0,0 @@
-## code ##
-if (self.MESSAGE["text"].lower() == "!пара" or self.MESSAGE["text"].lower().split()[0] == "!пари"):
-
- #getting current time
- current_time = datetime.datetime.now()
-
- current_week = current_time.isocalendar()[1] % 2
- current_day = current_time.weekday()
- current_seconds = current_week*604800 + current_day*86400 + current_time.hour*3600 + current_time.minute*60 + current_time.second
- reference_time = int(current_time.strftime("%s")) - current_seconds
-
- # baking defined schedule
- raw_schedule = json.loads( readfile(self.path + "schedule.json") )
- schedule = {}
- for day in range(len(raw_schedule)):
- for i in raw_schedule[day]:
- ts = day*86400 + int(i.split(":")[0])*3600 + int(i.split(":")[1])*60
- new_item = dict(raw_schedule[day][i])
- new_item["source"] = "schedule"
- schedule[ts] = new_item
-
- # baking additions (extra lessons)
- raw_additions = json.loads( readfile(self.path + "additions.json") )
- additions = {}
- for day in range(len(raw_additions)):
- for i in raw_additions[day]:
- ts = day*86400 + int(i.split(":")[0])*3600 + int(i.split(":")[1])*60
- new_item = dict(raw_additions[day][i])
- new_item["source"] = "additions"
- schedule[ts] = new_item
-
- full_schedule = dict(list(schedule.items()) + list(additions.items()))
-
-if self.MESSAGE["text"].lower() == "!пара":
- print("test1")
- print(f"Full schedule printout: {full_schedule}")
- print(f"Current delta_time: {current_seconds}")
- p = None
- next_lesson_time = None
-
- key_list = list(full_schedule.keys())
- key_list.sort()
- for i in key_list:
- if i > current_seconds - 5400:
- p = full_schedule[i]
- next_lesson_time = i
- break
-
- print("test2")
- if next_lesson_time == None:
- if len(full_schedule.keys()) > 0:
- print("test3.1")
- actual_lesson_ts = reference_time + min(full_schedule.keys())
- dt_lesson = datetime.datetime.fromtimestamp(actual_lesson_ts)
- dt_lesson_finish = datetime.datetime.fromtimestamp(actual_lesson_ts + 5400)
- p = full_schedule[min(full_schedule.keys())]
- print("test3.1.1")
-
- print("{} == 6 && {} == 1, {}".format(current_day, dt_lesson.strftime('%u'), str( ((current_day + 2) == int(dt_lesson.strftime("%u"))) or ((str(current_day) == "6") and (dt_lesson.strftime("%u") == "1")) )))
-
- human_readable_date = ""
- if ((current_day + 2) == int(dt_lesson.strftime("%u"))) or ((str(current_day) == "6") and (dt_lesson.strftime("%u") == "1")):
- human_readable_date += "завтра "
- elif current_week != int(dt_lesson.strftime("%W")) % 2:
- human_readable_date += "{} ".format(self.WEEKDAYS_GENITIVE_NEXT[int(dt_lesson.strftime("%u")) - 1])
- elif current_day != (int(dt_lesson.strftime("%u")) - 1):
- human_readable_date += "{} ".format(self.WEEKDAYS_GENITIVE_THIS[int(dt_lesson.strftime("%u")) - 1])
- else:
- human_readable_date += "сьогодні "
-
- print("test3.1.2")
-
- human_readable_date += "з "
-
- print("test3.1.3")
- human_readable_date += dt_lesson.strftime("%H:%M")
- print("test3.1.4")
-
- human_readable_date += " до "
- human_readable_date += dt_lesson_finish.strftime("%H:%M")
-
- self.RESPONCE = "Актуальна пара: {}\nДата: {}\nВикладач: {}\nПосилання на пару: {}".format(p['name'], human_readable_date, p['teacher'], p['link'])
- print("test3.1.5")
- else:
- self.RESPONCE = "Пар немає взагалі. Ми вільні!"
-
- else:
- print("test3.2")
- actual_lesson_ts = reference_time + next_lesson_time
- dt_lesson = datetime.datetime.fromtimestamp(actual_lesson_ts)
- dt_lesson_finish = datetime.datetime.fromtimestamp(actual_lesson_ts + 5400)
-
- human_readable_date = ""
- if ((current_day + 2) == int(dt_lesson.strftime("%u"))) or ((str(current_day) == "6") and (dt_lesson.strftime("%u") == "1")):
- human_readable_date += "завтра "
- elif current_week != int(dt_lesson.strftime("%W")) % 2:
- human_readable_date += "{} ".format(self.WEEKDAYS_GENITIVE_NEXT[int(dt_lesson.strftime("%u")) - 1])
- elif current_day != (int(dt_lesson.strftime("%u")) - 1):
- human_readable_date += "{} ".format(self.WEEKDAYS_GENITIVE_THIS[int(dt_lesson.strftime("%u")) - 1])
- else:
- human_readable_date += "сьогодні "
-
- human_readable_date += "з "
- human_readable_date += dt_lesson.strftime("%H:%M")
-
- human_readable_date += " до "
- human_readable_date += dt_lesson_finish.strftime("%H:%M")
-
- self.RESPONCE = "Актуальна пара: {}\nДата: {}\nВикладач: {}\nПосилання на пару: {}".format(p['name'], human_readable_date, p['teacher'], p['link'])
-
-if self.MESSAGE["text"].lower().split()[0] == "!пари":
- command = self.MESSAGE["text"].lower().split()
-
- preferences = {"name": True, "date": True, "teacher": True, "link": True}
- selected_day = current_week*7 + current_day
-
- if len(command) >= 2 and len(command[1]) > 0:
- if command[1][0] == "+":
- try:
- selected_day += int(command[1][1:])
- except Exception as e:
- print(f"[auto-schedule-pro:error] Got exception '{e}' while parsing {command[1]}")
- elif command[1][0] == "-":
- try:
- selected_day -= int(command[1][1:])
- except Exception as e:
- print(f"[auto-schedule-pro:error] Got exception '{e}' while parsing {command[1]}")
- else:
- try:
- selected_day = int(command[1])
- except Exception as e:
- print(f"[auto-schedule-pro:error] Got exception '{e}' while parsing {command[1]}")
-
- # keeping day in bounds
- selected_day = selected_day % 14
-
- if len(command) > 2:
- for i in command[2:]:
- if len(i) >= 2:
- if i[1:] in preferences:
- if i[0] == "+":
- preferences[i[1:]] = True
- elif i[0] == "-":
- preferences[i[1:]] = False
-
- found_lessons = {}
- for i in full_schedule:
- if selected_day*86400 <= i < (selected_day+1)*86400:
- found_lessons[i] = dict(full_schedule[i])
-
- result_text = f"Пари у {self.WEEKDAYS_ACCUSATIVE[selected_day%7]}:\n\n"
- for i in found_lessons:
- actual_lesson_ts = reference_time + i
- dt_lesson = datetime.datetime.fromtimestamp(actual_lesson_ts)
- dt_lesson_finish = datetime.datetime.fromtimestamp(actual_lesson_ts + 5400)
- p = found_lessons[i]
-
- human_readable_date = ""
- if ((current_day + 2) == int(dt_lesson.strftime("%u"))) or ((str(current_day) == "6") and (dt_lesson.strftime("%u") == "1")):
- human_readable_date += "завтра "
- elif current_week != int(dt_lesson.strftime("%W")) % 2:
- human_readable_date += "{} ".format(self.WEEKDAYS_GENITIVE_NEXT[int(dt_lesson.strftime("%u")) - 1])
- elif current_day != (int(dt_lesson.strftime("%u")) - 1):
- human_readable_date += "{} ".format(self.WEEKDAYS_GENITIVE_THIS[int(dt_lesson.strftime("%u")) - 1])
- else:
- human_readable_date += "сьогодні "
-
- human_readable_date += "з "
- human_readable_date += dt_lesson.strftime("%H:%M")
-
- human_readable_date += " до "
- human_readable_date += dt_lesson_finish.strftime("%H:%M")
-
-
- if preferences['name']:
- result_text += f"Назва: {p['name']}\n"
- if preferences['date']:
- result_text += f"Дата: {human_readable_date}\n"
- if preferences['teacher']:
- result_text += f"Викладач: {p['teacher']}\n"
- if preferences['link']:
- result_text += f"Посилання на пару: {p['link']}\n"
-
- result_text += "\n"
-
- self.RESPONCE = result_text
diff --git a/modules/auto-schedule-pro/meta.json b/modules/auto-schedule-pro/meta.json
deleted file mode 100644
index 732f1ea..0000000
--- a/modules/auto-schedule-pro/meta.json
+++ /dev/null
@@ -1,7 +0,0 @@
-{
- "start_on_boot": true,
- "alias": "auto-schedule-pro",
- "version": 1,
- "index_file": "index.py",
- "predefine": "predefine.py"
-}
diff --git a/modules/auto-schedule-pro/predefine.py b/modules/auto-schedule-pro/predefine.py
deleted file mode 100644
index c9d4242..0000000
--- a/modules/auto-schedule-pro/predefine.py
+++ /dev/null
@@ -1,6 +0,0 @@
-# Accusative - znahidnyj
-self.WEEKDAYS_ACCUSATIVE = ["понеділок", "вівторок", "середу", "четвер", "п'ятницю", "суботу", "неділю"]
-# Genitive - rodovyj
-self.WEEKDAYS_GENITIVE_NEXT = ["наступного понеділка", "наступного вівторка", "наступної середи", "наступного четверга", "наступної п'ятниці", "наступної суботи", "наступної неділі"]
-self.WEEKDAYS_GENITIVE_THIS = ["цього понеділка", "цього вівторка", "цієї середи", "цього четверга", "цієї п'ятниці", "цієї суботи", "цієї неділі"]
-self.current_seconds = 0
\ No newline at end of file
diff --git a/modules/auto-schedule-pro/schedule.json b/modules/auto-schedule-pro/schedule.json
deleted file mode 100644
index e7bb0cc..0000000
--- a/modules/auto-schedule-pro/schedule.json
+++ /dev/null
@@ -1,53 +0,0 @@
-[
- {
- "8:30": {"name": "Дискретна математика", "teacher": "Новотарський М. А.", "link": "https://us02web.zoom.us/j/87578307057?pwd=UGwyVGlwc3M4Q0Q0Q0NLWUt6bmVpUT09"},
- "10:25": {"name": "Комп'ютерна логіка", "teacher": "Жабін В. І.", "link": "https://bbb.comsys.kpi.ua/b/val-2vb-o7w-y5y АБО https://bbb.ugrid.org/b/val-osi-lup-ou8"},
- "12:20": {"name": "Культура мовлення та ділове мовлення", "teacher": "Онуфрієнко О. П.", "link": "В житті не буває нічого вічного. Життя мінливе, як і посилання на кожну нову пару. Щасти вам його віднайти!"}
- },
- {
- "12:20": {"name": "Практичний курс іноземної мови. Частина 1", "teacher": "Шевченко О. М.", "link": "https://meet.google.com/bwg-pdnr-evh"},
- "14:15": {"name": "Фізика", "teacher": "Федотов В. В. & Іванова І. М.", "link": "В житті не буває нічого вічного. Життя мінливе, як і посилання на кожну нову пару. Щасти вам його віднайти!"}
- },
- {
- "8:30": {"name": "Програмування. Частина 2. Об'єктно-орієнтоване програмування", "teacher": "Алещенко О. В.", "link": "https://us02web.zoom.us/j/2711546637?pwd=Ry82RHp3SjV6WTZRMXl6WUNod25hUT09"},
- "10:25": {"name": "Вища математика", "teacher": "Ординська З. П.", "link": "https://us04web.zoom.us/j/2684350438?pwd=kiOi3BrgbJHeYvkrx7qaSxa08J8m8O.1"}
- },
- {
- "10:25": {"name": "Вища математика", "teacher": "Ординська З. П.", "link": "https://us04web.zoom.us/j/2684350438?pwd=kiOi3BrgbJHeYvkrx7qaSxa08J8m8O.1"},
- "12:20": {"name": "Фізика", "teacher": "Русаков В. Ф.", "link": "В житті не буває нічого вічного. Життя мінливе, як і посилання на кожну нову пару. Щасти вам його віднайти!", "container_id": "1"},
- "14:15": {"name": "Програмування. Частина 2. Об'єктно-орієнтоване програмування", "teacher": "Алещенко О. В.", "link": "https://us02web.zoom.us/j/2711546637?pwd=Ry82RHp3SjV6WTZRMXl6WUNod25hUT09"}
- },
- {
- "10:25": {"name": "Фізика", "teacher": "Русаков В. Ф.", "link": "В житті не буває нічого вічного. Життя мінливе, як і посилання на кожну нову пару. Щасти вам його віднайти!", "container_id": "1"},
- "12:20": {"name": "Дискретна математика", "teacher": "Пономаренко А. М.", "link": "https://us05web.zoom.us/j/7089075754?pwd=TWRlZmxyVlFiTWU1UGlVVU1XcFE0Zz09"},
- "14:15": {"name": "Основи здорового способу життя", "teacher": "Соболенко А. І.", "link": "https://zoom.us/j/2035574145?pwd=bk1wTVhGbjJsQTR4WmVQMlROWFBCZz09"}
- },
- {},
- {},
- {
- "8:30": {"name": "Дискретна математика", "teacher": "Новотарський М. А.", "link": "https://us02web.zoom.us/j/87578307057?pwd=UGwyVGlwc3M4Q0Q0Q0NLWUt6bmVpUT09"},
- "10:25": {"name": "Комп'ютерна логіка", "teacher": "Жабін В. І.", "link": "https://bbb.comsys.kpi.ua/b/val-2vb-o7w-y5y АБО https://bbb.ugrid.org/b/val-osi-lup-ou8"},
- "12:20": {"name": "Вища математика", "teacher": "Ординська З. П.", "link": "https://us04web.zoom.us/j/2684350438?pwd=kiOi3BrgbJHeYvkrx7qaSxa08J8m8O.1"}
- },
- {
- "8:30": {"name": "Комп'ютерна логіка", "teacher": "Верба О. А.", "link": "https://us04web.zoom.us/j/7382214783?pwd=RnZ3SWgwK1JoVkZtNndnKzdPZjFGdz09"},
- "10:25": {"name": "Вища математика", "teacher": "Ординська З. П.", "link": "https://us04web.zoom.us/j/2684350438?pwd=kiOi3BrgbJHeYvkrx7qaSxa08J8m8O.1"},
- "12:20": {"name": "Практичний курс іноземної мови. Частина 1", "teacher": "Шевченко О. М.", "link": "https://meet.google.com/bwg-pdnr-evh"},
- "14:15": {"name": "Фізика", "teacher": "Федотов В. В. & Іванова І. М.", "link": "В житті не буває нічого вічного. Життя мінливе, як і посилання на кожну нову пару. Щасти вам його віднайти!"}
- },
- {
- "10:25": {"name": "Вища математика", "teacher": "Ординська З. П.", "link": "https://us04web.zoom.us/j/2684350438?pwd=kiOi3BrgbJHeYvkrx7qaSxa08J8m8O.1"}
- },
- {
- "10:25": {"name": "Вища математика", "teacher": "Ординська З. П.", "link": "https://us04web.zoom.us/j/2684350438?pwd=kiOi3BrgbJHeYvkrx7qaSxa08J8m8O.1"},
- "12:20": {"name": "Фізика", "teacher": "Русаков В. Ф.", "link": "В житті не буває нічого вічного. Життя мінливе, як і посилання на кожну нову пару. Щасти вам його віднайти!", "container_id": "1"},
- "14:15": {"name": "Програмування. Частина 2. Об'єктно-орієнтоване програмування", "teacher": "Алещенко О. В.", "link": "https://us02web.zoom.us/j/2711546637?pwd=Ry82RHp3SjV6WTZRMXl6WUNod25hUT09"}
- },
- {
- "10:25": {"name": "Фізика", "teacher": "Русаков В. Ф.", "link": "В житті не буває нічого вічного. Життя мінливе, як і посилання на кожну нову пару. Щасти вам його віднайти!", "container_id": "1"},
- "12:20": {"name": "Культура мовлення та ділове мовлення", "teacher": "Кушлаба М. П.", "link": "https://bbb.comsys.kpi.ua/b/myk-0iw-red-p01"},
- "14:15": {"name": "Основи здорового способу життя", "teacher": "Соболенко А. І.", "link": "https://zoom.us/j/2035574145?pwd=bk1wTVhGbjJsQTR4WmVQMlROWFBCZz09"}
- },
- {},
- {}
-]
diff --git a/modules/auto-schedule-pro/www/index.py b/modules/auto-schedule-pro/www/index.py
deleted file mode 100644
index af0a50c..0000000
--- a/modules/auto-schedule-pro/www/index.py
+++ /dev/null
@@ -1,165 +0,0 @@
-import datetime
-import json
-import os
-
-current_time = datetime.datetime.now()
-
-current_week = current_time.isocalendar()[1] % 2
-current_day = current_time.weekday()
-current_seconds = current_week*604800 + current_day*86400 + current_time.hour*3600 + current_time.minute*60 + current_time.second
-reference_time = int(current_time.strftime("%s")) - current_seconds
-
-# baking defined schedule
-raw_schedule = json.loads( open("../schedule.json").read() )
-schedule = {}
-for day in range(len(raw_schedule)):
- for i in raw_schedule[day]:
- ts = day*86400 + int(i.split(":")[0])*3600 + int(i.split(":")[1])*60
- new_item = dict(raw_schedule[day][i])
- new_item["source"] = "schedule"
- schedule[ts] = new_item
-
-# baking additions (extra pairs)
-raw_additions = json.loads( open("../additions.json").read() )
-additions = {}
-for day in range(len(raw_additions)):
- for i in raw_additions[day]:
- ts = day*86400 + int(i.split(":")[0])*3600 + int(i.split(":")[1])*60
- new_item = dict(raw_additions[day][i])
- new_item["source"] = "additions"
- schedule[ts] = new_item
-
-full_schedule = dict(list(schedule.items()) + list(additions.items()))
-
-#print("test1")
-#print(f"Full schedule #printout: {full_schedule}")
-#print(f"Current delta_time: {current_seconds}")
-p = None
-next_pair_time = None
-
-key_list = list(full_schedule.keys())
-key_list.sort()
-for i in key_list:
- if i > current_seconds - 5400:
- p = full_schedule[i]
- next_pair_time = i
- break
-
-#print("test2")
-if next_pair_time == None:
- if len(full_schedule.keys()) > 0:
- #print("test3.1")
-
- #actual_pair_ts = reference_time + min(full_schedule.keys())
- #dt_pair = datetime.datetime.fromtimestamp(actual_pair_ts)
- #dt_pair_finish = datetime.datetime.fromtimestamp(actual_pair_ts + 5400)
- p = full_schedule[min(full_schedule.keys())]
- #print("test3.1.1")
-
- #print("{} == 6 && {} == 1, {}".format(current_day, dt_pair.strftime('%u'), str( ((current_day + 2) == int(dt_pair.strftime("%u"))) or ((str(current_day) == "6") and (dt_pair.strftime("%u") == "1")) )))
- '''
- human_readable_date = ""
- if ((current_day + 2) == int(dt_pair.strftime("%u"))) or ((str(current_day) == "6") and (dt_pair.strftime("%u") == "1")):
- human_readable_date += "завтра "
- elif current_week != int(dt_pair.strftime("%W")) % 2:
- human_readable_date += "{} ".format(self.WEEKDAY_NAMES_ROD_WITH_NEXT[int(dt_pair.strftime("%u")) - 1])
- elif current_day != (int(dt_pair.strftime("%u")) - 1):
- human_readable_date += "{} ".format(self.WEEKDAY_NAMES_ROD_WITH_THIS[int(dt_pair.strftime("%u")) - 1])
- else:
- human_readable_date += "сьогодні "
-
- #print("test3.1.2")
-
- human_readable_date += "з "
-
- #print("test3.1.3")
- human_readable_date += dt_pair.strftime("%H:%M")
- #print("test3.1.4")
-
- human_readable_date += " до "
- human_readable_date += dt_pair_finish.strftime("%H:%M")
- '''
-
- #self.RESPONCE = "Актуальна пара: {}\nДата: {}\nВикладач: {}\nПосилання на пару: {}".format(p['name'], human_readable_date, p['teacher'], p['link'])
- #print("test3.1.5")
- if 'container_id' in p:
- try:
- cont = json.decode(open(f"../containers/{p['container_id']}", 'r').read())
- if (time.time() - cont['update_ts']) > 43200:
- if ("QUERY_STRING" in os.environ) and ("force" in os.environ['QUERY_STRING'].lower()):
- print(f"Location: {cont['link']}\n\n", end = '')
- else:
- import random
- new_seed = os.environ['REMOTE_ADDR'] + datetime.datetime.now().replace(minute = 0, second = 0).strftime("%s")
- random.seed(new_seed)
- surprise_pool = ["Йой!", "От халепа!", "Ой лишенько!"]
- print(f"Content-Type: text/html; charset=UTF-8\n\n{random.choice(surprise_pool)}
Посилання на пару {p['name']}, яке зберігається у сховищі, було отримане більш ніж 12 годин тому (рівно {time.time() - cont['update_ts']} секунд тому), тому, скоріш за все, не є дійсним.
На жаль, нового посилання ще не надходило, тому Ви можете або чекати на нього і оновлювати цю сторінку (перенаправлення станеться, щойно з'явиться нове посилання), або перейти вручну за старим посиланням (не рекомендується):
{cont['link']}
PS: щоб обійти цю сторінку та завжди автоматично переходити за будь-яким наявним посиланням, можна додати у рядок URL в кінці напис: ?force
")
- else:
- print(f"Location: {cont['link']}\n\n", end = '')
-
- except Exception as e:
- import random
- new_seed = os.environ['REMOTE_ADDR'] + datetime.datetime.now().replace(minute = 0, second = 0).strftime("%s")
- random.seed(new_seed)
- surprise_pool = ["Йой!", "От халепа!", "Ой лишенько!"]
- print(f"Content-Type: text/html; charset=UTF-8\n\n{random.choice(surprise_pool)}
Під час спроби отримання посилання на пару {p['name']} сталася непередбачена помилка. Ви можете оновлювати сторінку, поки проблема не зникне (перенаправлення відбудеться, щойно все запрацює), або пошукати посилання де-інде.
Вибачте за тимчасові незручності(
")
-
- else:
- print(f"Location: {p['link'].split()[0]}\n\n", end = '')
-
- else:
- #self.RESPONCE = "Пар немає взагалі. Ми вільні!"
- pass
-
-else:
- #print("test3.2")
- '''
- actual_pair_ts = reference_time + next_pair_time
- dt_pair = datetime.datetime.fromtimestamp(actual_pair_ts)
- dt_pair_finish = datetime.datetime.fromtimestamp(actual_pair_ts + 5400)
-
- human_readable_date = ""
- if ((current_day + 2) == int(dt_pair.strftime("%u"))) or ((str(current_day) == "6") and (dt_pair.strftime("%u") == "1")):
- human_readable_date += "завтра "
- elif current_week != int(dt_pair.strftime("%W")) % 2:
- human_readable_date += "{} ".format(self.WEEKDAY_NAMES_ROD_WITH_NEXT[int(dt_pair.strftime("%u")) - 1])
- elif current_day != (int(dt_pair.strftime("%u")) - 1):
- human_readable_date += "{} ".format(self.WEEKDAY_NAMES_ROD_WITH_THIS[int(dt_pair.strftime("%u")) - 1])
- else:
- human_readable_date += "сьогодні "
-
- human_readable_date += "з "
- human_readable_date += dt_pair.strftime("%H:%M")
-
- human_readable_date += " до "
- human_readable_date += dt_pair_finish.strftime("%H:%M")
- '''
-
- #self.RESPONCE = "Актуальна пара: {}\nДата: {}\nВикладач: {}\nПосилання на пару: {}".format(p['name'], human_readable_date, p['teacher'], p['link'])
-
- if 'container_id' in p:
- try:
- cont = json.decode(open(f"../containers/{p['container_id']}", 'r').read())
- if (time.time() - cont['update_ts']) > 43200:
- if ("QUERY_STRING" in os.environ) and ("force" in os.environ['QUERY_STRING'].lower()):
- print(f"Location: {cont['link']}\n\n", end = '')
- else:
- import random
- new_seed = os.environ['REMOTE_ADDR'] + datetime.datetime.now().replace(minute = 0, second = 0).strftime("%s")
- random.seed(new_seed)
- surprise_pool = ["Йой!", "От халепа!", "Ой лишенько!"]
- print(f"Content-Type: text/html; charset=UTF-8\n\n{random.choice(surprise_pool)}
Посилання на пару {p['name']}, яке зберігається у сховищі, було отримане більш ніж 12 годин тому (рівно {time.time() - cont['update_ts']} секунд тому), тому, скоріш за все, не є дійсним.
На жаль, нового посилання ще не надходило, тому Ви можете або чекати на нього і оновлювати цю сторінку (перенаправлення станеться, щойно з'явиться нове посилання), або перейти вручну за старим посиланням (не рекомендується):
{cont['link']}
PS: щоб обійти цю сторінку та завжди автоматично переходити за будь-яким наявним посиланням, можна додати у рядок URL в кінці напис: ?force
")
- else:
- print(f"Location: {cont['link']}\n\n", end = '')
-
- except Exception as e:
- import random
- new_seed = os.environ['REMOTE_ADDR'] + datetime.datetime.now().replace(minute = 0, second = 0).strftime("%s")
- random.seed(new_seed)
- surprise_pool = ["Йой!", "От халепа!", "Ой лишенько!"]
- print(f"Content-Type: text/html; charset=UTF-8\n\n{random.choice(surprise_pool)}
Під час спроби отримання посилання на пару {p['name']} сталася непередбачена помилка. Ви можете оновлювати сторінку, поки проблема не зникне (перенаправлення відбудеться, щойно все запрацює), або пошукати посилання де-інде.
Вибачте за тимчасові незручності(
")
-
- else:
- print(f"Location: {p['link'].split()[0]}\n\n", end = '')
-
- #print(f"Location: {p['link'].split()[0]}\n\n")
diff --git a/modules/auto-schedule/index.py b/modules/auto-schedule/index.py
deleted file mode 100644
index ebb1e6c..0000000
--- a/modules/auto-schedule/index.py
+++ /dev/null
@@ -1,45 +0,0 @@
-if self.MESSAGE["text"].lower() == "!пара-old":
- try:
- schedule = json.loads( readfile(self.path + "schedule.json") )
-
- current_time = datetime.datetime.now()
-
- current_week = current_time.isocalendar()[1] % 2
- current_day = current_time.weekday()
- current_seconds = current_time.hour * 3600 + current_time.minute * 60 + current_time.second
-
- print(f"[DEBUG] Current day is {type(current_day)}({current_day})")
- if current_day > 4 or current_day < 0:
- next_week = int(not bool(current_week))
- day = -1
-
- next_pair = None
-
- pair_found = False
- for i in schedule[next_week]:
- if not pair_found:
- day += 1
- for j in schedule[next_week][day]:
- next_pair = schedule[next_week][day][j]
- pair_found = True
- break
-
- self.RESPONCE = f"Сьогодні вихідний, тому пар немає)\n"\
- f"Наступна пара - {next_pair['subject']} ({next_pair['lector']}) о {self.reverse_timetable[int(j)]} у {self.days_rod[day]}\n"\
- f"Посилання (якщо воно чомусь треба): {next_pair['link']}"
- else:
- for i in self.timetable:
- if current_seconds < i:
- print("[DEBUG] Looking up a relevant pair...")
- try:
- relevant_pair = schedule[current_week][current_day][str(self.timetable[i])]
- self.RESPONCE = f"Актуальна пара: {relevant_pair['subject']} ({relevant_pair['lector']}), початок о {self.reverse_timetable[self.timetable[i]]}\n"\
- f"Посилання: {relevant_pair['link']}"
- break
- except Exception as e:
- print(f"[WARN] module: auto-schedule: exception {e} while looking up the pair")
- else:
- self.RESPONCE = "Сьогодні більше немає пар"
-
- except Exception as e:
- print(f"[WARN] module: auto-schedule: failed to process schedule.json ({e})")
diff --git a/modules/auto-schedule/meta.json b/modules/auto-schedule/meta.json
deleted file mode 100644
index 8ce5659..0000000
--- a/modules/auto-schedule/meta.json
+++ /dev/null
@@ -1,7 +0,0 @@
-{
- "start_on_boot": true,
- "alias": "auto-schedule",
- "version": 1,
- "index_file": "index.py",
- "predefine": "predefine.py"
-}
diff --git a/modules/auto-schedule/predefine.py b/modules/auto-schedule/predefine.py
deleted file mode 100644
index 5c20175..0000000
--- a/modules/auto-schedule/predefine.py
+++ /dev/null
@@ -1,4 +0,0 @@
-self.timetable = {36300: 0, 43200: 1, 50100: 2, 57000: 3, 63900: 4, 72300: 5, 78900: 6}
-self.days_rod = ["понеділок", "вівторок", "середу", "четвер", "п'ятницю"]
-
-self.reverse_timetable = ["8:30", "10:25", "12:20", "14:15", "16:10", "18:30", "20:20"]
diff --git a/modules/auto-schedule/schedule.json b/modules/auto-schedule/schedule.json
deleted file mode 100644
index dd4b943..0000000
--- a/modules/auto-schedule/schedule.json
+++ /dev/null
@@ -1,160 +0,0 @@
-[
- [
- {
- "0": {
- "link": "https://bbb.comsys.kpi.ua/b/ana-gca-2xm",
- "subject": "Структури даних та алгоритми",
- "lector": "Сергієнко А. М."
- },
- "1": {
- "link": "https://us05web.zoom.us/j/81227675458?pwd=SWFuQTZLY2w5a2dMMjd0cTdxSUN6dz09",
- "subject": "Вища математика",
- "lector": "Ординська З. П."
- },
- "2": {
- "link": "https://us02web.zoom.us/j/4387354937?pwd=R3R3NkpWU09GY3kvanZBeEcrQWZoUT09",
- "subject": "Основи здорового способу життя",
- "lector": "Хіміч І. Ю."
- },
- "3": {
- "link": "https://us02web.zoom.us/j/5060383482?pwd=Qk9HZGtIdVdFVHNFd0ZCY1lJbitvdz09",
- "subject": "Програмування",
- "lector": "Новотарський М. А."
- }
- },
- {
- "1": {
- "link": "https://meet.google.com/fyi-bwkm-qyf",
- "subject": "Історія науки й техніки",
- "lector": "Шевчук Т. В."
- }
- },
- {
- "0": {
- "link": "https://meet.google.com/idu-adtd-rvr?authuser=0",
- "subject": " Історія науки й техніки",
- "lector": "Костилєва С. О."
- },
- "1": {
- "link": "https://us02web.zoom.us/j/4911162386?pwd=OU43Q0thZEk1bFhvcFBRUm13VXlZZz09",
- "subject": "Аналітична геометрія та лінійна алгебра",
- "lector": "Ванєєва О. О."
- },
- "2": {
- "link": "https://us02web.zoom.us/j/5060383482?pwd=Qk9HZGtIdVdFVHNFd0ZCY1lJbitvdz09",
- "subject": "Програмування",
- "lector": "Новотарський М. А."
- },
- "3": {
- "link": "https://bbb.ugrid.org/b/val-zdp-vw0-dbr",
- "subject": "Комп'ютерна логіка",
- "lector": "Жабін В. І."
- }
- },
- {
- "1": {
- "link": "https://meet.google.com/bwg-pdnr-evh",
- "subject": "Практичний курс іноземної мови",
- "lector": "Шевченко О. М."
- },
- "2": {
- "link": "https://us05web.zoom.us/j/81227675458?pwd=SWFuQTZLY2w5a2dMMjd0cTdxSUN6dz09",
- "subject": "Вища математика",
- "lector": "Ординська З. П."
- },
- "3": {
- "link": "https://us05web.zoom.us/j/7089075754?pwd=TWRlZmxyVlFiTWU1UGlVVU1XcFE0Zz09",
- "subject": "Програмування",
- "lector": "Пономаренко"
- },
- "4": {
- "link": "https://us05web.zoom.us/j/7089075754?pwd=TWRlZmxyVlFiTWU1UGlVVU1XcFE0Zz09",
- "subject": "Програмування",
- "lector": "Пономаренко"
- }
- },
- {
- "1": {
- "link": "https://us05web.zoom.us/j/81227675458?pwd=SWFuQTZLY2w5a2dMMjd0cTdxSUN6dz09",
- "subject": "Вища математика",
- "lector": "Ординська З. П."
- },
- "2": {
- "link": "https://us04web.zoom.us/j/7382214783?pwd=RnZ3SWgwK1JoVkZtNndnKzdPZjFGdz09",
- "subject": "Комп'ютерна логіка",
- "lector": "Верба О. А."
- }
- }
- ],
- [
- {
- "0": {
- "link": "https://bbb.comsys.kpi.ua/b/ana-gca-2xm",
- "subject": "Структури даних та алгоритми",
- "lector": "Сергієнко А. М."
- },
- "1": {
- "link": "https://us05web.zoom.us/j/81227675458?pwd=SWFuQTZLY2w5a2dMMjd0cTdxSUN6dz09",
- "subject": "Вища математика",
- "lector": "Ординська З. П."
- },
- "2": {
- "link": "https://us05web.zoom.us/j/81227675458?pwd=SWFuQTZLY2w5a2dMMjd0cTdxSUN6dz09",
- "subject": "Вища математика",
- "lector": "Ординська З. П."
- },
- "3": {
- "link": "https://us02web.zoom.us/j/5060383482?pwd=Qk9HZGtIdVdFVHNFd0ZCY1lJbitvdz09",
- "subject": "Програмування",
- "lector": "Новотарський М. А."
- }
- },
- {},
- {
- "1": {
- "link": "https://us02web.zoom.us/j/4911162386?pwd=OU43Q0thZEk1bFhvcFBRUm13VXlZZz09",
- "subject": "Аналітична геометрія та лінійна алгебра",
- "lector": "Ванєєва О. О."
- },
- "2": {
- "link": "https://us02web.zoom.us/j/5060383482?pwd=Qk9HZGtIdVdFVHNFd0ZCY1lJbitvdz09",
- "subject": "Програмування",
- "lector": "Новотарський М. А."
- },
- "3": {
- "link": "https://bbb.ugrid.org/b/val-zdp-vw0-dbr",
- "subject": "Комп'ютерна логіка",
- "lector": "Жабін В. І."
- }
- },
- {
- "1": {
- "link": "https://meet.google.com/bwg-pdnr-evh",
- "subject": "Практичний курс іноземної мови",
- "lector": "Шевченко О. М."
- },
- "2": {
- "link": "https://us05web.zoom.us/j/81227675458?pwd=SWFuQTZLY2w5a2dMMjd0cTdxSUN6dz09",
- "subject": "Вища математика",
- "lector": "Ординська З. П."
- },
- "3": {
- "link": "https://us02web.zoom.us/j/4911162386?pwd=OU43Q0thZEk1bFhvcFBRUm13VXlZZz09",
- "subject": "Аналітична геометрія та лінійна алгебра",
- "lector": "Ванєєва О. О."
- }
- },
- {
- "0": {
- "link": "https://zoom.us/j/2035574145?pwd=bk1wTVhGbjJsQTR4WmVQMlROWFBCZz09",
- "subject": " Основи здорового способу життя",
- "lector": "Соболенко А. І."
- },
- "1": {
- "link": "https://us02web.zoom.us/j/88932218187?pwd=MUpFNjE3bHAxeEZ0NDE3NU0vYUUxZz09",
- "subject": "Структури даних та алгоритми",
- "lector": "Молчанова А. А."
- }
- }
- ]
-]
diff --git a/modules/echo-v1.0/index.py b/modules/echo-v1.0/index.py
deleted file mode 100644
index 9d384d9..0000000
--- a/modules/echo-v1.0/index.py
+++ /dev/null
@@ -1,2 +0,0 @@
-if msg.chat["type"] == "private":
- self.RESPONCE = self.MESSAGE["text"]
diff --git a/modules/echo-v1.0/meta.json b/modules/echo-v1.0/meta.json
deleted file mode 100644
index c489c9b..0000000
--- a/modules/echo-v1.0/meta.json
+++ /dev/null
@@ -1,5 +0,0 @@
-{
- "version": 1,
- "index_file": "index.py",
- "start_on_boot": false
-}
diff --git a/modules/irc-bridge/bot.py b/modules/irc-bridge/bot.py
deleted file mode 100644
index 93392c8..0000000
--- a/modules/irc-bridge/bot.py
+++ /dev/null
@@ -1,122 +0,0 @@
-import time
-import socket
-import threading
-
-login_lines_raw = [
- "NICK bridge",
- "USER bridge bridge * !",
- "JOIN #io23-bridge"
-]
-
-login_lines = map( lambda x: (x + "\n").encode("utf-8"), login_lines_raw )
-
-recv_s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
-s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
-
-send_buffer = []
-reconnecting = False
-
-LINE_END = "\r\n".encode("utf-8")
-
-recv_s.bind( ("127.0.0.1", 5001) )
-
-def reconnect():
- global s, reconnecting
- reconnecting = True
- while True:
- try:
- s.close()
- except:
- pass
-
- try:
- s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
- s.connect( ("10.1.1.1", 6667) )
-
- for i in login_lines:
- s.send(i)
- time.sleep(0.5)
-
- reconnecting = False
- break
- except Exception as e:
- print(f"[reconnect:main] ERROR: got exception {e}")
- t = time.time()
- open("error.log", "a", encoding = "utf-8").write(f"[{t}] recv_thread:main ERROR: got exception {e}\n")
-
- time.sleep(2)
-
-def recv_thread():
- global s, send_buffer, reconnecting
- databuffer = bytes()
- while True:
- try:
- new_data = s.recv(1024)
- print(f"[DEBUG] new_data: {new_data}")
- if len(new_data) == 0:
- if not reconnecting:
- reconnect() # bin the old socket and get a new one instead
- continue
-
- databuffer += new_data
-
- if LINE_END in databuffer:
- commands = map( lambda x: x.decode("UTF-8"), databuffer.split(LINE_END)[:-1])
-
- for command in commands:
- if len(command) > 0:
- if command.split(" ")[0] == "PING":
- print("[DEBUG] recv_thread:command:ping: Responding with {}".format(command.split(" ")[1]).encode("UTF-8"))
- send_buffer.append(("PONG {}\n".format( command.split(" ")[1]).encode("UTF-8") ))
- else:
- pass
-
- databuffer = databuffer.split(LINE_END)[-1]
- except Exception as e:
- print(f"[recv_thread:main] ERROR: got exception {e}")
- t = time.time()
- open("error.log", "a", encoding = "utf-8").write(f"[{t}] recv_thread:main ERROR: got exception {e}\n")
- try:
- if not reconnecting:
- reconnect()
- except Exception as e:
- print(f"[recv_thread:except:reconnect] ERROR: got exception {e}")
- t = time.time()
- open("error.log", "a", encoding = "utf-8").write(f"[{t}] recv_thread:except:reconnect ERROR: got exception {e}\n")
-
-def send_thread():
- global s, send_buffer, reconnecting
- while True:
- if len(send_buffer) > 0:
- try:
- print(f"[DEBUG] send_thread: sending {send_buffer[0]}")
- s.send(send_buffer[0])
- del send_buffer[0]
- except Exception as e:
- print(f"[send_thread:main] ERROR: got exception {e}")
- t = time.time()
- open("error.log", "a", encoding = "utf-8").write(f"[{t}] send_thread:main ERROR: got exception {e}\n")
-
- if not reconnecting:
- reconnect()
-
- time.sleep(0.2)
- else:
- time.sleep(3)
-
-def msg_thread():
- global recv_s, send_buffer
- while True:
- d = recv_s.recvfrom(16384)
- print(f"[DEBUG] msg_thread:d: {d}")
- send_buffer.append(d[0])
-
-st = threading.Thread(target = send_thread, args = [])
-rt = threading.Thread(target = recv_thread, args = [])
-mt = threading.Thread(target = msg_thread, args = [])
-
-reconnect()
-
-st.start()
-rt.start()
-mt.start()
diff --git a/modules/irc-bridge/index.py b/modules/irc-bridge/index.py
deleted file mode 100644
index e27e77f..0000000
--- a/modules/irc-bridge/index.py
+++ /dev/null
@@ -1,10 +0,0 @@
-if self.MESSAGE["chat"]["id"] == -1001570221452:
- l = min( len(self.MESSAGE["text"]), 300 )
- new_msg = "{} {}: {}".format(self.MESSAGE.from_user.first_name,\
- self.MESSAGE.from_user.last_name,\
- self.MESSAGE.text.replace("\n", " | ")[:l])
-
- import socket
- s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
- s.sendto(f"PRIVMSG #io23-bridge :{new_msg}\n".encode("utf-8"), ("127.0.0.1", 5001))
- del s
diff --git a/modules/irc-bridge/meta.json b/modules/irc-bridge/meta.json
deleted file mode 100644
index 0309cdc..0000000
--- a/modules/irc-bridge/meta.json
+++ /dev/null
@@ -1,7 +0,0 @@
-{
- "start_on_boot": true,
- "alias": "irc-bridge",
- "version": 1,
- "index_file": "index.py",
- "predefine": "predefine.py"
-}
diff --git a/modules/irc-bridge/predefine.py b/modules/irc-bridge/predefine.py
deleted file mode 100644
index 7d007f2..0000000
--- a/modules/irc-bridge/predefine.py
+++ /dev/null
@@ -1,5 +0,0 @@
-import socket
-
-SEND_ADDR = ( "127.0.0.1", 5001 )
-
-s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
diff --git a/modules/mass-tagger/index.py b/modules/mass-tagger/index.py
deleted file mode 100644
index 667a3de..0000000
--- a/modules/mass-tagger/index.py
+++ /dev/null
@@ -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))
diff --git a/modules/mass-tagger/meta.json b/modules/mass-tagger/meta.json
deleted file mode 100644
index f27d2a4..0000000
--- a/modules/mass-tagger/meta.json
+++ /dev/null
@@ -1,7 +0,0 @@
-{
- "version": 1,
- "index_file": "index.py",
- "predefine": "predefine.py",
- "start_on_boot": true,
- "alias": "mass-tagger"
-}
diff --git a/modules/mass-tagger/predefine.py b/modules/mass-tagger/predefine.py
deleted file mode 100644
index 3eeadb6..0000000
--- a/modules/mass-tagger/predefine.py
+++ /dev/null
@@ -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"}
-}
diff --git a/modules/module-v2-example/index.py b/modules/module-v2-example/index.py
deleted file mode 100644
index c48f583..0000000
--- a/modules/module-v2-example/index.py
+++ /dev/null
@@ -1,16 +0,0 @@
-class Counter:
- def __init__(self):
- self.counter = 0
-
- def call_count(self):
- self.counter += 1
- return self.counter
-
-c = Counter()
-
-def get_num():
- return c.call_count()
-
-def process(message, path):
- if message.text == "!v2-testing":
- return f"Testing successful - call number {get_num()}"
diff --git a/modules/module-v2-example/meta.json b/modules/module-v2-example/meta.json
deleted file mode 100644
index dc5c36c..0000000
--- a/modules/module-v2-example/meta.json
+++ /dev/null
@@ -1,6 +0,0 @@
-{
- "version": 2,
- "index_file": "index.py",
- "start_on_boot": true,
- "alias": "module-v2-example"
-}
diff --git a/modules/qna-basic/db/obj.json b/modules/qna-basic/db/obj.json
deleted file mode 100644
index b2fad31..0000000
--- a/modules/qna-basic/db/obj.json
+++ /dev/null
@@ -1,6 +0,0 @@
-{
- "trigger_lists": [
- ["коли", "тест", "обж"]
- ],
- "responce_text": "Тести з ОБЖ необхідно проходити лише тим студентам, які не були на практичному занятті. Якщо Ви були на практиці, але все одно пройдете тест, то ризикуєте отримати нижчу оцінку та знизити свій загальний бал"
-}
diff --git a/modules/qna-basic/index.py b/modules/qna-basic/index.py
deleted file mode 100644
index a59822c..0000000
--- a/modules/qna-basic/index.py
+++ /dev/null
@@ -1,25 +0,0 @@
-msg = self.MESSAGE["text"].lower()
-
-responce_given = False
-
-for file in os.listdir(self.path + "db/"):
- if responce_given:
- break
-
- try:
- criteria = json.loads( readfile(self.path + "db/" + file) )
-
- for wordset in criteria["trigger_lists"]:
- all_words_in = True
- for word in wordset:
- if word not in msg:
- all_words_in = False
- break
-
- if all_words_in:
- self.RESPONCE = criteria["responce_text"]
- responce_given = True
- break
-
- except Exception as e:
- print("[WARN] module : qna-basic: db file {} raised exception \"{}\"".format(file, e))
diff --git a/modules/qna-basic/meta.json b/modules/qna-basic/meta.json
deleted file mode 100644
index 73757df..0000000
--- a/modules/qna-basic/meta.json
+++ /dev/null
@@ -1,6 +0,0 @@
-{
- "version": 1,
- "index_file": "index.py",
- "start_on_boot": true,
- "alias": "qna-basic"
-}
diff --git a/modules/transliteration-decoder/index.py b/modules/transliteration-decoder/index.py
deleted file mode 100644
index 866f887..0000000
--- a/modules/transliteration-decoder/index.py
+++ /dev/null
@@ -1,30 +0,0 @@
-command = self.MESSAGE['text'].split(" ", 2)
-command_length = len(command)
-
-if (command[0] in self.aliases) and (1 <= command_length <= 3):
- try:
- models = json.loads(readfile(self.path + "translate_models.json"))
-
- if command_length == 1:
- chosen_model = "cz-ua"
- else:
- chosen_model = command[1]
-
- if command_length == 3:
- text_to_decode = command[2]
- else:
- text_to_decode = self.MESSAGE['reply_to_message']['text']
-
- decoded_text = text_to_decode
- if chosen_model not in models:
- self.RESPONCE = f"Такого варіанту транслітерації не існує. Доступні варіанти: {', '.join(list(models.keys()))}"
- else:
- for i in models[chosen_model]:
- decoded_text = decoded_text.replace(i[0], i[1])
- decoded_text = decoded_text.replace(i[0].capitalize(), i[1].capitalize())
- decoded_text = decoded_text.replace(i[0].upper(), i[1].upper())
-
- self.RESPONCE = f"Результат: {decoded_text}"
-
- except Exception as e:
- print(f"[translit-decoder] Got exception: {e}")
diff --git a/modules/transliteration-decoder/meta.json b/modules/transliteration-decoder/meta.json
deleted file mode 100644
index 94db3ee..0000000
--- a/modules/transliteration-decoder/meta.json
+++ /dev/null
@@ -1,7 +0,0 @@
-{
- "version": 1,
- "index_file": "index.py",
- "start_on_boot": true,
- "alias": "translit-decoder",
- "predefine": "predefine.py"
-}
diff --git a/modules/transliteration-decoder/predefine.py b/modules/transliteration-decoder/predefine.py
deleted file mode 100644
index cb45e84..0000000
--- a/modules/transliteration-decoder/predefine.py
+++ /dev/null
@@ -1 +0,0 @@
-self.aliases = ["!decode", "!dc"]
diff --git a/modules/transliteration-decoder/translate_models.json b/modules/transliteration-decoder/translate_models.json
deleted file mode 100644
index d931d09..0000000
--- a/modules/transliteration-decoder/translate_models.json
+++ /dev/null
@@ -1,79 +0,0 @@
-{
- "cz-ua": [
- ["šč", "щ"],
- ["ja", "я"],
- ["ju", "ю"],
- ["ji", "ї"],
- ["je", "є"],
- ["f", "ф"],
- ["b", "б"],
- ["ž", "ж"],
- ["q", "к"],
- ["š", "ш"],
- ["n", "н"],
- ["p", "п"],
- ["r", "р"],
- ["s", "с"],
- ["t", "т"],
- ["h", "х"],
- ["č", "ч"],
- ["'", "ь"],
- ["y", "и"],
- ["z", "з"],
- ["l", "л"],
- ["k", "к"],
- ["d", "д"],
- ["u", "у"],
- ["m", "м"],
- ["v", "в"],
- ["j", "й"],
- ["c", "ц"],
- ["a", "а"],
- ["i", "і"],
- ["g", "г"],
- ["`", "'"]
- ],
- "en-ua-direct": [
- ["q", "й"],
- ["w", "ц"],
- ["e", "у"],
- ["r", "к"],
- ["t", "е"],
- ["y", "н"],
- ["u", "г"],
- ["i", "ш"],
- ["o", "щ"],
- ["p", "з"],
- ["[", "х"],
- ["]", "ї"],
- ["a", "ф"],
- ["s", "і"],
- ["d", "в"],
- ["f", "а"],
- ["g", "п"],
- ["h", "р"],
- ["j", "о"],
- ["k", "л"],
- ["l", "д"],
- [";", "ж"],
- [":", "Ж"],
- ["\"", "Є"],
- ["'", "є"],
- ["z", "я"],
- ["x", "ч"],
- ["c", "с"],
- ["v", "м"],
- ["b", "и"],
- ["n", "т"],
- ["m", "ь"],
- [",", "б"],
- [".", "ю"],
- ["/", "."],
- ["?", ","],
- ["@", "\""],
- ["#", "№"],
- ["$", ";"],
- ["^", ":"],
- ["&", "?"]
- ]
-}