Return User ID
This commit is contained in:
parent
0776585f75
commit
3f2b2379fe
35
bot.py
35
bot.py
@ -3,20 +3,43 @@
|
||||
# text bot at t.me/projektaktienbot
|
||||
# API Documentation https://core.telegram.org/bots/api
|
||||
# Code examples https://github.com/eternnoir/pyTelegramBotAPI#getting-started
|
||||
import os
|
||||
import telebot
|
||||
import time
|
||||
import sys
|
||||
import logging
|
||||
from telebot import types
|
||||
|
||||
bot = telebot.TeleBot(os.getenv('BOT_API_KEY'))
|
||||
|
||||
bot = telebot.TeleBot("5228016873:AAGFrh0P6brag7oD3gxXjCh5gnLLE8JMvMs")
|
||||
|
||||
@bot.message_handler(commands=['start', 'help'])
|
||||
def send_welcome(message):
|
||||
bot.reply_to(message, "Thank you for using this bot")
|
||||
|
||||
|
||||
@bot.message_handler(func=lambda message: True)
|
||||
def echo_all(message):
|
||||
bot.reply_to(message, message.text)
|
||||
answer = message.text + ' ID: ' + str(message.from_user.id)
|
||||
bot.reply_to(message, answer)
|
||||
|
||||
telebot.logger.setLevel(logging.DEBUG)
|
||||
|
||||
@bot.inline_handler(lambda query: query.query == 'text')
|
||||
def query_text(inline_query):
|
||||
try:
|
||||
r = types.InlineQueryResultArticle('1', 'Result1', types.InputTextMessageContent('hi'))
|
||||
r2 = types.InlineQueryResultArticle('2', 'Result2', types.InputTextMessageContent('hi'))
|
||||
bot.answer_inline_query(inline_query.id, [r, r2])
|
||||
except Exception as e:
|
||||
print(e)
|
||||
|
||||
def main_loop():
|
||||
bot.infinity_polling()
|
||||
while 1:
|
||||
time.sleep(3)
|
||||
|
||||
|
||||
bot.infinity_polling()
|
||||
if __name__ == '__main__':
|
||||
try:
|
||||
main_loop()
|
||||
except KeyboardInterrupt:
|
||||
print('\nExiting by user request.\n')
|
||||
sys.exit(0)
|
||||
|
Loading…
Reference in New Issue
Block a user