Clean up downloads user requests bot shut-down
* Basically for Ctrl + C Signed-off-by: lzzy12 <jhashivam2020@gmail.com>
This commit is contained in:
parent
ab6c01146e
commit
f0efb4357d
|
|
@ -3,7 +3,6 @@ import configparser
|
||||||
import aria2p
|
import aria2p
|
||||||
from telegram.ext import Updater
|
from telegram.ext import Updater
|
||||||
|
|
||||||
|
|
||||||
logging.basicConfig(format='%(asctime)s - %(name)s - %(levelname)s - %(message)s',
|
logging.basicConfig(format='%(asctime)s - %(name)s - %(levelname)s - %(message)s',
|
||||||
level=logging.INFO)
|
level=logging.INFO)
|
||||||
|
|
||||||
|
|
@ -31,8 +30,7 @@ aria2 = aria2p.API(
|
||||||
secret="",
|
secret="",
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
aria2.autopurge()
|
|
||||||
aria2.remove_all(True)
|
|
||||||
DOWNLOAD_DIR = None
|
DOWNLOAD_DIR = None
|
||||||
BOT_TOKEN = None
|
BOT_TOKEN = None
|
||||||
try:
|
try:
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,8 @@
|
||||||
from telegram.ext import CommandHandler, run_async
|
from telegram.ext import CommandHandler, run_async
|
||||||
from bot import dispatcher, LOGGER, updater
|
from bot import dispatcher, LOGGER, updater, aria2
|
||||||
import bot.mirror
|
import bot.mirror
|
||||||
|
from bot.helper import fs_utils
|
||||||
|
import signal
|
||||||
|
|
||||||
|
|
||||||
@run_async
|
@run_async
|
||||||
|
|
@ -13,10 +15,12 @@ LOGGER.info('__main__.py')
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
|
|
||||||
start_handler = CommandHandler('start', start)
|
start_handler = CommandHandler('start', start)
|
||||||
dispatcher.add_handler(start_handler)
|
dispatcher.add_handler(start_handler)
|
||||||
LOGGER.info("Bot Started!")
|
LOGGER.info("Bot Started!")
|
||||||
updater.start_polling()
|
updater.start_polling()
|
||||||
|
signal.signal(signal.SIGINT, fs_utils.exit_clean_up)
|
||||||
|
|
||||||
|
|
||||||
main()
|
main()
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue