pyircbot/bin/pyircbot

35 lines
959 B
Python
Executable File

#!/usr/bin/env python3
import os
import sys
import logging
from optparse import OptionParser
from pyircbot import PyIRCBot
from time import sleep
if __name__ == "__main__":
" logging level and facility "
logging.basicConfig(level=logging.DEBUG, format="%(asctime)-15s %(levelname)-8s %(filename)s:%(lineno)d %(message)s")
log = logging.getLogger('main')
" parse command line args "
parser = OptionParser()
parser.add_option("-c", "--config", action="store", type="string", dest="config", help="Path to config file")
(options, args) = parser.parse_args()
log.debug(options)
if not options.config:
log.critical("No bot config file specified (-c). Exiting.")
sys.exit(0)
botconfig = PyIRCBot.load(options.config)
log.debug(botconfig)
bot = PyIRCBot(botconfig)
try:
bot.loop()
except KeyboardInterrupt:
bot.kill(message="Ctrl-C pressed!")