pyircbot/bin/pyircbot

37 lines
1.0 KiB
Plaintext
Raw Normal View History

2013-12-28 09:58:20 -08:00
#!/usr/bin/env python3
import sys
import logging
2016-11-06 15:00:15 -08:00
from argparse import ArgumentParser
2015-06-18 19:29:46 -07:00
from pyircbot import PyIRCBot
2013-12-28 09:58:20 -08:00
if __name__ == "__main__":
2015-11-01 18:03:11 -08:00
" logging level and facility "
2017-01-01 14:59:01 -08:00
logging.basicConfig(level=logging.INFO,
format="%(asctime)-15s %(levelname)-8s %(filename)s:%(lineno)d %(message)s")
2015-11-01 18:03:11 -08:00
log = logging.getLogger('main')
2016-11-06 15:00:15 -08:00
2015-11-01 18:03:11 -08:00
" parse command line args "
2016-11-06 15:00:15 -08:00
parser = ArgumentParser(description="Run pyircbot")
parser.add_argument("-c", "--config", help="Path to config file", required=True)
parser.add_argument("--debug", action="store_true", help="Dump raw irc network")
args = parser.parse_args()
if args.debug:
logging.getLogger().setLevel(logging.DEBUG)
log.debug(args)
if not args.config:
2015-11-01 18:03:11 -08:00
log.critical("No bot config file specified (-c). Exiting.")
sys.exit(0)
2016-11-06 15:00:15 -08:00
botconfig = PyIRCBot.load(args.config)
2015-11-01 18:03:11 -08:00
log.debug(botconfig)
2016-11-06 15:00:15 -08:00
2015-11-01 18:03:11 -08:00
bot = PyIRCBot(botconfig)
try:
bot.loop()
except KeyboardInterrupt:
2015-11-27 02:16:04 -08:00
bot.kill(message="Ctrl-C pressed!")