run in project path
This commit is contained in:
5
bot.py
5
bot.py
@ -2,6 +2,7 @@
|
||||
|
||||
# modules
|
||||
import os
|
||||
import sys
|
||||
import time
|
||||
import json
|
||||
from pprint import pprint
|
||||
@ -153,11 +154,11 @@ def backup_db():
|
||||
'status': user._status,
|
||||
'question': user._question
|
||||
}
|
||||
with open('users.json', 'w') as f:
|
||||
with open(sys.path[0] + '/users.json', 'w') as f:
|
||||
json.dump(users_backup, f, indent=' ')
|
||||
|
||||
def restore_db():
|
||||
with open('users.json', 'r') as f:
|
||||
with open(sys.path[0] + '/users.json', 'r') as f:
|
||||
users_restore = json.load(f)
|
||||
for key in users_restore.keys():
|
||||
user = users_restore[key]
|
||||
|
@ -2,6 +2,7 @@
|
||||
|
||||
# modules
|
||||
import os
|
||||
import sys
|
||||
from random import choice
|
||||
import telepot
|
||||
from telepot.namedtuple import ReplyKeyboardMarkup, ReplyKeyboardRemove
|
||||
@ -228,7 +229,7 @@ class Kuser:
|
||||
def send_answer(self, text, file_id):
|
||||
self._status = '正常使用'
|
||||
# define filename
|
||||
filename = self._username + self._question
|
||||
filename = sys.path[0] + '/' + self._username + self._question
|
||||
if self._api.list_questions()[self._question][3] == 'Python':
|
||||
filename += '.py'
|
||||
else:
|
||||
|
Reference in New Issue
Block a user