Commit d398ca48 authored by Antonin Ferrand's avatar Antonin Ferrand
Browse files

Initial Commit

parents
secrets.py
env
__pycache__
\ No newline at end of file
import telepot
from time import sleep
from telepot.loop import MessageLoop
from telepot.namedtuple import InlineKeyboardMarkup, InlineKeyboardButton
from secrets import TOKEN, admin_ids
bot = telepot.Bot(TOKEN)
def generateKeyboard():
buttons = [InlineKeyboardButton(text='Button 1', callback_data='data_1')]
inline_keyboard = [buttons]
return InlineKeyboardMarkup(inline_keyboard=inline_keyboard)
def handleMessage(msg):
print(msg)
chan_id = msg['chat']['id']
if '/get_permission' in msg['text']:
if msg['from']['id'] in admin_ids:
bot.sendMessage(chan_id, "You are admin of this bot.")
else:
bot.sendMessage(chan_id, "You are not admin of this bot.")
if '/get_admins' == msg['text']:
message = "<b>Les administrateurs de ce bot sont : </b> \n"
for username in admin_ids.values():
message += f"- {username} \n"
bot.sendMessage(chan_id, message, parse_mode='HTML')
if '/testKeyboard' in msg['text']:
keyboard = generateKeyboard()
bot.sendMessage(chan_id,
"Test keyboard : ",
parse_mode='HTML',
reply_markup=keyboard)
def handleInlineKeyboard(callback):
print(callback)
MessageLoop(bot, {
'chat': handleMessage,
'callback_query': handleInlineKeyboard
}).run_as_thread()
while 1:
sleep(1)
{
"message_id": <integer>,
"from": {
"id": <integer>,
"is_bot": <boolean>,
"first_name": <string>,
"username": <string>,
"language_code": <string>
},
"chat": {
"id": <integer>,
"first_name": <string>,
"username": <string>,
"type": <string>
},
"date": <timestamp : integer>,
"text": <string>,
"entities": [{ "offset": <integer>, "length": <integer>, "type": <string> }]
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment