import requests
base_url = 'https://api.telegram.org/bot123456:ABC-DEF1234ghIkl-zyx57W2v1u123ew11/'
while True:
api_response = requests.get(base_url + 'getMe').json()
for update in api_response:
chat_id = update['chat_id']
message = update['message']['text']
reply_message = {
"chat_id": chat_id,
"text": message,
}
requests.post(base_url + 'sendMessage', json=reply_message)
from telegram.ext import Updater, CommandHandler, MessageHandler, Filters
def echo(update, context):
"""Echo the user message."""
update.message.reply_text(update.message.text)
updater = Updater("TOKEN", use_context=True)
dp.add_handler(MessageHandler(Filters.text, echo))
updater.start_polling()
import telebot
bot = telebot.TeleBot('<api_token>')
@bot.message_handler(func=lambda message: True)
def echo_message(message):
bot.reply_to(message, message.text)
bot.polling()