pyircbot/bin/pyircbot

35 lines
959 B
Plaintext
Raw Normal View History

2013-12-28 09:58:20 -08:00
#!/usr/bin/env python3
import os
import sys
import logging
from optparse import OptionParser
2015-06-18 19:29:46 -07:00
from pyircbot import PyIRCBot
2015-11-27 02:16:04 -08:00
from time import sleep
2013-12-28 09:58:20 -08:00
if __name__ == "__main__":
2015-11-01 18:03:11 -08:00
" logging level and facility "
2015-11-27 02:16:04 -08:00
logging.basicConfig(level=logging.DEBUG, format="%(asctime)-15s %(levelname)-8s %(filename)s:%(lineno)d %(message)s")
2015-11-01 18:03:11 -08:00
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:
2015-11-27 02:16:04 -08:00
bot.kill(message="Ctrl-C pressed!")