async def end_of_names(connection, channel, prefix=None): # Deregister RPL_NAMERPLY callback client.off(RPL_NAMEREPLY, receive_names) client.add_msg(channel, "Members: ") for name in names: client.add_msg(channel, " " + name)
async def client_join(connection, channel, prefix=None): """Displays a message when a user JOINs the chat. Begins listening for a NAMES reply, if the message was an echo of our own JOIN. """ client.add_msg(channel, "%s has joined the chat!" % prefix) if prefix == client.nickname: listen_for_names()
async def on_nick_collision(connection, nick, *params, prefix=None): client.add_msg('SYSTEM', "Nickname taken: %s" % nick) client.add_msg('SYSTEM', "You have been assigned an anonymous nickname" "") client.add_msg( 'SYSTEM', "Type '/NICK ' followed by your nickname to choose a new one" "")
async def on_already_registered(connection, msg, prefix=None): client.add_msg('SYSTEM', "Error: %s" % msg)
async def on_need_more_params(connection, cmd, msg, prefix=None): client.add_msg('SYSTEM', "Error in cmd %s: %s" % (cmd, msg))
async def on_nick_error(connection, nick, *params, prefix=None): client.add_msg('SYSTEM', "Unable to set nickname. Invalid nickname: %s" % nick) client.add_msg('SYSTEM', "Nicknames must respect the following rules:") client.add_msg('SYSTEM', " 1. Between 1 and 9 characters long") client.add_msg('SYSTEM', " 2. Start with a letter") client.add_msg( 'SYSTEM', R" 3. Contain only letters, numbers, and the following special characters: -[]\|`^{}" ) client.add_msg('SYSTEM', "Type '/NICK ' followed by a nickname to try again" "")
async def on_nick_in_use(connection, nick, *params, prefix=None): client.add_msg('SYSTEM', "Unable to set nickname. Nickname taken: %s" % nick) client.add_msg('SYSTEM', "Type '/NICK ' followed by a nickname to try again" "")
async def client_quit(connection, msg, prefix=None): """Displays a message when a user QUITs the chat""" client.add_msg(prefix, "*left the chat: %s*" % msg)
async def receive_message(connection, receivers, msg, prefix=None): """Displays received messages in the View""" client.add_msg(prefix, msg)
async def on_nick(connection, nick, prefix=None): if prefix == client.nickname: client.nickname = nick else: client.add_msg(prefix, "*changed their nickname to %s*" % nick)