mirror of
https://github.com/jlu5/PyLink.git
synced 2024-11-27 21:19:31 +01:00
58 lines
1.6 KiB
Python
58 lines
1.6 KiB
Python
from collections import defaultdict
|
|
import time
|
|
|
|
class IrcUser():
|
|
def __init__(self, nick, ts, uid, ident='null', host='null',
|
|
realname='PyLink dummy client', realhost='null',
|
|
ip='0.0.0.0', modes=set()):
|
|
self.nick = nick
|
|
self.ts = ts
|
|
self.uid = uid
|
|
self.ident = ident
|
|
self.host = host
|
|
self.realhost = realhost
|
|
self.ip = ip
|
|
self.realname = realname
|
|
self.modes = modes
|
|
|
|
self.identified = False
|
|
|
|
def __repr__(self):
|
|
return repr(self.__dict__)
|
|
|
|
class IrcServer():
|
|
"""PyLink IRC Server class.
|
|
|
|
uplink: The SID of this IrcServer instance's uplink. This is set to None
|
|
for the main PyLink PseudoServer!
|
|
name: The name of the server.
|
|
internal: Whether the server is an internal PyLink PseudoServer.
|
|
"""
|
|
def __init__(self, uplink, name, internal=False):
|
|
self.uplink = uplink
|
|
self.users = []
|
|
self.internal = internal
|
|
self.name = name.lower()
|
|
def __repr__(self):
|
|
return repr(self.__dict__)
|
|
|
|
class IrcChannel():
|
|
def __init__(self):
|
|
self.users = set()
|
|
self.modes = set()
|
|
self.topic = ''
|
|
self.ts = int(time.time())
|
|
self.prefixmodes = {'ops': set(), 'halfops': set(), 'voices': set(),
|
|
'owners': set(), 'admins': set()}
|
|
|
|
def __repr__(self):
|
|
return repr(self.__dict__)
|
|
|
|
def removeuser(self, target):
|
|
for s in self.prefixmodes.values():
|
|
s.discard(target)
|
|
self.users.discard(target)
|
|
|
|
class ProtocolError(Exception):
|
|
pass
|