示例#1
0
def test_build2():
    command = 'command'
    params = ['param1', 'param with spaces']
    text = 'COMMAND param1 :param with spaces'

    msg = Message(command=command, params=params)
    assert msg.to_string() == text
示例#2
0
def test_build2():
    command = 'command'
    params = ['param1', 'param with spaces']
    text = 'COMMAND param1 :param with spaces'

    msg = Message(command=command, params=params)
    assert msg.to_string() == text
示例#3
0
def test_build1():
    prefix = 'prefix'
    command = 'command'
    params = ['param1', 'param2']
    text = ':prefix COMMAND param1 param2'

    msg = Message(prefix=prefix, command=command, params=params)
    assert msg.to_string() == text
示例#4
0
def test_build1():
    prefix = 'prefix'
    command = 'command'
    params = ['param1', 'param2']
    text = ':prefix COMMAND param1 param2'

    msg = Message(prefix=prefix, command=command, params=params)
    assert msg.to_string() == text
示例#5
0
def test_parse1():
    text = ':irc.example.com 251 botnet_test :There are 185 users on 25 servers'
    msg = Message()
    msg.from_string(text)

    # Prefix
    assert msg.prefix == msg.servername == 'irc.example.com'
    assert msg.nickname is None 
    # Command
    assert msg.command == '251'
    assert msg.command_code() == Code.RPL_LUSERCLIENT
    # Params
    assert msg.params[0] == 'botnet_test'
    assert msg.params[1] == 'There are 185 users on 25 servers'

    assert msg.to_string() == text
示例#6
0
def test_parse2():
    text = ':[email protected] PRIVMSG #channel :test 123456'
    msg = Message()
    msg.from_string(text)

    # Prefix
    assert msg.nickname == 'nick'
    assert msg.servername is None 
    # Command
    assert msg.command == 'PRIVMSG'
    assert msg.command_code() is None
    # Params
    assert msg.params[0] == '#channel'
    assert msg.params[1] == 'test 123456'

    assert msg.to_string() == text
示例#7
0
def test_parse_pretty_illegal_colors():
    text = bytes.fromhex('3a6e 6963 6b21 7e7a 401f 0334 4a6f 796f 7573 032e 0333 4b77 616e 7a61 6103 2e1f 6e69 636b 2050 5249 564d 5347 2072 6f62 6f74 6e65 745f 7465 7374 2074 6573 74').decode()
    msg = Message()
    msg.from_string(text)

    # Prefix
    assert msg.nickname == 'nick'
    assert msg.servername is None
    # Command
    assert msg.command == 'PRIVMSG'
    assert msg.command_code() is None
    # Params
    print(msg.params)
    assert msg.params[0] == 'robotnet_test'
    assert msg.params[1] == 'test'

    assert msg.to_string() == text
示例#8
0
def test_parse1():
    text = ':irc.example.com 251 botnet_test :There are 185 users on 25 servers'
    msg = Message()
    msg.from_string(text)

    # Prefix
    assert msg.prefix == msg.servername == 'irc.example.com'
    assert msg.nickname is None
    # Command
    assert msg.command == '251'
    assert msg.command_code() == Code.RPL_LUSERCLIENT
    # Params
    assert msg.params[0] == 'botnet_test'
    assert msg.params[1] == 'There are 185 users on 25 servers'

    assert msg.to_string() == text
示例#9
0
def test_parse2():
    text = ':[email protected] PRIVMSG #channel :test 123456'
    msg = Message()
    msg.from_string(text)

    # Prefix
    assert msg.nickname == 'nick'
    assert msg.servername is None
    # Command
    assert msg.command == 'PRIVMSG'
    assert msg.command_code() is None
    # Params
    assert msg.params[0] == '#channel'
    assert msg.params[1] == 'test 123456'

    assert msg.to_string() == text
示例#10
0
def test_whois_intertwined():
    config = make_config()
    a = Admin(config)

    for i in range(len(data1)):
        msg = Message()
        msg.from_string(data1[i])
        message_in.send(None, msg=msg)

        msg = Message()
        msg.from_string(data2[i])
        message_in.send(None, msg=msg)

    assert a._whois_cache.get('nick1')
    assert a._whois_cache.get('nick2')
    assert not a._whois_current
示例#11
0
def test_parse_pretty_illegal_colors():
    text = bytes.fromhex(
        '3a6e 6963 6b21 7e7a 401f 0334 4a6f 796f 7573 032e 0333 4b77 616e 7a61 6103 2e1f 6e69 636b 2050 5249 564d 5347 2072 6f62 6f74 6e65 745f 7465 7374 2074 6573 74'
    ).decode()
    msg = Message()
    msg.from_string(text)

    # Prefix
    assert msg.nickname == 'nick'
    assert msg.servername is None
    # Command
    assert msg.command == 'PRIVMSG'
    assert msg.command_code() is None
    # Params
    print(msg.params)
    assert msg.params[0] == 'robotnet_test'
    assert msg.params[1] == 'test'

    assert msg.to_string() == text
示例#12
0
def admin_make_message(nick, text):
    text = ':%[email protected] PRIVMSG %s' % (nick, text)
    msg = Message()
    msg.from_string(text)
    return msg
def make_privmsg(text):
    text = ':[email protected] PRIVMSG %s' % text
    msg = Message()
    msg.from_string(text)
    return msg
示例#14
0
 def f(text, nick='nick'):
     text = ':%[email protected] PRIVMSG #channel :%s' % (nick, text)
     msg = Message()
     msg.from_string(text)
     return msg
示例#15
0
def send_data(data):
    for text in data:
        msg = Message()
        msg.from_string(text)
        message_in.send(None, msg=msg)
示例#16
0
文件: conftest.py 项目: boreq/botnet
 def f(text, nick='nick'):
     text = ':%[email protected] PRIVMSG #channel :%s' % (nick, text)
     msg = Message()
     msg.from_string(text)
     return msg
示例#17
0
def make_message(text):
    text = ':[email protected] PRIVMSG %s' % text
    msg = Message()
    msg.from_string(text)
    return msg