def main() -> None: logging.basicConfig( format='%(asctime)s - %(name)s - %(levelname)s - %(message)s', level=logging.INFO) args = parse_args() if args.command == CMD_TELEGRAM_BOT: telegram_bot.start_bot() elif args.command == CMD_VK_BOT: vk_bot.start_bot() elif args.command == CMD_PARSE_QUESTIONS: parse_questions(args.questions_folder, args.output_file)
def start(): if len(sys.argv) == 2: mode = sys.argv[1] else: mode = input( "Do you want to input the subreddits or call me on me telegram?. Type 1 for local CLI of 2 for " "telegram") if mode == "1": reddit_input = input( 'please input the subreddits as it follows: a;b;c') subreddits = process_input(reddit_input) print_subreddits_and_threads(subreddits) elif mode == "2": start_bot() else: print("INVALID MODE! Type 1 or 2.")
return True def cpu_active(): cpu_vals = ps.cpu_percent(percpu=True) logging.info(cpu_vals) if any([cpu > tgbot.config.CPU_THRES for cpu in cpu_vals]): return True return False def gpu_active(): proc = Popen("nvidia-smi", shell=True, stdout=PIPE, stderr=DEVNULL) output = proc.communicate()[0] if proc.returncode != 0: return False return str(output).find("No running processes found") == -1 if __name__ == "__main__": tgbot.start_bot() check_status()
def main() -> None: logging.basicConfig(level=logging.INFO) telegram_bot.start_bot()
import logging import os import telegram_bot from autotweet import logger_factory DB_URI = os.getenv('DATABASE_URL') TELEGRAM_TOKEN = os.getenv('TELEGRAM_TOKEN') THRESHOLD = os.getenv('THRESHOLD') logging.basicConfig( format='%(asctime)s {%(module)s:%(levelname)s}: %(message)s', datefmt='%Y-%m-%d %H:%M:%S') logger = logging.getLogger(telegram_bot.__name__) logger.setLevel(logging.DEBUG) logger_factory.set_level(logging.DEBUG) logger.info('Starting telegram bot...') telegram_bot.start_bot(TELEGRAM_TOKEN, DB_URI, float(THRESHOLD), learning=False, answering=True)
import logging from telegram_bot import start_bot logging.basicConfig(level=logging.DEBUG, format='%(asctime)s - %(name)s - \ %(levelname)s - %(message)s') logger = logging.getLogger(__name__) logger.debug('Loading enviroment variables') start_bot()