Below is a copyβandβpaste, beginnerβfriendly bot that will greet users, let them pick their language, and serve up concise educational nuggets about Bitcoin.
1.β―Prerequisites (1β―minute)
python -m venv btcβbotβenv
source btcβbotβenv/bin/activate # Windows: btcβbotβenv\Scripts\activate
pip install –upgrade python-telegram-bot==20.*
- Create a bot with @BotFather β grab the API token.
- Paste that token into the TOKEN = “YOUR_BOT_TOKEN_HERE” line in the code below.
- Run the file: python bitcoin_dual_lang_bot.py (polling modeβno webhooks needed).
2.β―The Code (save as
bitcoin_dual_lang_bot.py
)
#!/usr/bin/env python3
# βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
# Telegram Bitcoin Education Bot β English π¬π§ & Khmer π°π
# βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
import logging
from telegram import (
Update,
InlineKeyboardButton,
InlineKeyboardMarkup,
)
from telegram.ext import (
ApplicationBuilder,
CallbackContext,
CallbackQueryHandler,
CommandHandler,
)
TOKEN = “YOUR_BOT_TOKEN_HERE”
DEFAULT_LANG = “en”
# ———- Multilingual content bank ———-
CONTENT = {
“en”: {
“welcome”: (
“π *Hey there, future Bitcoin pro!* \n”
“Tap a button to switch languages or explore a topic:”
),
“help”: (
“π€ *Bot menu*\n”
“/about β What _is_ Bitcoin?\n”
“/how β How does it work?\n”
“/why β Why might people use it?\n”
“/lang β Switch language”
),
“about”: (
“πͺ *What is Bitcoin?*\n”
“Bitcoin is a borderless, decentralised digital currency. “
“No company or country controls it; the network runs on thousands “
“of independent computers worldwide.”
),
“how”: (
“βοΈ *How does Bitcoin work?*\n”
“Transactions are bundled into βblocksβ and added to a public ledgerβthe “
“blockchainβsecured by cryptography and global miners.”
),
“why”: (
“π *Why use Bitcoin?*\n”
“β’ Permissionβless payments \n”
“β’ Fixed supply (21β―million coins) \n”
“β’ Open to anyone with the internet”
),
“lang_btn”: “Switch to Khmer π°π”,
“lang_confirm”: “Language switched to *English* β ”,
},
“km”: {
“welcome”: (
“π *αα½ααααΈ! α’αααααααααααα½αααααΆαααΆα’αααααααΆα Bitcoin α¬αα ?* \n”
“ααααΎαααΎαααΆααΆ α¬ααΆααα½αα’αααΈαααααΆαααααΆαααααα:”
),
“help”: (
“π€ *αααΊαα»αααΌα*\n”
“/about β Bitcoin ααΊααΆα’αααΈ?\n”
“/how β ααΆααααΎαααΆααααΆαααΌα ααααα ?\n”
“/why β ααΌαα ααα»αααααα»αααααααΎααΆ?\n”
“/lang β ααααΌαααΆααΆ”
),
“about”: (
“πͺ *Bitcoin ααΊααΆα’αααΈ?*\n”
“Bitcoin ααΊααΆαα»αααΈααΈααααααα·αααΆααααα»αα αα»α α¬ααααααααΆαααα»αααΆααααααααααα “
“ααΆαααααΎαααααΆααα»αααααΌααααααα―αααΆαααααΆα αααΎαααΌααΆαααα·αααααα”
),
“how”: (
“βοΈ *Bitcoin ααααΎαααΆααααΆαααΌα ααααα ?*\n”
“ααααα·ααααα·ααΆαααααΌαααΆααααα αααΆ βαααα»αβ α αΎαααααααα αΌααααα»ααααααααααΆααΆααΆαααβ”
“blockchainβαααααΆααα»ααααα·ααΆααααααααααα·α α·αααα’ααα αα·αααΈαααα”
),
“why”: (
“π *α ααα»α’αααΈααααΎααααααααΎ Bitcoin?*\n”
“β’ αααααααΆαααααααααΆαααααα \n”
“β’ ααααααααααααα (α’α‘ααΆαααΆαα) \n”
“β’ α’αααααΆααα’αΆα α αΌααα½αααΆα ααααα·αααΎααΆαα’ααΈαααΊαα·α”
),
“lang_btn”: “ααααΌααα English π¬π§”,
“lang_confirm”: “ααΆαααααΌαααΆααΆαα *Khmer* β ”,
},
}
# ———————————————————-
# ———- Command handlers ———-
async def start(update: Update, context: CallbackContext.DEFAULT_TYPE) -> None:
user_lang = context.user_data.get(“lang”, DEFAULT_LANG)
await update.message.reply_text(
CONTENT[user_lang][“welcome”],
reply_markup=lang_keyboard(user_lang),
parse_mode=”Markdown”,
)
await help_cmd(update, context) # autoβdisplay help
async def help_cmd(update: Update, context: CallbackContext.DEFAULT_TYPE) -> None:
user_lang = context.user_data.get(“lang”, DEFAULT_LANG)
await update.message.reply_text(
CONTENT[user_lang][“help”], parse_mode=”Markdown”
)
async def about(update: Update, context: CallbackContext.DEFAULT_TYPE) -> None:
await send_topic(update, context, “about”)
async def how(update: Update, context: CallbackContext.DEFAULT_TYPE) -> None:
await send_topic(update, context, “how”)
async def why(update: Update, context: CallbackContext.DEFAULT_TYPE) -> None:
await send_topic(update, context, “why”)
async def send_topic(update: Update, context: CallbackContext.DEFAULT_TYPE, topic: str):
user_lang = context.user_data.get(“lang”, DEFAULT_LANG)
await update.message.reply_text(
CONTENT[user_lang][topic], parse_mode=”Markdown”
)
# ———- Language switch ———-
def lang_keyboard(current_lang: str) -> InlineKeyboardMarkup:
other_lang = “km” if current_lang == “en” else “en”
return InlineKeyboardMarkup(
[[InlineKeyboardButton(CONTENT[current_lang][“lang_btn”], callback_data=f”SET_LANG:{other_lang}”)]]
)
async def lang_switcher(update: Update, context: CallbackContext.DEFAULT_TYPE) -> None:
query = update.callback_query
await query.answer()
_, new_lang = query.data.split(“:”)
context.user_data[“lang”] = new_lang
await query.edit_message_text(
CONTENT[new_lang][“lang_confirm”], parse_mode=”Markdown”
)
# Show menu again
await query.message.reply_text(
CONTENT[new_lang][“welcome”],
reply_markup=lang_keyboard(new_lang),
parse_mode=”Markdown”,
)
# ———- Main autoboot ———-
def main() -> None:
logging.basicConfig(
format=”%(asctime)s | %(name)s | %(levelname)s | %(message)s”,
level=logging.INFO,
)
app = (
ApplicationBuilder()
.token(TOKEN)
.build()
)
# Core commands
app.add_handler(CommandHandler(“start”, start))
app.add_handler(CommandHandler(“help”, help_cmd))
app.add_handler(CommandHandler(“about”, about))
app.add_handler(CommandHandler(“how”, how))
app.add_handler(CommandHandler(“why”, why))
app.add_handler(CallbackQueryHandler(lang_switcher, pattern=r”^SET_LANG:”))
logging.info(“π Bot is up and running. Press Ctrl+C to stop.”)
app.run_polling()
if __name__ == “__main__”:
main()
3.β―How it works (happyβdance version πΊ)
| Stage | What happens | π Why itβs cool |
| /start | Greets user in default English, plus an inline button to swap languages. | Instant bilingual friendlinessβno commands needed! |
| Inline button | CallbackQueryHandler flips user_data[“lang”] and edits the message. | Snappy UX, keeps chat tidy. |
| /about, /how, /why | Deliver succinct lessons drawn from the CONTENT dict in the callerβs language. | Keeps logic superβsimpleβeasy to expand topics later. |
| /lang (optional) | /lang shows the same buttons if people prefer commands over taps. | Accessibility FTW. |
4.β―Next steps when youβre ready to levelβup
- Add live price dataβhit CoinGeckoβs free API and inject numbers into the messages.
- Drop in pictures/GIFs for visual learners (Telegram supports MarkdownβV2 and HTML).
- Gamify with quizzes or streak counts to keep learners pumped.
- Deploy 24/7βswitch from polling to a webhook + a cheap VPS or serverless function.
β¨ Boom! You now have a cheerful, hypeβdriven, bilingual Bitcoin educator ready to roll.
Fire it up, invite friends, and watch the orangeβcoin knowledge spread across borders! ππ§‘