Compare commits
No commits in common. "f236aa0aedd1fb52aa17f960240a8e970b970612" and "8cd8840e7b64c3545aee58ed3140ff302bdd89fa" have entirely different histories.
f236aa0aed
...
8cd8840e7b
@ -2,7 +2,6 @@ from flask import Flask, request, jsonify
|
|||||||
import sqlite3
|
import sqlite3
|
||||||
import os
|
import os
|
||||||
from flask_cors import CORS
|
from flask_cors import CORS
|
||||||
from bot import BankBot
|
|
||||||
|
|
||||||
app = Flask(__name__)
|
app = Flask(__name__)
|
||||||
CORS(app)
|
CORS(app)
|
||||||
@ -166,17 +165,9 @@ def add_products(address):
|
|||||||
(shop_id, product['name'], product['code'], product['price']))
|
(shop_id, product['name'], product['code'], product['price']))
|
||||||
db.commit()
|
db.commit()
|
||||||
db.close()
|
db.close()
|
||||||
|
|
||||||
return jsonify({'status': 'OK'})
|
return jsonify({'status': 'OK'})
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
initDB()
|
initDB()
|
||||||
|
|
||||||
app.run(host="0.0.0.0")
|
app.run(host="0.0.0.0")
|
||||||
|
|
||||||
print("start the bot...")
|
|
||||||
bot = BankBot()
|
|
||||||
bot.start_polling()
|
|
||||||
bot.application.idle()
|
|
||||||
@ -2,23 +2,15 @@ from urllib import response
|
|||||||
from cairo import Filter
|
from cairo import Filter
|
||||||
from telegram import Update
|
from telegram import Update
|
||||||
import torch
|
import torch
|
||||||
from telegram.ext import MessageHandler, CallbackContext, CommandHandler, filters, Application
|
from telegram.ext import Application, MessageHandler, CallbackContext, CommandHandler, filters
|
||||||
import json
|
|
||||||
import os
|
|
||||||
|
|
||||||
TOKEN = ""
|
TOKEN = ""
|
||||||
|
|
||||||
class BankBot():
|
class BankBot():
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.application = Application.builder().token(TOKEN).build()
|
self.application = Application.builder().token(TOKEN).build()
|
||||||
self.application.add_handler(CommandHandler('shop', self.addShop))
|
|
||||||
self.application.add_handler(MessageHandler(filters.ALL, self.response))
|
self.application.add_handler(MessageHandler(filters.ALL, self.response))
|
||||||
|
self.application.add_handler(CommandHandler('shop', self.addShop))
|
||||||
if os.path.isfile('./client.json'):
|
|
||||||
with open("client.json") as fp:
|
|
||||||
self.clients = json.load(fp)
|
|
||||||
else:
|
|
||||||
self.clients = {}
|
|
||||||
|
|
||||||
def start_polling(self):
|
def start_polling(self):
|
||||||
print("start...")
|
print("start...")
|
||||||
@ -29,7 +21,7 @@ class BankBot():
|
|||||||
|
|
||||||
await context.bot.send_message(
|
await context.bot.send_message(
|
||||||
chat_id=update.effective_chat.id,
|
chat_id=update.effective_chat.id,
|
||||||
text="我看不懂這個 {} 指令".format(q)
|
text=q
|
||||||
)
|
)
|
||||||
|
|
||||||
async def addShop(self, update, context):
|
async def addShop(self, update, context):
|
||||||
@ -41,8 +33,12 @@ class BankBot():
|
|||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
address = args[0]
|
address = args[0]
|
||||||
this.client[address] = update.effective_chat.id
|
|
||||||
await context.bot.send_message(
|
await context.bot.send_message(
|
||||||
chat_id=update.effective_chat.id,
|
chat_id=update.effective_chat.id,
|
||||||
text="已經設定 {} 的店家收款通知!"
|
text=address
|
||||||
)
|
)
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
|
||||||
|
bot = BankBot()
|
||||||
|
bot.start_polling()
|
||||||
@ -67,7 +67,6 @@ export default {
|
|||||||
console.log(`Code matched = ${decodedText}`, decodedResult);
|
console.log(`Code matched = ${decodedText}`, decodedResult);
|
||||||
if (decodedText in this.products){
|
if (decodedText in this.products){
|
||||||
var product = this.products[decodedText]
|
var product = this.products[decodedText]
|
||||||
this.scanner.clear()
|
|
||||||
this.productCar.push({
|
this.productCar.push({
|
||||||
'name': product['name'],
|
'name': product['name'],
|
||||||
'id': product['id'],
|
'id': product['id'],
|
||||||
@ -75,10 +74,10 @@ export default {
|
|||||||
'count': 1
|
'count': 1
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
this.scanner.clear()
|
|
||||||
this.msg = "商品列表中沒有這項商品:"+decodedText
|
this.msg = "商品列表中沒有這項商品:"+decodedText
|
||||||
this.warningModalStatus = true
|
this.warningModalStatus = true
|
||||||
}
|
}
|
||||||
|
this.scanner.clear()
|
||||||
},
|
},
|
||||||
scan() {
|
scan() {
|
||||||
this.scanner = new Html5QrcodeScanner(
|
this.scanner = new Html5QrcodeScanner(
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user