Skip to content

Commit b6159af

Browse files
committed
Added tinydb and saving messages
1 parent c5213fe commit b6159af

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

howdoibot.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@
44
import json
55
from howdoi.howdoi import howdoi
66
from path import Path
7+
from tinydb import TinyDB, Query
78

9+
db = TinyDB('messages.json')
810

911
config_path = Path(__file__).parent / 'config.json'
1012
info = json.load(open(config_path))
@@ -39,7 +41,10 @@
3941
def telegram_webhook():
4042
update = request.get_json()
4143
app.logger.info(update)
42-
if "message" in update:
44+
msg = Query()
45+
if "message" in update and len(db.search(db.message_id == update['message']['message_id'])) == 0:
46+
47+
db.insert(update['message'])
4348
text = update["message"]["text"]
4449
args = {
4550
'query': text.split(' ')

requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,6 @@ pyquery==1.4.0
1414
requests==2.21.0
1515
requests-cache==0.4.13
1616
telepot==12.7
17+
tinydb==3.12.2
1718
urllib3==1.24.1
1819
Werkzeug==0.14.1

0 commit comments

Comments
 (0)