pyircbot/bin/pyircbot

37 lines
1.0 KiB
Python
Executable File

#!/usr/bin/env python3
import sys
import logging
from argparse import ArgumentParser
from pyircbot import PyIRCBot
if __name__ == "__main__":
" logging level and facility "
logging.basicConfig(level=logging.INFO,
format="%(asctime)-15s %(levelname)-8s %(filename)s:%(lineno)d %(message)s")
log = logging.getLogger('main')
" parse command line args "
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:
log.critical("No bot config file specified (-c). Exiting.")
sys.exit(0)
botconfig = PyIRCBot.load(args.config)
log.debug(botconfig)
bot = PyIRCBot(botconfig)
try:
bot.loop()
except KeyboardInterrupt:
bot.kill(message="Ctrl-C pressed!")