forked from v2boardbot/v2boardbot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
MyCommandHandler.py
90 lines (81 loc) · 2.97 KB
/
MyCommandHandler.py
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
from telegram import Update, InlineKeyboardButton, InlineKeyboardMarkup, KeyboardButton
from telegram.ext import (
Application,
CallbackQueryHandler,
CommandHandler,
ContextTypes,
ConversationHandler,
)
from keyboard import return_keyboard
from v2board import _bind, _checkin, _traffic, _lucky, _unbind, _wallet
from Utils import START_ROUTES, END_ROUTES
# 签到
async def command_checkin(update: Update, context: ContextTypes.DEFAULT_TYPE):
text = _checkin(update.effective_user.id)
keyboard = [
return_keyboard,
]
reply_markup = InlineKeyboardMarkup(keyboard)
await update.message.reply_text(text=text, reply_markup=reply_markup)
return START_ROUTES
# 绑定
async def command_bind(update: Update, context: ContextTypes.DEFAULT_TYPE):
# http://172.16.1.14/api/v1/client/subscribe?token=b9bc3bee61de39f04047dbf8dca12e97
keyboard = [
return_keyboard,
]
reply_markup = InlineKeyboardMarkup(keyboard)
if update.message.chat.type != 'private':
text = '绑定用户仅限私聊使用,请私聊机器人'
await update.message.reply_text(text=text, reply_markup=reply_markup)
return START_ROUTES
else:
try:
token = context.args[0].split('token=')[-1]
except:
text = '参数错误'
await update.message.reply_text(text=text, reply_markup=reply_markup)
return START_ROUTES
text = _bind(token, update.effective_user.id)
await update.message.reply_text(text=text, reply_markup=reply_markup)
return START_ROUTES
# 解绑
async def command_unbind(update: Update, context: ContextTypes.DEFAULT_TYPE):
telegram_id = update.effective_user.id
text = _unbind(telegram_id)
keyboard = [
return_keyboard,
]
reply_markup = InlineKeyboardMarkup(keyboard)
await update.message.reply_text(text=text, reply_markup=reply_markup)
return START_ROUTES
# 抽奖
async def command_lucky(update: Update, context: ContextTypes.DEFAULT_TYPE):
telegram_id = update.effective_user.id
text = _lucky(telegram_id)
keyboard = [
return_keyboard,
]
reply_markup = InlineKeyboardMarkup(keyboard)
await update.message.reply_text(text=text, reply_markup=reply_markup)
return START_ROUTES
# 查看钱包
async def command_wallet(update: Update, context: ContextTypes.DEFAULT_TYPE):
telegram_id = update.effective_user.id
text = _wallet(telegram_id)
keyboard = [
return_keyboard,
]
reply_markup = InlineKeyboardMarkup(keyboard)
await update.message.reply_text(text=text, reply_markup=reply_markup)
return START_ROUTES
# 流量查询
async def command_traffic(update: Update, context: ContextTypes.DEFAULT_TYPE):
telegram_id = update.effective_user.id
text = _traffic(telegram_id)
keyboard = [
return_keyboard,
]
reply_markup = InlineKeyboardMarkup(keyboard)
await update.message.reply_text(text=text, reply_markup=reply_markup)
return START_ROUTES