Updated app.py
This commit is contained in:
@@ -1,28 +1,34 @@
|
||||
# app.py — Teacher-Only Telegram Joke Bot
|
||||
from telegram import Update
|
||||
from telegram.ext import Application, CommandHandler, ContextTypes
|
||||
from telegram.ext import ApplicationBuilder, CommandHandler, ContextTypes
|
||||
import random
|
||||
|
||||
# 🔑 REPLACE WITH REAL TOKEN FROM @BotFather
|
||||
BOT_TOKEN = "7864875699:AAEWf6ff1DYNzPvW6Dbn7D2W5aavg9KPhgY"
|
||||
|
||||
# --- COPY STUDENT JOKES HERE BEFORE CLASS ---
|
||||
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! 🥚"
|
||||
"Knock knock!\\nWho's there?\\nBoo!\\nBoo who?\\nDon't cry! 😂",
|
||||
"Why don't eggs tell jokes? They'd crack each other up! 🥚",
|
||||
"What do you call a penguin in the desert? Lost! 🐧",
|
||||
# Add student jokes here
|
||||
]
|
||||
|
||||
async def start(update: Update, context: ContextTypes.DEFAULT_TYPE):
|
||||
await update.message.reply_text("Hi! Type /joke for a funny joke! 😄")
|
||||
await update.message.reply_text("🤖 Hi! I'm your Joke Bot!\nType /joke for a funny joke in English! 😄")
|
||||
|
||||
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()
|
||||
print("🚀 Starting Joke Bot...")
|
||||
app = ApplicationBuilder().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.")
|
||||
print("✅ Bot is running! Press Ctrl+C to stop.")
|
||||
app.run_polling()
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
Reference in New Issue
Block a user