Added walkthrough guide
This commit is contained in:
29
jokes-bot-v3.0/app.py
Normal file
29
jokes-bot-v3.0/app.py
Normal file
@@ -0,0 +1,29 @@
|
||||
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()
|
||||
Reference in New Issue
Block a user