You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

39 lines
775 B

2 years ago
import json
import os.path
import sys
2 years ago
import traceback
2 years ago
from bot_instance import BotInstance
2 years ago
def load_user_config():
2 years ago
with open("config.json", "r") as config_file:
config = json.load(config_file)
2 years ago
return config
2 years ago
2 years ago
def init_bot(config):
return BotInstance(config)
2 years ago
2 years ago
def execute_bot(config, freq, log_file):
2 years ago
print("execute bot... %s" % freq)
bot = init_bot(config)
2 years ago
bot.block_reports(freq, log_file)
2 years ago
def main():
2 years ago
with open('log.txt', 'a') as log_file:
try:
config = load_user_config()
execute_bot(config, sys.argv[1], log_file)
except Exception as e:
traceback.print_exc(file=log_file)
sys.exit(1)
sys.exit(0)
2 years ago
2 years ago
2 years ago
# Run main function
if __name__ == "__main__":
2 years ago
main()