-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpolybot.py
More file actions
40 lines (34 loc) · 1.63 KB
/
polybot.py
File metadata and controls
40 lines (34 loc) · 1.63 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
from telegram import Update, InlineKeyboardButton, InlineKeyboardMarkup
from telegram.ext import ApplicationBuilder, CommandHandler, CallbackQueryHandler, ContextTypes
import logging
logging.basicConfig(level=logging.INFO)
def mock_get_markets():
return [
{"id": "1", "title": "Will ETH > $3K by Sept?", "price": 0.63},
{"id": "2", "title": "Will Trump win in 2024?", "price": 0.45}
]
async def start(update: Update, context: ContextTypes.DEFAULT_TYPE):
keyboard = [
[InlineKeyboardButton(m['title'], callback_data=m['id'])] for m in mock_get_markets()
]
await update.message.reply_text('📈 Choose a market to trade:', reply_markup=InlineKeyboardMarkup(keyboard))
async def handle_market_choice(update: Update, context: ContextTypes.DEFAULT_TYPE):
query = update.callback_query
await query.answer()
market_id = query.data
market = next((m for m in mock_get_markets() if m["id"] == market_id), None)
if market:
await query.edit_message_text(
text=f"🧠 *{market['title']}*\nCurrent Price: {market['price']} USDC\n\nChoose an action:",
reply_markup=InlineKeyboardMarkup([
[InlineKeyboardButton("✅ Buy YES", url="https://checkout.base.org/yes-mock")],
[InlineKeyboardButton("❌ Buy NO", url="https://checkout.base.org/no-mock")]
])
)
def main():
app = ApplicationBuilder().token("8378292690:AAHy3UJJRZ2EdZMqI7omy-t0OkxL5eh2x2E").build()
app.add_handler(CommandHandler("start", start))
app.add_handler(CallbackQueryHandler(handle_market_choice))
app.run_polling()
if __name__ == "__main__":
main()