def keyboard_finished(self): buttons = [ KeyboardButton(self.CANCEL), KeyboardButton(self.FINISHED) ] menu = utl.build_menu(buttons, n_cols=2) return ReplyKeyboardMarkup(menu, resize_keyboard=True)
def keyboard_datetime(self): buttons = [ KeyboardButton(self.CANCEL), KeyboardButton(self.NO_END) ] menu = utl.build_menu(buttons, n_cols=2) return ReplyKeyboardMarkup(menu, resize_keyboard=True)
def cmd_notify(self, bot, update): user_id = update.effective_user.id sql = self.get_global_resource("select_user.sql") res = self.execute_global_sql(sql, user_id) if not res["success"]: msg = f"{emo.ERROR} Not possible to retrieve user: {res['data']}" update.message.reply_text(msg) self.notify(msg) return if res["data"][0]: telegram = res["data"][0][5] email = res["data"][0][6] discord = res["data"][0][7] else: telegram = email = discord = str() msg = f"*Current notification settings*\n\n" \ f"`Telegram: {'Enabled' if telegram else 'Disabled'}`\n" \ f"`Discord : {'Enabled' if discord else 'Disabled'}`\n" \ f"`E-Mail : {'Enabled' if email else 'Disabled'}`\n\n" \ f"Choose which notification type to edit" buttons = [ InlineKeyboardButton(self.TYPE_TG, callback_data=self.TYPE_TG), InlineKeyboardButton(self.TYPE_EM, callback_data=self.TYPE_EM), InlineKeyboardButton(self.TYPE_DC, callback_data=self.TYPE_DC) ] menu = utl.build_menu(buttons, n_cols=3) keyboard = InlineKeyboardMarkup(menu, resize_keyboard=True) update.message.reply_text(msg, reply_markup=keyboard, parse_mode=ParseMode.MARKDOWN) return self.ONOFF
def callback_onoff(self, bot, update, user_data): query = update.callback_query if query.data not in [self.TYPE_DC, self.TYPE_EM, self.TYPE_TG]: return user_data["type"] = query.data buttons = [ InlineKeyboardButton(self.ONOFF_Y, callback_data=self.ONOFF_Y), InlineKeyboardButton(self.ONOFF_N, callback_data=self.ONOFF_N) ] menu = utl.build_menu(buttons, n_cols=2) keyboard = InlineKeyboardMarkup(menu, resize_keyboard=True) bot.edit_message_text( chat_id=query.message.chat_id, message_id=query.message.message_id, text=f"Enable {user_data['type']} notifications?", reply_markup=keyboard) return self.DATA
def _show_button(self, row_id): data = f"{self._PREFIX}{row_id}" menu = utl.build_menu( [InlineKeyboardButton("Show Results", callback_data=data)]) return InlineKeyboardMarkup(menu, resize_keyboard=True)
def callback_enable(self, bot, update, user_data): query = update.callback_query user_id = query.from_user.id if query.data not in [self.ONOFF_N, self.ONOFF_Y]: return user_data["enable"] = query.data if user_data["enable"] == self.ONOFF_N: sql = str() if user_data["type"] == self.TYPE_TG: sql = self.get_resource("update_telegram.sql") elif user_data["type"] == self.TYPE_EM: sql = self.get_resource("update_email.sql") elif user_data["type"] == self.TYPE_DC: sql = self.get_resource("update_discord.sql") if sql: self.execute_global_sql(sql, None, user_id) bot.edit_message_text( chat_id=query.message.chat_id, message_id=query.message.message_id, text=f"{emo.CANCEL} {user_data['type']} notifications disabled" ) return ConversationHandler.END user_data["enable"] = self.ONOFF_Y menu = utl.build_menu( [InlineKeyboardButton(self.CANCEL, callback_data=self.CANCEL)]) keyboard = InlineKeyboardMarkup(menu, resize_keyboard=True) msg = str() if user_data["type"] == self.TYPE_TG: sql = self.get_resource("update_telegram.sql") self.execute_global_sql(sql, user_id, user_id) bot.edit_message_text( chat_id=query.message.chat_id, message_id=query.message.message_id, text=f"{emo.CHECK} {self.TYPE_TG} notifications enabled") return ConversationHandler.END elif user_data["type"] == self.TYPE_EM: msg = f"Please send me your {self.TYPE_EM} address or press {self.CANCEL}" elif user_data["type"] == self.TYPE_DC: #msg = f"Please send me your {self.TYPE_DC} ID or press {self.CANCEL}" # TODO: Remove this if Discord notifications are possible bot.edit_message_text( chat_id=query.message.chat_id, message_id=query.message.message_id, text= f"{emo.SKULL} {self.TYPE_DC} notifications not available yet") return ConversationHandler.END bot.edit_message_text(chat_id=query.message.chat_id, message_id=query.message.message_id, text=msg, reply_markup=keyboard) return self.FINAL
def _remove_button(self, row_id): data = f"list_{row_id}" menu = utl.build_menu([ InlineKeyboardButton("Remove from Watchlist", callback_data=data) ]) return InlineKeyboardMarkup(menu, resize_keyboard=True)
def keyboard_cancel(self): menu = utl.build_menu([KeyboardButton(self.CANCEL)], n_cols=1) return ReplyKeyboardMarkup(menu, resize_keyboard=True)
def _result_button(self, uid): menu = utl.build_menu( [InlineKeyboardButton("Show Results", callback_data=f"{uid}")]) return InlineKeyboardMarkup(menu, resize_keyboard=True)