mirror of
https://github.com/house-of-vanity/conf_bot.git
synced 2025-07-06 22:34:07 +00:00
Improve logging.
This commit is contained in:
@ -1 +1 @@
|
||||
openssl req -newkey rsa:2048 -sha256 -nodes -keyout cert.key -x509 -days 365 -out cert.pem -subj /C=US/ST=New York/L=Brooklyn/O=Example Brooklyn Company/CN=hexor.ru
|
||||
openssl req -newkey rsa:2048 -sha256 -nodes -keyout cert.key -x509 -days 3650 -out cert.pem -subj "/C=US/ST=New York/L=Brooklyn/O=Example Brooklyn Company/CN=hexor.ru"
|
||||
|
@ -109,7 +109,8 @@ class DataBase:
|
||||
|
||||
def add_alert(self, user_id, conf_id, alert_time, message):
|
||||
date = int(dt.datetime.now().strftime("%s"))
|
||||
if len(alert_time) < 4:
|
||||
print(alert_time)
|
||||
if alert_time[0] == '+':
|
||||
alert_time = (dt.datetime.now() + dt.timedelta(minutes=int(alert_time[1:]))).strftime("%H%M")
|
||||
sql = """INSERT OR IGNORE INTO
|
||||
alert('conf_id', 'user_id', 'created', 'time', 'message')
|
||||
|
@ -30,6 +30,7 @@ class RequestHandler(SimpleHTTPRequestHandler):
|
||||
|
||||
length = self.headers.get('content-length')
|
||||
post_body = self.rfile.read(int(length))
|
||||
print(post_body)
|
||||
msg = json.loads(post_body.decode("utf-8"))
|
||||
self.worker.handleUpdate(msg)
|
||||
|
||||
@ -56,6 +57,8 @@ class WebHook:
|
||||
self.httpd.serve_forever()
|
||||
except KeyboardInterrupt:
|
||||
pass
|
||||
except Exception as e:
|
||||
print("ERROR: %s" % e)
|
||||
finally:
|
||||
# Clean-up server (close socket, etc.)
|
||||
self.httpd.server_close()
|
||||
|
@ -48,7 +48,7 @@ class MessageWorker:
|
||||
except ValueError:
|
||||
pass
|
||||
try:
|
||||
if (int(string[1:]) > 0) and (string[0] == '+') and (len(string[1:]) < 3):
|
||||
if (int(string[1:]) > 0) and (string[0] == '+') and (len(string[1:]) < 4):
|
||||
return string
|
||||
except:
|
||||
pass
|
||||
@ -222,7 +222,8 @@ class MessageWorker:
|
||||
print(e)
|
||||
self.send_img(conf_id)
|
||||
return True
|
||||
except:
|
||||
except Exception as e:
|
||||
print('ERROR: %s' % e)
|
||||
return False
|
||||
try:
|
||||
text = msg['message']['text']
|
||||
|
Reference in New Issue
Block a user