34 lines
718 B
Python
34 lines
718 B
Python
|
import logging
|
||
|
import time
|
||
|
import logging
|
||
|
import sched
|
||
|
import threading
|
||
|
|
||
|
from load import config, viber, app
|
||
|
import handlers
|
||
|
|
||
|
|
||
|
logging.basicConfig(
|
||
|
format='%(asctime)s - %(name)s - %(levelname)s - %(message)s',
|
||
|
level=logging.INFO
|
||
|
)
|
||
|
|
||
|
|
||
|
def set_webhook(viber):
|
||
|
viber.unset_webhook()
|
||
|
viber.set_webhook(config.webhook.webhook_url)
|
||
|
|
||
|
|
||
|
if __name__ == '__main__':
|
||
|
scheduler = sched.scheduler(time.time, time.sleep)
|
||
|
scheduler.enter(5, 1, set_webhook, (viber,))
|
||
|
t = threading.Thread(target=scheduler.run)
|
||
|
t.start()
|
||
|
|
||
|
context = (config.cert["cert"], config.cert["key"])
|
||
|
app.run(host=config.webhook.host,
|
||
|
port=int(config.webhook.port),
|
||
|
debug=True,
|
||
|
ssl_context=context
|
||
|
)
|