feat: trace TG client's following address
This commit is contained in:
parent
49dcf1653e
commit
f236aa0aed
@ -2,15 +2,23 @@ from urllib import response
|
||||
from cairo import Filter
|
||||
from telegram import Update
|
||||
import torch
|
||||
from telegram.ext import Application, MessageHandler, CallbackContext, CommandHandler, filters
|
||||
from telegram.ext import MessageHandler, CallbackContext, CommandHandler, filters, Application
|
||||
import json
|
||||
import os
|
||||
|
||||
TOKEN = ""
|
||||
|
||||
class BankBot():
|
||||
def __init__(self):
|
||||
self.application = Application.builder().token(TOKEN).build()
|
||||
self.application.add_handler(MessageHandler(filters.ALL, self.response))
|
||||
self.application.add_handler(CommandHandler('shop', self.addShop))
|
||||
self.application.add_handler(MessageHandler(filters.ALL, self.response))
|
||||
|
||||
if os.path.isfile('./client.json'):
|
||||
with open("client.json") as fp:
|
||||
self.clients = json.load(fp)
|
||||
else:
|
||||
self.clients = {}
|
||||
|
||||
def start_polling(self):
|
||||
print("start...")
|
||||
@ -21,7 +29,7 @@ class BankBot():
|
||||
|
||||
await context.bot.send_message(
|
||||
chat_id=update.effective_chat.id,
|
||||
text=q
|
||||
text="我看不懂這個 {} 指令".format(q)
|
||||
)
|
||||
|
||||
async def addShop(self, update, context):
|
||||
@ -33,12 +41,8 @@ class BankBot():
|
||||
)
|
||||
else:
|
||||
address = args[0]
|
||||
this.client[address] = update.effective_chat.id
|
||||
await context.bot.send_message(
|
||||
chat_id=update.effective_chat.id,
|
||||
text=address
|
||||
text="已經設定 {} 的店家收款通知!"
|
||||
)
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
bot = BankBot()
|
||||
bot.start_polling()
|
||||
@ -2,6 +2,7 @@ from flask import Flask, request, jsonify
|
||||
import sqlite3
|
||||
import os
|
||||
from flask_cors import CORS
|
||||
from bot import BankBot
|
||||
|
||||
app = Flask(__name__)
|
||||
CORS(app)
|
||||
@ -165,9 +166,17 @@ def add_products(address):
|
||||
(shop_id, product['name'], product['code'], product['price']))
|
||||
db.commit()
|
||||
db.close()
|
||||
|
||||
return jsonify({'status': 'OK'})
|
||||
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
initDB()
|
||||
|
||||
app.run(host="0.0.0.0")
|
||||
|
||||
print("start the bot...")
|
||||
bot = BankBot()
|
||||
bot.start_polling()
|
||||
bot.application.idle()
|
||||
Loading…
Reference in New Issue
Block a user