def cmd_gaps_get_notes(update, context): """ treatment of command /getgapsnotes [<year> [<branch> ...]] Send to user the note. If no year and no branch specified, all mark in cache send If only no branch specified, all mark of the specific year send If multiple branch specified, all mark of specified branch send :param update: :type update: telegram.Update :param context: :type context: telegram.ext.CallbackContext """ u = User(update.effective_user.id) if len(context.args) >= 1: year = context.args[0] courses = context.args[1:] u.gaps().send_notes(year, courses, update.effective_chat.id) else: usage("cmd_gaps_get_notes", user=u, prefix=True, send=True, chat_id=update.effective_chat.id) u.gaps().send_notes_all(update.effective_chat.id)
def cmd_gaps_check_notes(update, context): """ treatment of command /checkgapsnotes Check online if user have new mark or an update :param update: :type update: telegram.Update :param context: :type context: telegram.ext.CallbackContext """ u = User(update.effective_user.id) u.gaps().check_gaps_notes()
def cmd_gaps_set_credentials(update, context): """ treatment of command /gapssetcredentials Change user credentials for connexion to GAPS, for security the message from user contain password is deleted :param update: :type update: telegram.Update :param context: :type context: telegram.ext.CallbackContext """ u = User(update.effective_user.id) if len(context.args) == 2: act_result = u.gaps().set_credentials(context.args[0], context.args[1]) u.send_message("set GAPS credentials : " + act_result, chat_id=update.effective_chat.id) else: usage("cmd_gaps_set_credentials", user=u, prefix=True, send=True, chat_id=update.effective_chat.id) context.bot.delete_message(update.effective_chat.id, update.effective_message.message_id) u.send_message("Your message has been deleted for security", chat_id=update.effective_chat.id)
def cmdsetgapscredentials(update, context): """ treatment of command /setgappscredentials Change user credentials for connexion to GAPS, for security the message from user contain password is deleted :param update: :type update: telegram.Update :param context: :type context: telegram.ext.CallbackContext """ user = User(update.effective_user.id) if (len(context.args) == 2): act_result = user.gaps().set_credentials(context.args[0], context.args[1]) user.send_message("set GAPS credentials : " + act_result, chat_id=update.effective_chat.id) else: user.send_message("Usage : /setgapscredentials username password", chat_id=update.effective_chat.id) context.bot.delete_message(update.effective_chat.id, update.effective_message.message_id) user.send_message("Your message has been deleted for security", chat_id=update.effective_chat.id)
def cmd_gaps_remove_password(update, context): """ treatment of command /gapsremovepassword Delete user credentials for connexion to GAPS :param update: :type update: telegram.Update :param context: :type context: telegram.ext.CallbackContext """ u = User(update.effective_user.id) u.gaps().unset_credentials() u = User(update.effective_user.id) if u.gaps().is_registred(): u.send_message("Sorry, failed to delete credentials", chat_id=update.effective_chat.id) else: u.send_message("credentials deleted", chat_id=update.effective_chat.id)
def cmd_gaps_notes_track(update, context) -> None: """ treatment of command /gapsnotestrack Get tracking gaps note value treatment of command /gapsnotestrack * treatment of command /gapsnotestrack [<branchname> ...] Set tracking gaps note value :param update: :type update: telegram.Update :param context: :type context: telegram.ext.CallbackContext """ u = User(update.effective_user.id) text = "" if len(context.args) == 1 and context.args[0] == "*": u.gaps().set_tracking(type="notes", branch_list=True, user_id=update.effective_chat.id) elif len(context.args) >= 1: u.gaps().set_tracking(type="notes", branch_list=context.args, user_id=update.effective_chat.id) else: usage("cmd_gaps_notes_track", user=u, prefix=True, send=True, chat_id=update.effective_chat.id) if u.gaps().tracking("notes", user_id=update.effective_chat.id): text += "Tracking gaps notes is *enable*" else: text += "Tracking gaps notes is *disable*" u.send_message(text, chat_id=update.effective_chat.id, parse_mode="Markdown")
def cmd_gaps_notes_untrack(update, context) -> None: """ treatment of command /gapsnotesuntrack Disable tracking gaps note :param update: :type update: telegram.Update :param context: :type context: telegram.ext.CallbackContext """ u = User(update.effective_user.id) u.gaps().set_tracking(type="notes", branch_list=False, user_id=update.effective_chat.id) if u.gaps().tracking("notes", user_id=update.effective_chat.id): text = "Tracking gaps notes is *enable*" else: text = "Tracking gaps notes is *disable*" u.send_message(text, chat_id=update.effective_chat.id, parse_mode="Markdown")
def cmd_gaps_clear_notes(update, context): """ treatment of command /gapsclearnotes Remove cache of GAPS notes :param update: :type update: telegram.Update :param context: :type context: telegram.ext.CallbackContext """ u = User(update.effective_user.id) u.gaps()._data["notes"] = {} u.save() u.send_message("Notes cache cleared", chat_id=update.effective_chat.id)
def cmd_gaps_calendar(update, context) -> None: """ treatment of command /calendar <YYYY-MM-DD> Get timetable for a day :param update: :type update: telegram.Update :param context: :type context: telegram.ext.CallbackContext """ u = User(update.effective_user.id) if len(context.args) == 1: dt = arrow.get(context.args[0]) else: dt = arrow.now() text = u.gaps().get_day_lesson(text=True, dt=dt) u.send_message(text, chat_id=update.effective_chat.id, parse_mode="Markdown")
This file is part of heig-bot. heig-bot is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. heig-bot is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with heig-bot. If not, see <https://www.gnu.org/licenses/>. """ import os from heig.init import config from heig.user import User, DIR_DB_PICKLE for i in os.scandir(config()["database_directory"] + DIR_DB_PICKLE): id = i.name[:-7] user = User(id) try: user.gaps().check_gaps_notes(id, auto=True) except: print("Error for " + id) #for id in config["logs_userid"]: #updater.bot.send_message(chat_id=id, text="Bonjour")
heig-bot is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. heig-bot is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with heig-bot. If not, see <https://www.gnu.org/licenses/>. """ import os from heig.init import config from heig.user import User, DIR_DB_PICKLE for i in os.scandir(config()["database_directory"]+DIR_DB_PICKLE): id = i.name[:-7] user = User(id) try: if user.gaps().is_registred(): user.gaps().check_gaps_notes() else: user.debug("Auto sync notes ignored") except: user.debug("Auto sync notes ERROR") print("["+id+"] Error")