mirror of
https://github.com/jlu5/PyLink.git
synced 2024-11-24 03:29:28 +01:00
Make IrcChannel.users a set and add part handling
This should be everything needed for basic channel enumeration: closes #13.
This commit is contained in:
parent
4b9e7b1937
commit
70480b8830
@ -25,7 +25,7 @@ class IrcServer():
|
|||||||
|
|
||||||
class IrcChannel():
|
class IrcChannel():
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.users = []
|
self.users = set()
|
||||||
'''
|
'''
|
||||||
self.ops = []
|
self.ops = []
|
||||||
self.halfops = []
|
self.halfops = []
|
||||||
|
11
proto.py
11
proto.py
@ -41,9 +41,7 @@ def removeClient(irc, numeric):
|
|||||||
Removes a client from our internal databases, regardless
|
Removes a client from our internal databases, regardless
|
||||||
of whether it's one of our pseudoclients or not."""
|
of whether it's one of our pseudoclients or not."""
|
||||||
for k, v in copy(irc.channels).items():
|
for k, v in copy(irc.channels).items():
|
||||||
if numeric in irc.channels[k].users:
|
irc.channels[k].users.discard(numeric)
|
||||||
print('Removing client %s from channel %s' % (numeric, k))
|
|
||||||
irc.channels[k].users.remove(numeric)
|
|
||||||
if not irc.channels[k].users:
|
if not irc.channels[k].users:
|
||||||
# Clear empty channels
|
# Clear empty channels
|
||||||
del irc.channels[k]
|
del irc.channels[k]
|
||||||
@ -102,6 +100,11 @@ def handle_privmsg(irc, source, command, args):
|
|||||||
msg(irc, source, 'Uncaught exception in command %r: %s: %s' % (cmd, type(e).__name__, str(e)))
|
msg(irc, source, 'Uncaught exception in command %r: %s: %s' % (cmd, type(e).__name__, str(e)))
|
||||||
return
|
return
|
||||||
|
|
||||||
|
def handle_part(irc, source, command, args):
|
||||||
|
channel = args[0]
|
||||||
|
# We should only get PART commands for channels that exist, right??
|
||||||
|
irc.channels[channel].users.discard(source)
|
||||||
|
|
||||||
def handle_error(irc, numeric, command, args):
|
def handle_error(irc, numeric, command, args):
|
||||||
print('Received an ERROR, killing!')
|
print('Received an ERROR, killing!')
|
||||||
irc.connected = False
|
irc.connected = False
|
||||||
@ -128,7 +131,7 @@ def handle_fjoin(irc, servernumeric, command, args):
|
|||||||
if mode == 'v':
|
if mode == 'v':
|
||||||
irc.channels[channel].voices.append(user)
|
irc.channels[channel].voices.append(user)
|
||||||
'''
|
'''
|
||||||
irc.channels[channel].users.append(user)
|
irc.channels[channel].users.add(user)
|
||||||
|
|
||||||
def handle_uid(irc, numeric, command, args):
|
def handle_uid(irc, numeric, command, args):
|
||||||
# :70M UID 70MAAAAAB 1429934638 GL 0::1 hidden-7j810p.9mdf.lrek.0000.0000.IP gl 0::1 1429934638 +Wioswx +ACGKNOQXacfgklnoqvx :realname
|
# :70M UID 70MAAAAAB 1429934638 GL 0::1 hidden-7j810p.9mdf.lrek.0000.0000.IP gl 0::1 1429934638 +Wioswx +ACGKNOQXacfgklnoqvx :realname
|
||||||
|
Loading…
Reference in New Issue
Block a user