IN this video you learn about how to create a telegram bot using termux
bot script
#tutorial #telegram #new
#python #trending #youtubeshorts
import telebot
import requests
Replace with your bot token
bot = telebot.TeleBot(" YOUR _TOKEN_HERE _PLZ")
Fetch a random quote from quotable.io
def get_random_quote():
response = requests.get("https://api.quotable.io/random")
if response.status_code == 200:
data = response.json()
return f'"{data["content"]}" - {data["author"]}'
else:
return "Error fetching quote"
@bot.message_handler(commands=['start'])
def start(message):
bot.send_message(message.chat.id, "Hello! I'm a Random Quote Generator Bot. Created by @beingpankajkr Use /quote to get a random quote.")
@bot.message_handler(commands=['quote'])
def send_quote(message):
quote = get_random_quote()
bot.send_message(message.chat.id, quote)
bot.polling()