mirror of
https://github.com/house-of-vanity/conf_bot.git
synced 2025-07-06 22:34:07 +00:00
Add +min feature to alert
This commit is contained in:
@ -109,6 +109,8 @@ class DataBase:
|
|||||||
|
|
||||||
def add_alert(self, user_id, conf_id, alert_time, message):
|
def add_alert(self, user_id, conf_id, alert_time, message):
|
||||||
date = int(dt.datetime.now().strftime("%s"))
|
date = int(dt.datetime.now().strftime("%s"))
|
||||||
|
if len(alert_time) < 4:
|
||||||
|
alert_time = (dt.datetime.now() + dt.timedelta(minutes=int(alert_time[1:]))).strftime("%H%M")
|
||||||
sql = """INSERT OR IGNORE INTO
|
sql = """INSERT OR IGNORE INTO
|
||||||
alert('conf_id', 'user_id', 'created', 'time', 'message')
|
alert('conf_id', 'user_id', 'created', 'time', 'message')
|
||||||
VALUES ('%s','%s','%s','%s','%s')""" % (
|
VALUES ('%s','%s','%s','%s','%s')""" % (
|
||||||
@ -118,7 +120,6 @@ class DataBase:
|
|||||||
alert_time,
|
alert_time,
|
||||||
message
|
message
|
||||||
)
|
)
|
||||||
print('ALERT: ', sql)
|
|
||||||
self.execute(sql)
|
self.execute(sql)
|
||||||
|
|
||||||
def get_top(self, user_id, conf_id, limit=10):
|
def get_top(self, user_id, conf_id, limit=10):
|
||||||
|
12
worker.py
12
worker.py
@ -44,9 +44,16 @@ class MessageWorker:
|
|||||||
def isTime(self, string):
|
def isTime(self, string):
|
||||||
try:
|
try:
|
||||||
time.strptime(string, '%H%M')
|
time.strptime(string, '%H%M')
|
||||||
return True
|
return string
|
||||||
except ValueError:
|
except ValueError:
|
||||||
return False
|
pass
|
||||||
|
try:
|
||||||
|
if (int(string[1:]) > 0) and (string[0] == '+') and (len(string[1:]) < 3):
|
||||||
|
return string
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
return False
|
||||||
|
|
||||||
|
|
||||||
def colorize(self, code):
|
def colorize(self, code):
|
||||||
code_tag = code[code.rfind('#') + 1:]
|
code_tag = code[code.rfind('#') + 1:]
|
||||||
@ -209,7 +216,6 @@ class MessageWorker:
|
|||||||
chat_title = msg['message']['chat']['title']
|
chat_title = msg['message']['chat']['title']
|
||||||
self.db.add_conf(conf_id, chat_title)
|
self.db.add_conf(conf_id, chat_title)
|
||||||
if len(msg['message']['text'][6:]) < 10000:
|
if len(msg['message']['text'][6:]) < 10000:
|
||||||
print(msg['message']['text'][6:])
|
|
||||||
try:
|
try:
|
||||||
self.colorize(msg['message']['text'][6:])
|
self.colorize(msg['message']['text'][6:])
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
Reference in New Issue
Block a user