async def my_event_handler(event): sender = await event.get_sender() # print(sender) if sender.id in channels.keys(): filtered = await forbidden(event) if not filtered: await client.send_message(entity=channels[sender.id], message=event.message) else: logging.info( f'Message from {sender.title} was not sent because of filter violation' )
reply = yield from subscriber.next_published() asyncio.Task(parse_reply(bot, reply)) # do not wait for response except Exception as e: import traceback bot.log.critical(traceback.format_exc()) yield from asyncio.sleep(1) if __name__ == '__main__': # logging configuration logdict = irc3.config.LOGGING.copy() for k,v in logdict['formatters'].items(): v['format'] = '%(asctime)s ' + v['format'] logging.config.dictConfig(logdict) channels_list = list(channels.keys()) channels_list.append(default_channel) channels_list.append(firehose_channel) # instanciate a bot bot = irc3.IrcBot( nick='wikibugs', autojoins=channels_list, host='irc.freenode.net', port=7000, ssl=True, password=irc_password, realname="pywikibugs2", userinfo="Wikibugs v2.0, https://tools.wmflabs.org/wikibugs/", url="https://tools.wmflabs.org/wikibugs/", includes=[ 'irc3.plugins.core', 'irc3.plugins.ctcp', __name__, # this register MyPlugin
except Exception as e: import traceback bot.log.critical(traceback.format_exc()) yield from asyncio.sleep(1) if __name__ == '__main__': # logging configuration logdict = irc3.config.LOGGING.copy() for k,v in logdict['formatters'].items(): v['format'] = '%(asctime)s ' + v['format'] logging.config.dictConfig(logdict) # instanciate a bot bot = irc3.IrcBot( nick='wikibugs', autojoins=list(channels.keys()), host='irc.freenode.net', port=7000, ssl=True, password=irc_password, realname="pywikibugs2", userinfo="Wikibugs v2.0, https://tools.wmflabs.org/wikibugs/", url="https://tools.wmflabs.org/wikibugs/", includes=[ 'irc3.plugins.core', 'irc3.plugins.ctcp', __name__, # this register MyPlugin ], verbose=True, ctcp={'version': 'pywikibugs %s running on irc3 {version}. See {url} for more details.' % __version__, 'userinfo': '{userinfo}', 'ping': 'PONG'} )