#include #include "channel.h" static void _handle_help_cmd(char *token, char *buff) { if (!token) goto help_help; if (!strcasecmp(token,"ADMIN")) snprintf(buff, PATH_MAX, "Syntax: ADMIN []\n" "Instructs the server to return information about " "the administrators of the server specified by " ". Where is either a server or a " "user. If is omitted, the server should " "return information about the administrators of " "the current server.\r\n"); else if (!strcasecmp(token, "AWAY")) snprintf(buff, PATH_MAX, "Syntax: AWAY []\n" "Provides the server with a message to automatically " "send in reply to a PRIVMSG directed at the user, but " "not to a channel they are on.[2] If is " "omitted, the away status is removed.\r\n"); else if (!strcasecmp(token, "CNOTICE")) snprintf(buff, PATH_MAX, "Syntax: CNOTICE :\n" "Sends a channel NOTICE message to on that " "bypasses flood protection limits. The target nickname must be " "in the same channel as the client issuing the command, and the " "client must be a channel operator.\r\n"); else if (!strcasecmp(token, "CPRIVMSG")) snprintf(buff, PATH_MAX, "Syntax: CPRIVMSG :\n" "Sends a private message to on that bypasses " "flood protection limits. The target nickname must be in the same " "channel as the client issuing the command, and the client must be " "a channel operator.\r\n"); else if (!strcasecmp(token, "CONNECT")) snprintf(buff, PATH_MAX, "Syntax: CONNECT [ []]\n" "Instructs the server (or the current server, if " " is omitted) to connect to on port " ". This command should only be available to IRC Operators.\r\n"); else if (!strcasecmp(token, "DIE")) snprintf(buff, PATH_MAX, "Syntax: DIE\n" "This command may only be issued by IRC server operators.\r\n"); else if (!strcasecmp(token, "ENCAP")) snprintf(buff, PATH_MAX, "Syntax: : ENCAP \n" "This command is for use by servers to encapsulate commands so that they will " "propagate across hub servers not yet updated to support them, and indicates the " "subcommand and its parameters should be passed unaltered to the destination, " "where it will be unencapsulated and parsed. This facilitates implementation of " "new features without a need to restart all servers before they are usable across " "the network.\r\n"); else if (!strcasecmp(token, "ERROR")) snprintf(buff, PATH_MAX, "Syntax: ERROR \n" "This command is for use by servers to report errors " "to other servers. It is also used before terminating " "client connections.\r\n"); else if (!strcasecmp(token, "INFO")) snprintf(buff, PATH_MAX, "Syntax: INFO []\n" "Returns information about the server, or " "the current server if is omitted. Information " "returned includes the server's version, when it was " "compiled, the patch level, when it was started, and " "any other information which may be considered to be " "relevant.\r\n"); else if (!strcasecmp(token, "INVITE")) snprintf(buff, PATH_MAX, "Syntax: INVITE \n" "Invites to the channel . " "does not have to exist, but if it does, only members of " "the channel are allowed to invite other clients. If the " "channel mode i is set, only channel operators may invite " "other clients.\r\n"); else if (!strcasecmp(token, "ISON")) snprintf(buff, PATH_MAX, "Syntax: ISON \n" "Queries the server to see if the clients in the " "space-separated list are currently on the " "network. The server returns only the nicknames that are " "on the network in a space-separated list. If none of " "the clients are on the network the server returns an " "empty list.\r\n"); else if (!strcasecmp(token, "JOIN")) snprintf(buff, PATH_MAX, "Syntax: JOIN []\n" "Makes the client join the channels in the comma-separated " "list , specifying the passwords, if needed, in " "the comma-separated list . If the channel(s) do not " "exist then they will be created.\r\n"); else if (!strcasecmp(token, "KICK")) snprintf(buff, PATH_MAX, "Syntax: KICK []\n" "Forcibly removes from . This command may " "only be issued by channel operators.\r\n"); else if (!strcasecmp(token, "KILL")) snprintf(buff, PATH_MAX, "Syntax: KILL \n" "Forcibly removes from the network. This command " "may only be issued by IRC operators.\r\n"); else if (!strcasecmp(token, "KNOCK")) snprintf(buff, PATH_MAX, "Syntax: KNOCK []\n" "Sends a NOTICE to an invitation-only with an " "optional , requesting an invite.\r\n"); else if (!strcasecmp(token, "LINKS")) snprintf(buff, PATH_MAX, "Syntax: LINKS [ []]\n" "Lists all server links matching , if given, on " ", or the current server if omitted.\r\n"); else if (!strcasecmp(token, "LIST")) snprintf(buff, PATH_MAX, "Syntax: LIST [ []]\n" "Lists all channels on the server. If the comma-separated " "list is given, it will return the channel topics. " "If is given, the command will be forwarded to " " for evaluation.\r\n"); else if (!strcasecmp(token, "LUSERS")) snprintf(buff, PATH_MAX, "Syntax: LUSERS [ []]\n" "Returns statistics about the size of the network. If called " "with no arguments, the statistics will reflect the entire " "network. If is given, it will return only statistics " "reflecting the masked subset of the network. If is " "given, the command will be forwarded to for " "evaluation.\r\n"); else if (!strcasecmp(token, "MODE")) snprintf(buff, PATH_MAX, "Syntax: MODE (user)\n MODE []\n" "The MODE command is dual-purpose. It can be used to set both user and channel modes.\r\n"); else if (!strcasecmp(token, "MOTD")) snprintf(buff, PATH_MAX, "Syntax: MOTD []\n" "Returns the message of the day on or the current " "server if it is omitted.\r\n"); else if (!strcasecmp(token, "NAMES")) snprintf(buff, PATH_MAX,"Syntax: NAMES [ []]\n" "Returns a list of who is on the comma-separated list of " ", by channel name. If is omitted, " "all users are shown, grouped by channel name with all users " "who are not on a channel being shown as part of channel \"*\". " "If is specified, the command is sent to " "for evaluation\r\n"); else if (!strcasecmp(token, "NAMESX")) snprintf(buff, PATH_MAX,"Syntax: PROTOCTL NAMESX\n" "Instructs the server to send names in an RPL_NAMES reply " "prefixed with all their respective channel statuses instead " "of just the highest one (similar to IRCv3's multi-prefix).\r\n"); else if (!strcasecmp(token, "NICK")) snprintf(buff, PATH_MAX,"Syntax: NICK []\n" "Allows a client to change their IRC nickname. Hopcount " "is for use between servers to specify how far away a " "nickname is from its home server.\r\n"); else if (!strcasecmp(token, "NOTICE")) snprintf(buff, PATH_MAX,"Syntax: NOTICE \n" "This command works similarly to PRIVMSG, except automatic " "replies must never be sent in reply to NOTICE messages.\r\n"); else if (!strcasecmp(token, "OPER")) snprintf(buff, PATH_MAX,"Syntax: OPER \n" "Authenticates a user as an IRC operator on that server/network.\r\n"); else if (!strcasecmp(token, "PART")) snprintf(buff, PATH_MAX,"Syntax: PART []\n" "Causes a user to leave the channels in the comma-separated " "list .\r\n"); else if (!strcasecmp(token, "PASS")) snprintf(buff, PATH_MAX,"Syntax: PASS \n" "Sets a connection password. This command must be sent " "before the NICK/USER registration combination.\r\n"); else if (!strcasecmp(token, "PING")) snprintf(buff, PATH_MAX,"Syntax: PING []\n" "Tests the presence of a connection. A PING message results " "in a PONG reply. If is specified, the message " "gets passed on to it.\r\n"); else if (!strcasecmp(token, "PONG")) snprintf(buff, PATH_MAX,"Syntax: PONG []" "This command is a reply to the PING command and works " "in much the same way.\r\n"); else if (!strcasecmp(token, "PRIVMSG")) snprintf(buff, PATH_MAX,"Syntax: PRIVMSG \n" "Sends to , which is usually a user " "or channel.\r\n"); else if (!strcasecmp(token, "QUIT")) snprintf(buff, PATH_MAX,"Syntax: QUIT []\n" "Disconnects the user from the server.\r\n"); else if (!strcasecmp(token, "REHASH")) snprintf(buff, PATH_MAX,"Syntax: REHASH\n" "Causes the server to re-read and re-process its configuration " "file(s). This command can only be sent by IRC Operators.\r\n"); else if (!strcasecmp(token, "RESTART")) snprintf(buff, PATH_MAX,"Syntax: RESTART\n" "Restarts a server. It may only be sent by IRC Operators.\r\n"); else if (!strcasecmp(token, "RULES")) snprintf(buff, PATH_MAX,"Syntax: RULES\n" "Requests the server rules.\r\n"); else if (!strcasecmp(token, "SERVER")) snprintf(buff, PATH_MAX,"Syntax: SERVER \n" "The server message is used to tell a server that the other " "end of a new connection is a server.[36] This message is also " "used to pass server data over whole net. details " "how many hops (server connections) away is. " " contains addition human-readable information about " "the server.\r\n"); else if (!strcasecmp(token, "SERVICE")) snprintf(buff, PATH_MAX,"Syntax: SERVICE \n" "Registers a new service on the network.\r\n"); else if (!strcasecmp(token, "SERVLIST")) snprintf(buff, PATH_MAX,"Syntax: SERVLIST [ []]\n" "Lists the services currently on the network.\r\n"); else if (!strcasecmp(token, "SQUERY")) snprintf(buff, PATH_MAX,"Syntax: SQUERY \n" "Identical to PRIVMSG except the recipient must be a " "service.\r\n"); else if (!strcasecmp(token, "SQUIT")) snprintf(buff, PATH_MAX,"Syntax: SQUIT \n" "Causes to quit the network.\r\n"); else if (!strcasecmp(token, "SETNAME")) snprintf(buff, PATH_MAX,"Syntax: SETNAME \n" "Allows a client to change the \"real name\" specified " "when registering a connection.\r\n"); else if (!strcasecmp(token, "SILENCE")) snprintf(buff, PATH_MAX,"Syntax: SILENCE [+/-]\n" "Adds or removes a host mask to a server-side ignore list " "that prevents matching users from sending the client messages. " "More than one mask may be specified in a space-separated list, " "each item prefixed with a \"+\" or \"-\" to designate whether " "it is being added or removed. Sending the command with no " "parameters returns the entries in the client's ignore list.\r\n"); else if (!strcasecmp(token, "STATS")) snprintf(buff, PATH_MAX,"Syntax: STATS []\n" "Returns statistics about the current server, or " "if it's specified.\r\n"); else if (!strcasecmp(token, "SUMMON")) snprintf(buff, PATH_MAX,"Syntax: SUMMON [ []]\n" "Gives users who are on the same host as a message " "asking them to join IRC.\r\n"); else if (!strcasecmp(token, "TIME")) snprintf(buff, PATH_MAX,"Syntax: TIME []\n" "Returns the local time on the current server, or " "if specified.\r\n"); else if (!strcasecmp(token, "TOPIC")) snprintf(buff, PATH_MAX,"Syntax: TOPIC []\n" "Allows the client to query or set the channel topic on " ". If is given, it sets the channel topic " "to . If channel mode +t is set, only a channel " "operator may set the topic.\r\n"); else if (!strcasecmp(token, "TRACE")) snprintf(buff, PATH_MAX,"Syntax: TRACE []\n" "Trace a path across the IRC network to a specific server " "or client, in a similar method to traceroute.\r\n"); else if (!strcasecmp(token, "UHNAMES")) snprintf(buff, PATH_MAX,"Syntax: PROTOCTL UHNAMES\n" "Instructs the server to send names in an RPL_NAMES reply " "in the long format.\r\n"); else if (!strcasecmp(token, "USER")) snprintf(buff, PATH_MAX,"Syntax: USER \n" "This command is used at the beginning of a connection to specify the " "username, hostname, real name and initial user modes of the connecting " "client. may contain spaces, and thus must be prefixed with a " "colon.\r\n"); else if (!strcasecmp(token, "USERHOST")) snprintf(buff, PATH_MAX,"Syntatx: USERHOST [ ...]\n" "Returns a list of information about the nicknames specified.\r\n"); else if (!strcasecmp(token, "USERIP")) snprintf(buff, PATH_MAX,"Syntatx: USERIP \n" "Requests the direct IP address of the user with the " "specified nickname.\r\n"); else if (!strcasecmp(token, "USERS")) snprintf(buff, PATH_MAX,"Syntatx: USERS []\n" "Returns a list of users and information about those users " "in a format similar to the UNIX commands who, rusers and " "finger.\r\n"); else if (!strcasecmp(token, "VERSION")) snprintf(buff, PATH_MAX,"Syntatx: VERSION []\n" "Returns the version of , or the current server " "if omitted.\r\n"); else if (!strcasecmp(token, "WALLOPS")) snprintf(buff, PATH_MAX,"Syntatx: WALLOPS \n" "Sends to all operators connected to the server, " "or all users with user mode 'w' set.\r\n"); else if (!strcasecmp(token, "WATCH")) snprintf(buff, PATH_MAX,"Syntatx: WATCH [+/-]\n" "Adds or removes a user to a client's server-side friends " "list. More than one nickname may be specified in a " "space-separated list, each item prefixed with a \"+\" or " "\"-\" to designate whether it is being added or removed. " "Sending the command with no parameters returns the " "entries in the client's friends list.\r\n"); else if (!strcasecmp(token, "WHO")) snprintf(buff, PATH_MAX,"Syntatx: WHO [ [\"o\"]]\n" "Returns a list of users who match . If the flag " "\"o\" is given, the server will only return information " "about IRC Operators.\r\n"); else if (!strcasecmp(token, "WHOIS")) snprintf(buff, PATH_MAX,"Syntatx: WHOIS [] \n" "Returns information about the comma-separated list of " "nicknames masks . If is given, the " "command is forwarded to it for processing.\r\n"); else if (!strcasecmp(token, "WHOWAS")) snprintf(buff, PATH_MAX,"Syntatx: WHOWAS [ []]\n" "Used to return information about a nickname that is no longer " "in use (due to client disconnection, or nickname changes). If " "given, the server will return information from the last " "times the nickname has been used. If is given, the " "command is forwarded to it for processing. can be " "a comma-separated list of nicknames.\r\n"); else help_help: snprintf(buff, PATH_MAX, "/HELP \n Available commands" " are: ADMIN AWAY CNOTICE CPRIVMSG CONNECT DIE ENCAP " "ERROR INFO INVITE ISON JOIN KICK KILL KNOCK LINKS " "LIST LUSERS MODE MOTD NAMES NAMESX NICK NOTICE OPER " "PART PASS PING PONG PRIVMSG QUIT REHASH RESTART " "RULES SERVER SERVICE SERVLIST SQUERY SQUIT SETNAME " "SILENCE STATS SUMMON TIME TOPIC TRACE UHNAMES USER " "USERHOST USERIP USERS VERSION WALLOPS WATCH WHO " "WHOIS WHOWAS\r\n"); } void _cmd_txt_handle(Express_Network *channel_net, const char *channel_name, char *str, char *buff) { char **tokens, *cmd = strdup(str); eina_str_toupper(&cmd); tokens = eina_str_split(cmd, " ", 0); if (!strcasecmp(tokens[0], "/HELP")) { _handle_help_cmd(tokens[1], buff); } else { snprintf(buff, PATH_MAX, "%s\r\n", str); express_network_channel_priv_send(channel_net, channel_name, buff); } free(cmd); }