Пример #1
0
                return

            if is_channel(msg.target) and \
                    ('http://' in msg.message or 'https://' in msg.message)\
                    and not msg.message.startswith('+'):
                def replace_url(match):
                    the_url, = match.groups('url')
                    return '\x0304\x02{}\x0F'.format(the_url)
                text = utils.url_pattern.sub(replace_url, msg.message)
                prot.sendline('PRIVMSG {} :Matched: {}'
                              .format(msg.target, text))
        if isinstance(msg, CtcpRequest):
            if msg.ctcp_command == 'VERSION':
                prot.sendline('NOTICE {} :\x01VERSION {}\x01'
                              .format(msg.sender, 'Shanghai Doll 0.1dev'))


loop = asyncio.get_event_loop()

prot1 = IRCProtocol('irc.euirc.net', 6667, IRCHandler())
# prot2 = IRCProtocol('irc.freenode.net', 6667, IRCHandler())

asyncio.ensure_future(prot1.run())
# asyncio.ensure_future(prot2.run())

try:
    loop.run_forever()
except KeyboardInterrupt:
    loop.close()
print()