Files
myrepoes/Thesis_AI6_Building a Telegram Joke Bot_ A Student Project.html
2025-12-16 07:23:26 +00:00

257 lines
9.1 KiB
HTML

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Building a Telegram Joke Bot: A Student Project</title>
<style>
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
font-family: 'Arial', sans-serif;
line-height: 1.6;
color: #333;
max-width: 800px;
margin: 0 auto;
padding: 20px;
background-color: #f5f5f5;
}
.document {
background-color: white;
padding: 40px;
box-shadow: 0 0 20px rgba(0,0,0,0.1);
border-radius: 8px;
}
h1 {
color: #2c3e50;
text-align: center;
margin-bottom: 30px;
padding-bottom: 15px;
border-bottom: 3px solid #3498db;
}
.project-team {
text-align: center;
margin-bottom: 30px;
padding: 15px;
background-color: #f0f7ff;
border-radius: 5px;
}
.supervisor {
font-weight: bold;
color: #2c3e50;
margin-bottom: 10px;
}
.developers {
color: #555;
}
h2 {
color: #3498db;
margin-top: 25px;
margin-bottom: 15px;
padding-left: 10px;
border-left: 4px solid #3498db;
}
p {
margin-bottom: 15px;
text-align: justify;
}
ul, ol {
margin-bottom: 20px;
padding-left: 30px;
}
li {
margin-bottom: 8px;
}
.code-block {
background-color: #2c3e50;
color: #ecf0f1;
padding: 20px;
margin: 20px 0;
border-radius: 5px;
font-family: 'Courier New', monospace;
white-space: pre-wrap;
overflow-wrap: break-word;
font-size: 12px;
line-height: 1.3;
}
.code-note {
background-color: #ffebee;
padding: 10px;
border-radius: 4px;
margin: 10px 0;
font-size: 0.9rem;
border-left: 3px solid #f44336;
}
.highlight {
background-color: #fffacd;
padding: 2px 4px;
border-radius: 3px;
}
.addendum {
background-color: #f9f9f9;
padding: 20px;
margin-top: 30px;
border-left: 4px solid #e74c3c;
page-break-inside: avoid;
}
@media print {
body {
background-color: white;
padding: 0;
}
.document {
box-shadow: none;
padding: 15mm;
}
h1 {
color: black;
}
h2 {
color: #2c3e50;
page-break-after: avoid;
}
.code-block {
background-color: #f8f9fa;
color: black;
border: 1px solid #ddd;
font-size: 11px;
}
.project-team {
background-color: #f8f9fa;
}
.addendum {
page-break-inside: avoid;
}
}
</style>
</head>
<body>
<div class="document">
<h1>Building a Telegram Joke Bot: A Student Project</h1>
<div class="project-team">
<div class="supervisor">Supervisor: Bob Santos</div>
<div class="developers">
Developers: Дашунин Дмитрий, Ерохин Даниил, Овганова Инна, Полковников Артём
</div>
</div>
<h2>Introduction</h2>
<p>A group of students created a Telegram joke bot as a school project. A Telegram bot is a small computer program that can send and receive messages automatically. This particular bot tells jokes to people who message it. The students wanted to make something fun that could bring smiles to people's faces while learning about computer programming.</p>
<h2>Aim</h2>
<p>The goal of this project was to create a simple, working bot that could:</p>
<ul>
<li>Respond to basic commands from users</li>
<li>Tell different jokes at random</li>
<li>Stay online and working all the time</li>
<li>Show how even beginners can create useful programs</li>
</ul>
<h2>Method</h2>
<p>The students used these steps to build their bot:</p>
<ol>
<li><strong>Choose Python</strong>: They picked Python because it's a beginner-friendly programming language.</li>
<li><strong>Use Telegram's Tools</strong>: They connected to Telegram's Bot API, which lets programs send and receive messages.</li>
<li><strong>Write the Code</strong>: They wrote about 30 lines of code that make the bot work.</li>
<li><strong>Add Jokes</strong>: They created a list of three funny jokes for the bot to tell.</li>
<li><strong>Test the Bot</strong>: They tested the bot to make sure it worked correctly.</li>
</ol>
<h2>Results</h2>
<p>The students successfully created a working Telegram bot with these features:</p>
<ul>
<li><strong>/start command</strong>: When users type <span class="highlight">/start</span>, the bot greets them and explains how to get jokes.</li>
<li><strong>/joke command</strong>: When users type <span class="highlight">/joke</span>, the bot randomly picks and tells one of its jokes.</li>
<li><strong>Three different jokes</strong>: The bot can tell jokes about robots, lettuce, and eggs.</li>
<li><strong>Always available</strong>: Once started, the bot runs continuously until stopped.</li>
</ul>
<h2>Conclusion</h2>
<p>The students learned that creating technology doesn't have to be complicated. With just basic programming skills, they built a bot that can make people happy. This project showed them that coding is not just about math and logic—it's also a creative tool. They proved that even simple programs can have real value and bring joy to people.</p>
<h2>Future Possibilities</h2>
<p>This bot could be improved in many ways:</p>
<ul>
<li>Let users submit their own jokes</li>
<li>Allow users to vote for their favorite jokes</li>
<li>Send jokes at scheduled times each day</li>
<li>Connect to online joke databases for more variety</li>
<li>Add voice messages that tell jokes out loud</li>
<li>Tell different types of jokes based on user preferences</li>
</ul>
<div class="addendum">
<h2>Addendum: Complete Bot Code</h2>
<p>Here is the complete Python code for the Telegram joke bot:</p>
<div class="code-note">
<strong>Note:</strong> For security reasons, the actual bot token has been removed. When using this code, you should replace "YOUR_BOT_TOKEN_HERE" with your actual bot token from @BotFather.
</div>
<div class="code-block">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():
# 🔑 REPLACE THIS with your bot token from @BotFather
BOT_TOKEN = "YOUR_BOT_TOKEN_HERE"
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()</div>
<p>The code is organized in a simple way:</p>
<ol>
<li>It imports necessary tools (like the Telegram library and random number generator)</li>
<li>It creates a list of jokes</li>
<li>It makes two functions: one for the /start command and one for the /joke command</li>
<li>It connects to Telegram using a special bot token</li>
<li>It starts the bot and keeps it running</li>
</ol>
</div>
</div>
</body>
</html>