webhook code update
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
from sanic import Sanic
|
||||
from sanic.response import text
|
||||
|
||||
from tgbot.config import WEBHOOK, FEEDBACK_CHAT_ID
|
||||
from tgbot.config import FEEDBACK_CHAT_ID
|
||||
|
||||
from tgbot.handlers.handle_feedback import handle_feedback, handle_answer
|
||||
from tgbot.handlers.handle_members_change import handle_join, handle_left
|
||||
@@ -20,17 +20,13 @@ app = Sanic(name="welcomecenter")
|
||||
app.config.REGISTERED = False
|
||||
|
||||
|
||||
@app.route('/', methods=["GET"])
|
||||
@app.get('/')
|
||||
async def register(req):
|
||||
res = 'skipped'
|
||||
if not app.config.REGISTERED:
|
||||
r = register_webhook(WEBHOOK)
|
||||
print(f'\n\t\t\tWEBHOOK REGISTERED:\n{r}')
|
||||
print(register_webhook())
|
||||
app.config.REGISTERED = True
|
||||
print(r)
|
||||
res = 'ok'
|
||||
handle_startup()
|
||||
return text(res)
|
||||
return text('ok')
|
||||
|
||||
|
||||
@app.post('/')
|
||||
@@ -43,6 +39,8 @@ async def handle(req):
|
||||
# видимые сообщения
|
||||
msg = update.get('message', update.get('edited_message'))
|
||||
if msg:
|
||||
if 'edited_message' in update:
|
||||
msg['edit'] = True
|
||||
if 'text' in msg:
|
||||
if msg['chat']['id'] == msg['from']['id']:
|
||||
print('private chat message')
|
||||
|
Reference in New Issue
Block a user