Telegram- Contact -ukussa-server-bot -
# Server-side action: Store, validate, or route the contact UkussaServerDB.save_contact(user_id, phone, f"first_name last_name")
Enable and start:
async def start(update: Update, context: ContextTypes.DEFAULT_TYPE): # Create a button that shares the user's contact contact_button = KeyboardButton(text="Share My Contact", request_contact=True) reply_markup = ReplyKeyboardMarkup([[contact_button]], resize_keyboard=True) await update.message.reply_text( "Welcome to the ukussa server bot. Press the button below to link your contact to our server.", reply_markup=reply_markup ) Telegram- Contact -ukussa-server-bot
await update.message.reply_text( f"✅ Contact received for first_name. The ukussa server has logged your number: phone[:5]*****" ) def main(): app = Application.builder().token(TOKEN).build() app.add_handler(CommandHandler("start", start)) app.add_handler(MessageHandler(filters.CONTACT, handle_contact)) # Server-side action: Store, validate, or route the
import logging from telegram import Update, KeyboardButton, ReplyKeyboardMarkup from telegram.ext import Application, CommandHandler, MessageHandler, filters, ContextTypes TOKEN = "YOUR_BOT_TOKEN_UKUSSA" Simulated server-side database (ukussa local DB) class UkussaServerDB: @staticmethod def save_contact(user_id, phone_number, full_name): # In production, this writes to PostgreSQL or Redis with open("/var/log/ukussa_contacts.log", "a") as f: f.write(f"user_id|phone_number|full_name\n") return True ssh root@your-server-ip apt update && apt upgrade -y
# Run the bot on the server (polling method for simplicity) print("ukussa-server-bot is running...") app.run_polling() if == " main ": main() Step 3: Running as a Persistent Service To ensure ukussa-server-bot never dies, create a systemd service.
ssh root@your-server-ip apt update && apt upgrade -y apt install python3-pip nginx -y mkdir /var/telegram-ukussa-bot cd /var/telegram-ukussa-bot Create bot.py with the following logic—specifically designed to handle the CONTACT shared type.