Example #1
0
def test():
    # save off and clear alias.aliases, since it gets persisted # FIXME
    orig_aliases = alias.aliases
    alias.aliases = {}
    try:
        transport = protocol.FileWrapper(pipe)
        vt = VellumTalk()
        vt.performLogin = 0
        vt.joined("#testing")
        vt.defaultSession = d20session.D20Session('#testing')
        vt.makeConnection(transport)
        linesyntax.setBotName('VellumTalk')

        testOneSet(testcommands, vt)
        testOneSet(testhijack, vt)
        testOneSet(testobserved, vt)

        vt.userLeft('GeeEm', '#testing')
        testOneSet(testobserved2, vt)
    finally:
        # restore original aliases when done, so save works
        alias.aliases = orig_aliases
        global passed
        print passed
        passed = 0
Example #2
0
def test():
    # save off and clear alias.aliases, since it gets persisted # FIXME
    orig_aliases = alias.aliases
    alias.aliases = {}
    try:
        transport = protocol.FileWrapper(pipe)
        vt = VellumTalk()
        vt.performLogin = 0
        vt.joined("#testing")
        vt.defaultSession = d20session.D20Session('#testing')
        vt.makeConnection(transport)
        linesyntax.setBotName('VellumTalk')

        testOneSet(testcommands, vt)
        testOneSet(testhijack, vt)
        testOneSet(testobserved, vt)

        vt.userRenamed('Player', 'Superman')
        testOneSet(testobserverchange, vt)
        vt.userLeft('GeeEm', '#testing')
        testOneSet(testunobserved, vt)
    finally:
        # restore original aliases when done, so save works
        alias.aliases = orig_aliases
        global passed
        print passed
        passed = 0
Example #3
0
 def signedOn(self):
     """Called when bot has succesfully signed on to server."""
     # create a session to respond to private messages from nicks
     # not in any channel I'm in
     self.defaultSession = d20session.D20Session('')
     linesyntax.setBotName(self.nickname)
     # join my default channel
     self.join(self.factory.channel)
Example #4
0
 def signedOn(self):
     """Called when bot has succesfully signed on to server."""
     # create a session to respond to private messages from nicks
     # not in any channel I'm in
     self.defaultSession = Session('')
     linesyntax.setBotName(self.nickname)
     # join my default channel
     self.join(self.factory.channel)
Example #5
0
def test():
    from twisted.words.test.test_irc import StringIOWithoutClosing
    # save off and clear alias.aliases, since it gets persisted # FIXME
    orig_aliases = alias.aliases
    alias.aliases = {}
    try:
        f = StringIOWithoutClosing()
        transport = protocol.FileWrapper(f)
        vt = VellumTalk()
        vt.performLogin = 0
        vt.joined("#testing")
        vt.defaultSession = Session('#testing')
        vt.makeConnection(transport)
        pos = ([0],)
        linesyntax.setBotName('VellumTalk')

        def check(nick, channel, target, expected):
            _pos = pos[0] # ugh, python
            f.seek(_pos.pop(0))
            actual = f.read().strip()
            _pos.append(f.tell())
            if expected is None:
                if actual == '':
                    pass
                else:
                    print
                    print ' '*10 + ' '*len(target) + expected
                    print actual
                    return
            else:
                for _line in actual.splitlines():
                    pattern = 'PRIVMSG %s :%s' % (re.escape(target), expected)
                    if re.match(pattern, _line):
                        break
                else:
                    print
                    print ' '*10 + ' '*len(target) + expected
                    print actual
                    return
            sys.stdout.write('.')


        for nick, channel, target, sent, received in testcommands:
            vt.privmsg(nick, channel, sent)
            check(nick, channel, target, received)
        for nick, channel, target, sent, received in testhijack:
            vt.privmsg(nick, channel, sent)
            check(nick, channel, target, received)
    finally:
        # restore original aliases when done, so save works
        alias.aliases = orig_aliases