Exemplo n.º 1
0
def whois(irc: kirc.Irc, target: str):
    whois = {}
    irc.send('WHOIS %s' % target)
    while True:
        msgs = irc.wait_data()
        for msg in msgs.split('\r\n'):
            kirc.pretty_print(msg)
            command = kirc.Parse(msg).command
            if command == '318' or command == '401':
                break
            elif command == '311':
                words = msg.split()
                whois['nick'] = words[3]
                whois['username'] = words[4][1:]
                whois['ip'] = words[5]
                whois['realname'] = words[7][1:]
            elif command == '319':
                whois['channels'] = msg.split(':')[2][:-2].split()
            elif command == '312':
                whois['server'] = msg.split()[4]
            elif command == '223':
                whois['charset'] = msg.split()[6]
            elif command == '317':
                words = msg.split()
                try:
                    whois['seconds idle'] = float(words[4])
                    whois['signon time'] = float(words[5])
                except IndexError as error:
                    print(error)
        else:
            continue
        break
    return whois
Exemplo n.º 2
0
Arquivo: Coxy.py Projeto: kupp1/Coxy
def main_loop():
    while True:
        try:
            msgs = irc.wait_data()
            if msgs:
                for msg in msgs.split('\r\n'):
                    if msg:
                        irc.maintenance(msg)
                        kirc.pretty_print(msg.strip())
                        c.do(msg)
        except KeyboardInterrupt:
            irc.quit('Im part, but it doesnt mean that i crash')
            sys.exit()
        except kirc.IrcConnectionError:
            irc.reconnect(100, 100000)
            irc.join('#16bits')
            irc.join('#16bit')
            main_loop()
        except Exception as error:
            print(error)
Exemplo n.º 3
0
import kirc
import commands

irc = kirc.Irc('Rusnet', 'irc.run.net', 6660,
               'Coxy_t', 'bot', 'kupp bot', 'utf-8')
irc.connect(100, 900)
irc.join('#16bits')
irc.join('###kupp_tests')
c = commands.CommandsCore(irc, '.')
ready = select.select([sys.stdin], [], [], timeout)[0]
while True:
    try:
        msgs = irc.wait_data()
        if msgs:
            for msg in msgs.split('\r\n'):
                if msg:
                    irc.maintenance(msg)
                    kirc.pretty_print(msg.strip())
                    c.search(msg)
    except KeyboardInterrupt:
        irc.quit('Im part, but it doesnt mean that i crash')
    except kirc.IrcConnectionError:
        irc.reconnect(100, 900)