示例#1
0
 def numeric(self, source, numeric, *args):
     if numeric == RPL_WELCOME:
         for channel in self.ircchannel:
             self.fire(JOIN(channel))
     elif numeric == ERR_USERONCHANNEL:
         self.nick = newnick = "%s_" % self.nick
         self.fire(NICK(newnick))
示例#2
0
    def connected(self, host, port):
        """connected Event

        This event is triggered by the underlying ``TCPClient`` Component
        when a successfully connection has been made.
        """

        self.fire(NICK(self.nick))
        self.fire(USER("circuits", "circuits", host, "Artbuddy IRC Bot by epicmuffin/bloodywing"))
示例#3
0
    def connected(self, host, port):
        """connected Event

        This event is triggered by the underlying ``TCPClient`` Component
        when a successfully connection has been made.
        """

        self.fire(NICK("circuits"))
        self.fire(USER("circuits", "circuits", host, "Test circuits IRC Bot"))
示例#4
0
    def connected(self, host, port):
        print("Connected to %s:%d" % (host, port))

        nick = self.nick
        hostname = 'wc3.wechall.net:61221'
        # hostname = gethostname()
        name = "%s!spacebot (%s)" % (nick, hostname)

        self.fire(NICK(nick))
        self.fire(USER(nick, nick, hostname, name))
示例#5
0
def test_registration(server, client, watcher):
    client.fire(NICK("test"))
    client.fire(USER("test", "localhost", server.host, "Test Client"))

    assert watcher.wait("numeric")

    assert client.expect(
        "numeric",
        [(u'localhost', None, None), 1, u"test",
         u"Welcome to the {0:s} IRC Network".format(server.network)])
示例#6
0
    def connected(self, host, port):
        """Connected Event.

        Triggered by the underlying tcpclient Component when a successfully
        connection has been made.
        """

        self.fire(NICK(self.nick))
        self.fire(
            USER(self.nick, self.nick, host, "Bot of Astonex or Softkitty"))
示例#7
0
    def numeric(self, source, numeric, target, *args):
        """Numeric Event
        This event is triggered by the ``IRC`` Protocol Component when we have
        received an IRC Numeric Event from server we are connected to.
        """

        if numeric == ERR_NICKNAMEINUSE:
            self.fire(NICK("{0:s}_{1:d}".format(args[0], randint(0, 32768))))
        elif numeric in (RPL_ENDOFMOTD, ERR_NOMOTD):
            for irc_channel in self.irc_channels:
                self.fire(JOIN(irc_channel['name'], keys=irc_channel.get('key', None)))
示例#8
0
    def numeric(self, source, numeric, *args):
        """Numeric Event

        This event is triggered by the ``IRC`` Protocol Component when we have
        received an IRC Numberic Event from server we are connected to.
        """

        if numeric == ERR_NICKNAMEINUSE:
            self.fire(NICK("{0:s}_".format(args[0])))
        elif numeric in (RPL_ENDOFMOTD, ERR_NOMOTD):
            self.fire(JOIN("#artbuddy_test"))
示例#9
0
    def numeric(self, source, numeric, *args):
        """numeric Event

        This event is triggered by the ``IRC`` Protocol Component when we have
        received an IRC Numberic Event from server we are connected to.
        """

        if numeric == 1:
            self.fire(JOIN(self.ircchannel))
        elif numeric == 433:
            self.nick = newnick = "%s_" % self.nick
            self.fire(NICK(newnick))
示例#10
0
    def connected(self, host, port):
        """connected Event

        This event is triggered by the underlying ``TCPClient`` Component
        when a successfully connection has been made.
        """

        nick = self.nick
        hostname = self.hostname
        name = "%s on %s using circuits/%s" % (nick, hostname, systemVersion)

        self.fire(NICK(nick))
        self.fire(USER(nick, hostname, host, name))
