[O] Exit on keyboard interrupt

This commit is contained in:
Hykilpikonna
2020-11-27 10:37:15 -05:00
parent 24a49ea9cd
commit 8ee9439579
+8 -1
View File
@@ -11,6 +11,7 @@ from src.utils import createCommand
if __name__ == '__main__':
# Initialize logger
logging.basicConfig(format='%(asctime)s - %(name)s - %(levelname)s - %(message)s', level=logging.INFO)
logging.getLogger('apscheduler.executors.default').propagate = False
# Create bot
bot = telegram.Bot(token=token)
@@ -34,4 +35,10 @@ if __name__ == '__main__':
# Keep alive
while True:
time.sleep(5)
try:
time.sleep(5)
except KeyboardInterrupt:
print("Exiting...")
updater.stop()
dispatcher.stop()
exit(0)