def _resetpass(self, update: Update, context: CallbackContext): log_command(update) if not check_auth(update): return bc.config.telegram["passphrase"] = uuid.uuid4().hex log.warning("New passphrase: " + bc.config.telegram["passphrase"]) reply(update, 'Passphrase has been reset!')
def _handle_mentions(self, update: Update, context: CallbackContext) -> None: text = update.message.text log.info("(" + update.message.chat.title + ") " + update.message.from_user.username + ": " + text) if not check_auth(update): return result = bc.markov.generate() reply(update, result)
def _about(self, update: Update, context: CallbackContext): log_command(update) if not check_auth(update): return cmd_txt = context.args[0] if context.args else "" verbosity = 0 if cmd_txt == "-v": verbosity = 1 elif cmd_txt == "-vv": verbosity = 2 reply(update, bc.info.get_full_info(verbosity))
def _poll(self, update: Update, context: CallbackContext): log_command(update) if not check_auth(update): return if len(context.args) < 2: reply(update, "Usage: /poll option 1;option 2;option 3") return options = ' '.join(context.args).split(';') context.bot.send_poll( update.effective_chat.id, "Poll", options, )
def _listreminder(self, update: Update, context: CallbackContext): log_command(update) if not check_auth(update): return reminder_list = [] for index, reminder in bc.config.reminders.items(): rep = f' (repeats every {reminder.repeat_after} {reminder.repeat_interval_measure})' prereminders = f' ({", ".join([str(x) + " min" for x in reminder.prereminders_list])} prereminders enabled)' reminder_list.append( (reminder.time, reminder.message, f"{index} at {reminder.time} " f" in <#{reminder.channel_id}> (Discord)'" f"{rep if reminder.repeat_after else ''}" f"{prereminders if reminder.prereminders_list else ''}")) reminder_list.sort() result = "" for reminder in reminder_list: result += f"{reminder[0]}: {reminder[1]} {reminder[2]}\n" reply(update, result if result else "No reminders")
def _handle_messages(self, update: Update, context: CallbackContext) -> None: text = update.message.text log.info("(" + update.message.chat.title + ") " + update.message.from_user.username + ": " + text) if not check_auth(update): return bc.markov.add_string(text)
def _markov(self, update: Update, context: CallbackContext): log_command(update) if not check_auth(update): return result = bc.markov.generate() reply(update, result)
def _ping(self, update: Update, context: CallbackContext): log_command(update) if not check_auth(update): return reply(update, 'Pong!')