def main(): """ Main method to get started opens connection and starts endless while loop for polling IRC Channel """ args = parse() # set our settings for this run settings["app_dir"] = os.getcwd() settings["paperman"] = settings[platform.system()] settings["game"] = args.game if args.game else helpers.config_get("game") settings["ironman"] = args.ironman if args.ironman else helpers.config_get( "ironman") settings[ "language"] = args.language if args.language else helpers.config_get( "language") # language option commands = { 'truces': '!truces', 'ideas': '!ideas', 'ae': '!ae', 'mods': '!mods' } if settings["language"] == 'german': commands['truces'] = '!waffenstillstand' commands['ideas'] = '!ideen' # do some logging logging.basicConfig(level=logging.INFO) logger = logging.getLogger(__name__) logging.info(commands) # open connection connection = IrcSocket(args) # this'll run as long as you don't kill it while 1: text = connection.sock.recv(2040).decode() logger.info(text) # answer pings to stay connected if 'PING' in text: logger.info('Answer ping') connection.send_ping('PONG :tmi.twitch.tv\r\n') # ignore messages that aren't commands # only catches commmands if at the beginning of the message elif ':!' not in text: pass else: try: user = text[text.index('!') + 1:text.index('@')] except ValueError: continue #some default twitch messages don't fit the bill, but don't give us a user anyway text = text[text.rfind(':') + 1:].strip() # get ideas if text.startswith(commands.get('ideas')): connection.send_msg(user.title() + ': ' + getinfo.get_ideas()) #get mods from settings elif text.startswith(commands.get('mods')): connection.send_msg(user.title() + ': ' + getinfo.get_mods()) #get ae elif text.startswith(commands.get('ae')): connection.send_msg(user.title() + ': ' + getinfo.get_ae()) #get truces elif text.startswith(commands.get('truces')): connection.send_msg(user.title() + ': ' + getinfo.get_truces())