def show_companies_in_subcategory(message, subcategoryID): """ User will see info about companies """ list_of_companies = get_company_info(subcategoryID) if not list_of_companies: execuse_smth(message, code=1) ## return None for company in list_of_companies: """ keyboard = types.InlineKeyboardMarkup() text_url = "https://beautyhttp.herokuapp.com/redirect_user/" text_url += str(m.chat.id) + "/" text_url += company[5] + "/" # print(text_url) url_button = types.InlineKeyboardButton( text="telegram канал", url=text_url) keyboard.add(url_button) """ keyboard = types.InlineKeyboardMarkup(row_width=2) callback_button_1 = types.InlineKeyboardButton(text="class", callback_data="class") callback_button_2 = types.InlineKeyboardButton( text="not_class", callback_data="not_class") keyboard.add(callback_button_1, callback_button_2) bot.send_message(message.chat.id, company_out_text(company), reply_markup=keyboard)
def execuse_smth(message, code): """ Report user about problem """ text = code_wrongs[code] bot.send_message(message.chat.id, text) return
def get_statistics(message): """ To know your chat_id """ print(str(message.chat.id)) if m.chat.id in superusers: counts = get_visit_counts() print(str(counts)) bot.send_message( m.chat.id, UNIQUE_USERS, UNIQUE_CLICKS % ( ## counts[0], counts[1]))
def handling_error(e): """ Report developers about problems """ # print(e) bot.send_message(my_chat, e) t = datetime.strftime(datetime.now(), "%Y.%m.%d %H:%M:%S") f = open('errors.txt', 'a') text = str(e) + '\n' + t + '\n' f.write(text) f.close() bot.send_message(my_chat, t)
def invalidate(m, text_mes, list, buttonBack=0): """ Show a grid of buttons, which associated with elements of list """ keyboard = types.ReplyKeyboardMarkup(resize_keyboard=True, row_width=2, one_time_keyboard=True) keyboard.add(*[types.KeyboardButton(n) for n in list]) if buttonBack == 1: keyboard.add(types.KeyboardButton(BACK)) msg = bot.send_message(m.chat.id, text_mes, reply_markup=keyboard) return msg
def callback_inline(call): if call.data == "class": bot.send_message(call.message.chat.id, "class") if call.data == "not_class": bot.send_message(call.message.chat.id, "not_class")