mirror of
https://github.com/house-of-vanity/conf_bot.git
synced 2025-07-06 14:24:08 +00:00
Fix logging. Update cert gen script.
This commit is contained in:
@ -1,2 +1,2 @@
|
||||
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=des.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=des-rkn.hexor.ru"
|
||||
|
||||
|
@ -30,7 +30,6 @@ 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)
|
||||
|
||||
@ -42,7 +41,7 @@ class WebHook:
|
||||
def __init__(self,
|
||||
certfile,
|
||||
keyfile,
|
||||
address='0.0.0.0',
|
||||
address=settings.parser.get('bot', 'bind_address'),
|
||||
port=8443,
|
||||
RequestHandler=RequestHandler):
|
||||
|
||||
|
14
worker.py
14
worker.py
@ -76,7 +76,11 @@ class MessageWorker:
|
||||
|
||||
def handleUpdate(self, msg):
|
||||
try:
|
||||
input_message = msg['message']['text']
|
||||
try:
|
||||
input_message = msg['message']['text']
|
||||
except KeyError as excp:
|
||||
print(f"KeyError: {excp}")
|
||||
return True
|
||||
if input_message == '/help':
|
||||
conf_id = msg['message']['chat']['id']
|
||||
user_id = msg['message']['from']['id']
|
||||
@ -97,9 +101,9 @@ class MessageWorker:
|
||||
"""
|
||||
self.send(id=conf_id, msg=msg)
|
||||
if ('@here' in input_message) or (' @'+self.me['result']['username'] in input_message):
|
||||
if str(msg['message']['chat']['id']) != "-1001233797421":
|
||||
print("@here isn't available for '%s' (%s)" % (msg['message']['chat']['title'], msg['message']['chat']['id']))
|
||||
return
|
||||
# if str(msg['message']['chat']['id']) != "-1001233797421":
|
||||
# print("@here isn't available for '%s' (%s)" % (msg['message']['chat']['title'], msg['message']['chat']['id']))
|
||||
# return
|
||||
conf_id = msg['message']['chat']['id']
|
||||
user_id = msg['message']['from']['id']
|
||||
if msg['message']['chat']['type'] == 'private':
|
||||
@ -352,7 +356,7 @@ class MessageWorker:
|
||||
data = {'chat_id': id}
|
||||
files = {'photo': open('code.png', 'rb')}
|
||||
r = requests.post(url, files=files, data=data)
|
||||
print(r)
|
||||
#print(r)
|
||||
except Exception as e:
|
||||
print(e)
|
||||
|
||||
|
Reference in New Issue
Block a user