forked from JogleLew/channel-helper-bot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
option_cmd.py
47 lines (41 loc) · 1.29 KB
/
option_cmd.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#!/usr/bin/env python
# -*- coding: utf-8 -*-
""" Channel Helper Bot """
""" option_cmd.py """
""" Copyright 2018, Jogle Lew """
import helper_const
import helper_global
import helper_database
import telegram
import telegram
from telegram import InlineKeyboardButton, InlineKeyboardMarkup
from telegram.ext import CommandHandler
def option(bot, update):
from_id = update.message.from_user.id
chat_id = update.message.chat_id
records = helper_database.get_channel_info_by_user(from_id)
if records is None or len(records) == 0:
bot.send_message(
chat_id=chat_id,
text=helper_global.value("option_no_channel", "")
)
return
#Prepare keyboard
motd_keyboard = [[
InlineKeyboardButton(
"@" + record[1] if record[1] else "id: " + str(record[0]),
callback_data="option,%s" % record[0]
)
] for record in records] + [[
InlineKeyboardButton(
helper_global.value("option_finish", ""),
callback_data="option_finish"
)
]]
motd_markup = InlineKeyboardMarkup(motd_keyboard)
bot.send_message(
chat_id=chat_id,
text=helper_global.value("option_choose_channel", ""),
reply_markup=motd_markup
)
_handler = CommandHandler('option', option)