This repository has been archived on 2024-08-21. You can view files and clone it, but cannot push or open issues or pull requests.
TelegramPoster/main.py

40 lines
796 B
Python
Raw Normal View History

2023-06-21 17:39:33 +03:00
import contextlib
import logging
from os import getpid
from convopyro import Conversation
2023-06-21 23:03:52 +03:00
from classes.pyroclient import PyroClient
from modules.scheduler import scheduler
2023-06-21 17:39:33 +03:00
logging.basicConfig(
level=logging.INFO,
format="%(name)s.%(funcName)s | %(levelname)s | %(message)s",
datefmt="[%X]",
)
logger = logging.getLogger(__name__)
with contextlib.suppress(ImportError):
import uvloop
uvloop.install()
def main():
2023-06-26 14:34:58 +03:00
client = PyroClient(scheduler=scheduler)
2023-06-21 17:39:33 +03:00
Conversation(client)
try:
client.run()
except KeyboardInterrupt:
logger.warning("Forcefully shutting down with PID %s...", getpid())
finally:
2023-06-26 14:34:58 +03:00
if client.scheduler is not None:
client.scheduler.shutdown()
2023-06-21 17:39:33 +03:00
exit()
if __name__ == "__main__":
main()