from telegram import *
from telegram.ext import *
import mysql.connector

TOKEN="7974010617:AAG_5vOl8zhMCKUmiujblR7pjBL8fs_3qlg"

db=mysql.connector.connect(
    host="localhost",
    user="root",
    password="Webdmu@2017",
    database="geez_bingo"
)
cursor=db.cursor(dictionary=True)

async def start(update,context):
    keyboard=[[KeyboardButton("Share Contact",request_contact=True)]]
    await update.message.reply_text("Share contact",
        reply_markup=ReplyKeyboardMarkup(keyboard,resize_keyboard=True))

async def contact(update,context):
    c=update.message.contact
    cursor.execute("INSERT IGNORE INTO users(telegram_id,full_name,phone) VALUES(%s,%s,%s)",
                   (update.message.from_user.id,c.first_name,c.phone_number))
    db.commit()
    await update.message.reply_text("Menu:\n?? Play\n?? Deposit")

async def play(update,context):
    url=f"http://10.129.13.65/geez_bingo/select_card.php?tg_id={update.message.from_user.id}"
    await update.message.reply_text(url)

app=Application.builder().token(TOKEN).build()
app.add_handler(CommandHandler("start",start))
app.add_handler(MessageHandler(filters.CONTACT,contact))
app.add_handler(MessageHandler(filters.TEXT & filters.Regex("Play"),play))

app.run_polling()
