Files
ai6-m3/jokes-bot-v3.0/app.py
2026-01-16 09:56:17 +03:00

29 lines
982 B
Python

from telegram import Update
from telegram.ext import Application, CommandHandler, ContextTypes
import random
JOKE_LIST = [
"Why did the robot go to school? To recharge his brain! 🔋",
"Knock knock!\\nWho's there?\\nLettuce!\\nLettuce who?\\nLettuce in!",
"Why don't eggs tell jokes? They'd crack each other up! 🥚"
]
async def start(update: Update, context: ContextTypes.DEFAULT_TYPE):
await update.message.reply_text("Hi! Type /joke for a funny joke! 😄")
async def send_joke(update: Update, context: ContextTypes.DEFAULT_TYPE):
joke = random.choice(JOKE_LIST)
await update.message.reply_text(joke)
def main():
# Using the provided bot token
BOT_TOKEN = ""
app = Application.builder().token(BOT_TOKEN).build()
app.add_handler(CommandHandler("start", start))
app.add_handler(CommandHandler("joke", send_joke))
print("Bot is running... Press Ctrl+C to stop.")
app.run_polling()
if __name__ == "__main__":
main()