Replace build_command location, code refactoring on irc

This commit is contained in:
adator
2025-11-23 16:15:10 +01:00
parent d66d297a33
commit 226340e1aa
5 changed files with 149 additions and 188 deletions

View File

@@ -65,56 +65,56 @@ class Command(IModule):
for c in new_cmds:
self.ctx.Irc.Protocol.known_protocol.add(c)
self.ctx.Irc.build_command(2, self.module_name, 'join', 'Join a channel')
self.ctx.Irc.build_command(2, self.module_name, 'assign', 'Assign a user to a role or task')
self.ctx.Irc.build_command(2, self.module_name, 'part', 'Leave a channel')
self.ctx.Irc.build_command(2, self.module_name, 'unassign', 'Remove a user from a role or task')
self.ctx.Irc.build_command(2, self.module_name, 'owner', 'Give channel ownership to a user')
self.ctx.Irc.build_command(2, self.module_name, 'deowner', 'Remove channel ownership from a user')
self.ctx.Irc.build_command(2, self.module_name, 'protect', 'Protect a user from being kicked')
self.ctx.Irc.build_command(2, self.module_name, 'deprotect', 'Remove protection from a user')
self.ctx.Irc.build_command(2, self.module_name, 'op', 'Grant operator privileges to a user')
self.ctx.Irc.build_command(2, self.module_name, 'deop', 'Remove operator privileges from a user')
self.ctx.Irc.build_command(1, self.module_name, 'halfop', 'Grant half-operator privileges to a user')
self.ctx.Irc.build_command(1, self.module_name, 'dehalfop', 'Remove half-operator privileges from a user')
self.ctx.Irc.build_command(1, self.module_name, 'voice', 'Grant voice privileges to a user')
self.ctx.Irc.build_command(1, self.module_name, 'devoice', 'Remove voice privileges from a user')
self.ctx.Irc.build_command(1, self.module_name, 'topic', 'Change the topic of a channel')
self.ctx.Irc.build_command(2, self.module_name, 'opall', 'Grant operator privileges to all users')
self.ctx.Irc.build_command(2, self.module_name, 'deopall', 'Remove operator privileges from all users')
self.ctx.Irc.build_command(2, self.module_name, 'devoiceall', 'Remove voice privileges from all users')
self.ctx.Irc.build_command(2, self.module_name, 'voiceall', 'Grant voice privileges to all users')
self.ctx.Irc.build_command(2, self.module_name, 'ban', 'Ban a user from a channel')
self.ctx.Irc.build_command(2, self.module_name, 'automode', 'Automatically set user modes upon join')
self.ctx.Irc.build_command(2, self.module_name, 'unban', 'Remove a ban from a user')
self.ctx.Irc.build_command(2, self.module_name, 'kick', 'Kick a user from a channel')
self.ctx.Irc.build_command(2, self.module_name, 'kickban', 'Kick and ban a user from a channel')
self.ctx.Irc.build_command(2, self.module_name, 'umode', 'Set user mode')
self.ctx.Irc.build_command(2, self.module_name, 'mode', 'Set channel mode')
self.ctx.Irc.build_command(2, self.module_name, 'get_mode', 'Retrieve current channel mode')
self.ctx.Irc.build_command(2, self.module_name, 'svsjoin', 'Force a user to join a channel')
self.ctx.Irc.build_command(2, self.module_name, 'svspart', 'Force a user to leave a channel')
self.ctx.Irc.build_command(2, self.module_name, 'svsnick', 'Force a user to change their nickname')
self.ctx.Irc.build_command(2, self.module_name, 'wallops', 'Send a message to all operators')
self.ctx.Irc.build_command(2, self.module_name, 'globops', 'Send a global operator message')
self.ctx.Irc.build_command(2, self.module_name, 'gnotice', 'Send a global notice')
self.ctx.Irc.build_command(2, self.module_name, 'whois', 'Get information about a user')
self.ctx.Irc.build_command(2, self.module_name, 'names', 'List users in a channel')
self.ctx.Irc.build_command(2, self.module_name, 'invite', 'Invite a user to a channel')
self.ctx.Irc.build_command(2, self.module_name, 'inviteme', 'Invite yourself to a channel')
self.ctx.Irc.build_command(2, self.module_name, 'sajoin', 'Force yourself into a channel')
self.ctx.Irc.build_command(2, self.module_name, 'sapart', 'Force yourself to leave a channel')
self.ctx.Irc.build_command(2, self.module_name, 'kill', 'Disconnect a user from the server')
self.ctx.Irc.build_command(2, self.module_name, 'gline', 'Ban a user from the entire server')
self.ctx.Irc.build_command(2, self.module_name, 'ungline', 'Remove a global server ban')
self.ctx.Irc.build_command(2, self.module_name, 'kline', 'Ban a user based on their hostname')
self.ctx.Irc.build_command(2, self.module_name, 'unkline', 'Remove a K-line ban')
self.ctx.Irc.build_command(2, self.module_name, 'shun', 'Prevent a user from sending messages')
self.ctx.Irc.build_command(2, self.module_name, 'unshun', 'Remove a shun from a user')
self.ctx.Irc.build_command(2, self.module_name, 'glinelist', 'List all global bans')
self.ctx.Irc.build_command(2, self.module_name, 'shunlist', 'List all shunned users')
self.ctx.Irc.build_command(2, self.module_name, 'klinelist', 'List all K-line bans')
self.ctx.Irc.build_command(3, self.module_name, 'map', 'Show the server network map')
self.ctx.Commands.build_command(2, self.module_name, 'join', 'Join a channel')
self.ctx.Commands.build_command(2, self.module_name, 'assign', 'Assign a user to a role or task')
self.ctx.Commands.build_command(2, self.module_name, 'part', 'Leave a channel')
self.ctx.Commands.build_command(2, self.module_name, 'unassign', 'Remove a user from a role or task')
self.ctx.Commands.build_command(2, self.module_name, 'owner', 'Give channel ownership to a user')
self.ctx.Commands.build_command(2, self.module_name, 'deowner', 'Remove channel ownership from a user')
self.ctx.Commands.build_command(2, self.module_name, 'protect', 'Protect a user from being kicked')
self.ctx.Commands.build_command(2, self.module_name, 'deprotect', 'Remove protection from a user')
self.ctx.Commands.build_command(2, self.module_name, 'op', 'Grant operator privileges to a user')
self.ctx.Commands.build_command(2, self.module_name, 'deop', 'Remove operator privileges from a user')
self.ctx.Commands.build_command(1, self.module_name, 'halfop', 'Grant half-operator privileges to a user')
self.ctx.Commands.build_command(1, self.module_name, 'dehalfop', 'Remove half-operator privileges from a user')
self.ctx.Commands.build_command(1, self.module_name, 'voice', 'Grant voice privileges to a user')
self.ctx.Commands.build_command(1, self.module_name, 'devoice', 'Remove voice privileges from a user')
self.ctx.Commands.build_command(1, self.module_name, 'topic', 'Change the topic of a channel')
self.ctx.Commands.build_command(2, self.module_name, 'opall', 'Grant operator privileges to all users')
self.ctx.Commands.build_command(2, self.module_name, 'deopall', 'Remove operator privileges from all users')
self.ctx.Commands.build_command(2, self.module_name, 'devoiceall', 'Remove voice privileges from all users')
self.ctx.Commands.build_command(2, self.module_name, 'voiceall', 'Grant voice privileges to all users')
self.ctx.Commands.build_command(2, self.module_name, 'ban', 'Ban a user from a channel')
self.ctx.Commands.build_command(2, self.module_name, 'automode', 'Automatically set user modes upon join')
self.ctx.Commands.build_command(2, self.module_name, 'unban', 'Remove a ban from a user')
self.ctx.Commands.build_command(2, self.module_name, 'kick', 'Kick a user from a channel')
self.ctx.Commands.build_command(2, self.module_name, 'kickban', 'Kick and ban a user from a channel')
self.ctx.Commands.build_command(2, self.module_name, 'umode', 'Set user mode')
self.ctx.Commands.build_command(2, self.module_name, 'mode', 'Set channel mode')
self.ctx.Commands.build_command(2, self.module_name, 'get_mode', 'Retrieve current channel mode')
self.ctx.Commands.build_command(2, self.module_name, 'svsjoin', 'Force a user to join a channel')
self.ctx.Commands.build_command(2, self.module_name, 'svspart', 'Force a user to leave a channel')
self.ctx.Commands.build_command(2, self.module_name, 'svsnick', 'Force a user to change their nickname')
self.ctx.Commands.build_command(2, self.module_name, 'wallops', 'Send a message to all operators')
self.ctx.Commands.build_command(2, self.module_name, 'globops', 'Send a global operator message')
self.ctx.Commands.build_command(2, self.module_name, 'gnotice', 'Send a global notice')
self.ctx.Commands.build_command(2, self.module_name, 'whois', 'Get information about a user')
self.ctx.Commands.build_command(2, self.module_name, 'names', 'List users in a channel')
self.ctx.Commands.build_command(2, self.module_name, 'invite', 'Invite a user to a channel')
self.ctx.Commands.build_command(2, self.module_name, 'inviteme', 'Invite yourself to a channel')
self.ctx.Commands.build_command(2, self.module_name, 'sajoin', 'Force yourself into a channel')
self.ctx.Commands.build_command(2, self.module_name, 'sapart', 'Force yourself to leave a channel')
self.ctx.Commands.build_command(2, self.module_name, 'kill', 'Disconnect a user from the server')
self.ctx.Commands.build_command(2, self.module_name, 'gline', 'Ban a user from the entire server')
self.ctx.Commands.build_command(2, self.module_name, 'ungline', 'Remove a global server ban')
self.ctx.Commands.build_command(2, self.module_name, 'kline', 'Ban a user based on their hostname')
self.ctx.Commands.build_command(2, self.module_name, 'unkline', 'Remove a K-line ban')
self.ctx.Commands.build_command(2, self.module_name, 'shun', 'Prevent a user from sending messages')
self.ctx.Commands.build_command(2, self.module_name, 'unshun', 'Remove a shun from a user')
self.ctx.Commands.build_command(2, self.module_name, 'glinelist', 'List all global bans')
self.ctx.Commands.build_command(2, self.module_name, 'shunlist', 'List all shunned users')
self.ctx.Commands.build_command(2, self.module_name, 'klinelist', 'List all K-line bans')
self.ctx.Commands.build_command(3, self.module_name, 'map', 'Show the server network map')
def unload(self) -> None:
self.ctx.Commands.drop_command_by_module(self.module_name)
@@ -214,7 +214,7 @@ class Command(IModule):
user_uid = self.ctx.User.clean_uid(cmd[5])
userObj: MUser = self.ctx.User.get_user(user_uid)
channel_name = cmd[4] if self.ctx.Channel.is_valid_channel(cmd[4]) else None
client_obj = self.ctx.Client.get_Client(user_uid)
client_obj = self.ctx.Client.get_client(user_uid)
nickname = userObj.nickname if userObj is not None else None
if client_obj is not None: