Exemple #1
0
def test_user_get_function(c):
    c.me = User('Test')
    match = Match(None, None, c)

    assert c.users == [c.me]
    assert User.get('Test', c) is c.me
    assert User.get('Test!A@B', c) is c.me
    assert User.get('Test', match) is c.me
    assert User.get('Test2', c) is None
Exemple #2
0
def test_user_get_function(c):
    c.me = User('Test')
    match = Match(None, None, c)

    assert c.users == [c.me]
    assert User.get('Test', c) is c.me
    assert User.get('Test!A@B', c) is c.me
    assert User.get('Test', match) is c.me
    assert User.get('Test2', c) is None
Exemple #3
0
def test_user_str_parsing():
    user_str = 'Abc09_-\\[]{}^`|[email protected]'
    user = User(user_str)

    assert user.host == 'some.host'
    assert user.name == 'RealName'
    assert user.nick == 'Abc09_-\\[]{}^`|'

    user = User('AName')
    assert user.host is None
    assert user.name is None
    assert user.nick == 'AName'
def test_join_command(c):
    settings = MockObject(command_prefix='!')

    def match(line):
        assert track.join.command.matches(line, settings) is True
        track.join.command.match(line, [], c, settings)

    c.me = User('Pyro')

    line = Line(':Pyro!Hello@world JOIN :#Chan', c)
    assert line.sender is c.me

    match(line)
    assert len(c.me.channels) == 1
    assert c.me.channels[0] is line.channel
    assert c.last == 'WHOIS Pyro'

    channel = c.me.channels[0]
    line = Line(':User1!Hello@world JOIN #Chan', c)
    assert line.command == 'JOIN'
    assert line.channel == channel

    match(line)

    assert c.last == 'WHOIS User1'
    assert channel.users == [c.me, line.sender]
    assert line.sender.channels == [channel]
Exemple #5
0
def names(match):
    chan = Channel.get(match.line[4], match)

    if not chan:
        chan = Channel(match.line[4])

    for nick in match.line[5:]:
        nick = nick.lstrip(':!~&@%+')
        user = User.get(nick, match)

        if not user:
            user = User(nick)

        chan.users.append(user)
        user.channels.append(chan)

        if not user.auth:
            match.connection.write('WHOIS {}'.format(nick))
Exemple #6
0
def who_entry(match):
    user = User.get(match.line[7], match)

    if user.host is None:
        # User is new to us, so let's set info we know
        user.host = match.line[5]

    chan = Channel.get(match.line[3], match)
    if user not in chan.users:
        chan.users.append(user)

    if chan not in user.channels:
        user.channels.append(chan)
Exemple #7
0
def test_channel_get_function(c):
    c.me = User('')

    chan = Channel('#test')
    assert c.channels == []

    c.me.channels.append(chan)
    assert c.channels == [chan]

    assert Channel.get('#test', c) is chan
    assert Channel.get('#test2', c) is not chan

    match = Match(None, None, c)
    assert Channel.get('#test', match) is chan

    assert Channel.get('#test', None) is not chan
Exemple #8
0
 def __init__(self, *args, **kwargs):
     self.outbox = []
     self.me = User('')
Exemple #9
0
def kick(match):
    user = User.get(match.line[3], match)
    match.line.channel.users.remove(user)
Exemple #10
0
def whois_auth(match):
    user = User.get(match.line[3], match)
    user.auth = match.line[4]
Exemple #11
0
def whois_host_and_name(match):
    user = User.get(match.line[3], match)
    user.host = match.line[5]