mirror of
https://github.com/jlu5/PyLink.git
synced 2025-02-17 14:01:03 +01:00
classes: provide IrcChannel objects with their own name using KeyedDefaultdict
Closes #171.
This commit is contained in:
parent
544d6e1041
commit
1d4350c4fd
@ -13,7 +13,6 @@ import time
|
|||||||
import socket
|
import socket
|
||||||
import threading
|
import threading
|
||||||
import ssl
|
import ssl
|
||||||
from collections import defaultdict
|
|
||||||
import hashlib
|
import hashlib
|
||||||
from copy import deepcopy
|
from copy import deepcopy
|
||||||
|
|
||||||
@ -112,7 +111,7 @@ class Irc():
|
|||||||
internal=True, desc=self.serverdata.get('serverdesc')
|
internal=True, desc=self.serverdata.get('serverdesc')
|
||||||
or self.botdata['serverdesc'])}
|
or self.botdata['serverdesc'])}
|
||||||
self.users = {}
|
self.users = {}
|
||||||
self.channels = defaultdict(IrcChannel)
|
self.channels = utils.KeyedDefaultdict(IrcChannel)
|
||||||
|
|
||||||
# This sets the list of supported channel and user modes: the default
|
# This sets the list of supported channel and user modes: the default
|
||||||
# RFC1459 modes are implied. Named modes are used here to make
|
# RFC1459 modes are implied. Named modes are used here to make
|
||||||
@ -568,7 +567,7 @@ class IrcServer():
|
|||||||
|
|
||||||
class IrcChannel():
|
class IrcChannel():
|
||||||
"""PyLink IRC channel class."""
|
"""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.
|
# Initialize variables, such as the topic, user list, TS, who's opped, etc.
|
||||||
self.users = set()
|
self.users = set()
|
||||||
self.modes = {('n', None), ('t', None)}
|
self.modes = {('n', None), ('t', None)}
|
||||||
@ -581,6 +580,9 @@ class IrcChannel():
|
|||||||
# should set this.
|
# should set this.
|
||||||
self.topicset = False
|
self.topicset = False
|
||||||
|
|
||||||
|
# Saves the channel name (may be useful to plugins, etc.)
|
||||||
|
self.name = name
|
||||||
|
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
return 'IrcChannel(%s)' % self.__dict__
|
return 'IrcChannel(%s)' % self.__dict__
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user