3
0
mirror of https://github.com/jlu5/PyLink.git synced 2024-11-27 13:09:23 +01:00

classes: provide IrcChannel objects with their own name using KeyedDefaultdict

Closes #171.
This commit is contained in:
James Lu 2016-03-19 17:01:39 -07:00
parent 544d6e1041
commit 1d4350c4fd

View File

@ -13,7 +13,6 @@ import time
import socket
import threading
import ssl
from collections import defaultdict
import hashlib
from copy import deepcopy
@ -112,7 +111,7 @@ class Irc():
internal=True, desc=self.serverdata.get('serverdesc')
or self.botdata['serverdesc'])}
self.users = {}
self.channels = defaultdict(IrcChannel)
self.channels = utils.KeyedDefaultdict(IrcChannel)
# This sets the list of supported channel and user modes: the default
# RFC1459 modes are implied. Named modes are used here to make
@ -568,7 +567,7 @@ class IrcServer():
class IrcChannel():
"""PyLink IRC channel class."""
def __init__(self):
def __init__(self, name=None):
# Initialize variables, such as the topic, user list, TS, who's opped, etc.
self.users = set()
self.modes = {('n', None), ('t', None)}
@ -581,6 +580,9 @@ class IrcChannel():
# should set this.
self.topicset = False
# Saves the channel name (may be useful to plugins, etc.)
self.name = name
def __repr__(self):
return 'IrcChannel(%s)' % self.__dict__