示例#1
0
    def send_cmd(self, event):
        """
        Used to drop irc commands.
        """

        ask = Ask()
        send_cmd(self.con, ask.data)
示例#2
0
    def watcher(self, server, nick, user, host, target, msg):
        count, start       = self.data.setdefault(host, [0,  time.time()])
        count              = count + 1
        self.data[host][0] = count

        if time.time() - start > self.n_secs:
            self.data[host][0], self.data[host][1] = 0, time.time()
            if self.n_lines/float(self.n_secs) < count/(time.time() - start):
                send_cmd(server, self.cmd.format(nick=nick, 
                         chan=target, host=host, user=user))
示例#3
0
    def on_connect(self, con):
        area = self.create_area(self.addr)
        area.bind('<Destroy>',
                  lambda event: send_cmd(con, 'QUIT :vy rules!'),
                  add=True)

        Stdin(con)
        Stdout(con)
        Terminator(con)
        Irc(con)
        self.misc = Misc(con)

        xmap(con, CLOSE, lambda con, err: lose(con))
        xmap(con, '*JOIN', self.create_channel)
        xmap(con, Terminator.FOUND,
             lambda con, data: area.append('%s\n' % data))

        xmap(con, 'PMSG', self.e_pmsg)
        xmap(con, '376', lambda con, *args: send_cmd(con, self.irccmd))

        xmap(con, '376', self.auto_join)

        xmap(
            con, 'PING',
            lambda con, prefix, servaddr: send_cmd(con, 'PONG :%s' % servaddr))

        send_cmd(con, 'NICK %s' % self.nick)
        send_cmd(con, 'USER %s' % self.user)
示例#4
0
    def __init__(self, irc, area, chan):
        self.irc = irc
        self.area = area
        self.chan = chan
        self.peers = set()

        events = (
            ('PRIVMSG->%s' % chan, self.e_privmsg),
            ('332->%s' % chan, self.e_332),
            ('PART->%s' % chan, self.e_part),
            ('JOIN->%s' % chan, self.e_join),
            # ('*NICK', self.e_nick),
            ('NICK', self.e_nick),
            ('QUIT', self.e_quit),
            ('353->%s' % chan, self.e_353),
            ('KICK->%s' % chan, self.e_kick),
            ('MODE->%s' % chan, self.e_mode),
            (CLOSE, self.e_close))

        def unset(con, *args):
            for key, value in events:
                zmap(irc.con, key, value)

        for key, value in events:
            xmap(irc.con, key, value)

        once(irc.con, '*PART->%s' % chan, unset)
        xmap(irc.con, '*KICK->%s' % chan, unset)

        area.bind('<Destroy>', lambda event: unset(irc.con), add=True)

        # When area is destroyed, it sends a PART.
        area.bind('<Destroy>',
                  lambda event: send_cmd(irc.con, 'PART %s' % chan),
                  add=True)

        # Hook to send msgs.
        area.hook(
            'vyirc', 'IRC', '<Key-i>', lambda event: Get(
                events={
                    '<Escape>': lambda wid: True,
                    '<Return>': lambda wid: self.irc.drop_msg(area, wid, chan)
                }))

        # It unbinds the above callback.
        # In case the part command as sent by text
        # by the user. After part it should destroy the
        # area.
        once(irc.con, '*PART->%s' % chan,
             lambda con, *args: area.unbind('<Destroy>'))
示例#5
0
文件: ircmode.py 项目: joodicator/vy
    def set_common_irc_handles(self, area, con):
        l1 = lambda con, chan: self.create_channel(area, con, chan)
        l2 = lambda con, prefix, servaddr: send_cmd(con, 'PONG :%s' % servaddr)
        l3 = lambda con, data: area.insee('end', '%s\n' % data)

        xmap(con, '001', on_001)
        xmap(con, 'PRIVMSG', on_privmsg)
        xmap(con, 'JOIN', on_join)
        xmap(con, 'PART', on_part)
        xmap(con, '353', on_353)
        xmap(con, '332', on_332)
        xmap(con, 'NICK', on_nick)

        xmap(con, 'MEJOIN', l1)
        xmap(con, 'PING', l2)
        xmap(con, FOUND, l3)
示例#6
0
文件: ircmode.py 项目: joodicator/vy
 def send_cmd(self, area, con):
     ask = Ask(area)
     send_cmd(con, ask.data)
示例#7
0
文件: ircadm.py 项目: unav1/ameliabot
def irc_cmd(server, nick, user, host, target, msg, data):
    if is_adm(host): send_cmd(server, data)
示例#8
0
 def auto_join(self, con, *args):
     for ind in self.channels:
         send_cmd(con, 'JOIN %s' % ind)
示例#9
0
def irc_cmd(server, nick, user, host, target, msg, data):
    # is_adm(host) checks whether the user is authenticated
    # in order to send back to the server the irc command.
    if is_adm(host): send_cmd(server, data)
示例#10
0
文件: ircadm.py 项目: unav1/ameliabot
def irc_cmd(server, nick, user, host, target, msg, data):
    if is_adm(host): send_cmd(server, data)
示例#11
0
def irc_cmd(server, nick, user, host, target, msg, data):
    # is_adm(host) checks whether the user is authenticated
    # in order to send back to the server the irc command.
    if is_adm(host): send_cmd(server, data)