示例#11
0
    def numeric(self, source, numeric, target, *args):
        """Numeric Event

        This event is triggered by the ``IRC`` Protocol Component when we have
        received an IRC Numberic Event from server we are connected to.
        """

        if numeric == ERR_NICKNAMEINUSE:
            self.fire(NICK("{0:s}_".format(args[0])))
        elif numeric in (RPL_ENDOFMOTD, ERR_NOMOTD):
            for ircchannels in self.ircchannels:
                for ircchannel in ircchannels.split(","):
                    self.fire(JOIN(ircchannel))
示例#12
0
    def connected(self, host, port):
        """Connected Event

        This event is triggered by the underlying ``TCPClient`` Component
        when a successfully connection has been made.
        """

        nick = self.nick
        hostname = self.hostname
        name = "{0:s} on {1:s} using circuits/{2:s}".format(
            nick, hostname, circuits.__version__)

        self.fire(USER(nick, hostname, host, name))
        self.fire(NICK(nick))
示例#13
0
    def numeric(self, source, numeric, *args):
        """Numeric Event.

        Triggered by the irc Protocol Component when we have received an irc
        Numberic Event from server we are connected to
        """

        # if nick is in use add an _ to the end of our name
        if numeric == ERR_NICKNAMEINUSE:
            self.fire(NICK("{0:s}_".format(args[0])))

        # else wait for end of motd to start sending commands
        elif numeric in (RPL_ENDOFMOTD, ERR_NOMOTD):
            self.fire(PRIVMSG("NICKSERV", "IDENTIFY " + self.password))
示例#14
0
    assert nick == "test"
    assert ident == "foo"
    assert host == "localhost"

    s = "test"
    nick, ident, host = parseprefix(s)
    assert nick == "test"
    assert ident is None
    assert host is None


@pytest.mark.parametrize("event,data", [
    (PASS("secret"), b"PASS secret\r\n"),
    (USER("foo", "localhost", "localhost",
          "Test Client"), b"USER foo localhost localhost :Test Client\r\n"),
    (NICK("test"), b"NICK test\r\n"),
    (PONG("localhost"), b"PONG :localhost\r\n"),
    (QUIT(), b"QUIT Leaving\r\n"),
    (QUIT("Test"), b"QUIT Test\r\n"),
    (QUIT("Test Message"), b"QUIT :Test Message\r\n"),
    (JOIN("#test"), b"JOIN #test\r\n"),
    (JOIN("#test", "secret"), b"JOIN #test secret\r\n"),
    (PART("#test"), b"PART #test\r\n"),
    (PRIVMSG("test", "Hello"), b"PRIVMSG test Hello\r\n"),
    (PRIVMSG("test", "Hello World"), b"PRIVMSG test :Hello World\r\n"),
    (NOTICE("test", "Hello"), b"NOTICE test Hello\r\n"),
    (NOTICE("test", "Hello World"), b"NOTICE test :Hello World\r\n"),
    (KICK("#test", "test"), b"KICK #test test :\r\n"),
    (KICK("#test", "test", "Bye"), b"KICK #test test Bye\r\n"),
    (KICK("#test", "test", "Good Bye!"), b"KICK #test test :Good Bye!\r\n"),
    (TOPIC("#test", "Hello World!"), b"TOPIC #test :Hello World!\r\n"),
示例#15
0
文件: ircbot.py 项目: Arctem/ircbot
 def connected(self, host, port):
     self.fire(NICK(self.nick))
     self.fire(USER(self.nick, self.nick, host, self.realname))
示例#16
0
文件: ircbot.py 项目: Arctem/ircbot
 def numeric(self, source, numeric, *args):
     if numeric == ERR_NICKNAMEINUSE:
         self.fire(NICK("{0:s}_".format(self.nick)))
     elif numeric in (RPL_ENDOFMOTD, ERR_NOMOTD):
         self.fire(JOIN(self.channel))
示例#17
0
 def __call__(self, args):
     self._commander.fire(NICK(args.nick), args.ircserver.channel)