async def register(self): servlocal = aioircd.servlocal.get() self.user.state = RegisteredState(self.user) aioircd.update_status() await self.user.send( textwrap.dedent("""\ :{host} 001 {nick} :Welcome to the Internet Relay Network {nick} :{host} 002 {nick} :Your host is {host}, running version {version} :{host} 003 {nick} :The server was created someday :{host} 004 {nick} aioircd {version} {usermodes} {chanmodes} :{host} 005 {nick} {cap1} :are supported by this server :{host} 005 {nick} {cap2} :are supported by this server :{host} 422 {nick} :MOTD File is missing""".format( host=servlocal.host, nick=self.user.nick, version=aioircd.__version__, # RPL_MYINFO (004), advertise availables modes (none) usermodes="", chanmodes="", # RPL_ISUPPORT (005), advertise server capabilities (not much) cap1=('AWAYLEN=0 CASEMAPPING=ascii CHANLIMIT=#: CHANMODES= ' 'CHANNELLEN=50 CHANTYPES=# ELIST='), cap2=('HOSTLEN=63 KICKLEN=0 MAXLIST= MAXTARGETS=12 MODES=0 ' 'NICKLEN=15 STATUSMSG= TOPICLEN=0 USERLEN=15'), )).split('\n'))
async def JOIN(self, channels): servlocal = aioircd.servlocal.get() for channel in channels.split(','): if not chan_re.match(channel): await self.user.send(ErrNoSuchChannel.format(channel)) continue # Find or create the channel, add the user in it chan = servlocal.channels.get(channel) if not chan: chan = Channel(channel) servlocal.channels[chan.name] = chan aioircd.update_status() chan.users.add(self.user) self.user.channels.add(chan) # Send JOIN response to all await chan.send(f":{self.user.nick} JOIN {channel}") # Send NAMES list to joiner await self.NAMES(channel)
async def PART(self, channels, reason=None): servlocal = aioircd.servlocal.get() for channel in channels.split(','): chan = servlocal.channels.get(channel) if not chan: await self.user.send(ErrNoSuchChannel.format(channel)) continue if self.user not in chan.users: await self.user.send(ErrNotOnChannel.format(channel)) continue self.user.channels.remove(chan) chan.users.remove(self.user) if not chan.users: servlocal.channels.pop(chan.name) aioircd.update_status() if reason: await chan.send(f":{self.user.nick} PART {channel} :{reason}") else: await chan.send(f":{self.user.nick} PART {channel}")
def __init__(self, user): super().__init__(user) user.nick = None aioircd.update_status()
def started(self, _listeners): sdnotify.ready() aioircd.update_status()