X-Git-Url: http://git.pk910.de/?a=blobdiff_plain;f=src%2Fmodcmd.h;h=52c272c53e6f8acd6c9425cd3519292592c7a100;hb=391260f64a1dfb35bf0a55e7044fe1b8d83f2561;hp=940ab32a6d021e4aac83c8fc07405e6c2e5adae0;hpb=0f1dc61921eef1db8e404a5a82372e2d1cd55daa;p=NeonServV5.git diff --git a/src/modcmd.h b/src/modcmd.h index 940ab32..52c272c 100644 --- a/src/modcmd.h +++ b/src/modcmd.h @@ -1,7 +1,25 @@ +/* modcmd.h - NeonServ v5.2 + * Copyright (C) 2011 Philipp Kreil (pk910) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ #ifndef _modcmd_h #define _modcmd_h #include "main.h" +#define MAXPARAMETERS 50 + #define CMDFLAG_REQUIRE_CHAN 0x0001 #define CMDFLAG_REQUIRE_AUTH 0x0002 #define CMDFLAG_REQUIRE_GOD 0x0004 @@ -12,6 +30,11 @@ #define CMDFLAG_CHAN_PARAM 0x0080 #define CMDFLAG_LOG 0x0100 #define CMDFLAG_OPLOG 0x0200 +#define CMDFLAG_EMPTY_ARGS 0x0400 +#define CMDFLAG_REQUIRED 0x0800 +#define CMDFLAG_TEMPONARY_BIND 0x1000 +#define CMDFLAG_FUNCMD 0x2000 +#define CMDFLAG_ESCAPE_ARGS 0x4000 struct ClientSocket; struct UserNode; @@ -20,7 +43,7 @@ struct Event; #define CMD_BIND(NAME) void NAME(UNUSED_ARG(struct ClientSocket *client), UNUSED_ARG(struct UserNode *user), UNUSED_ARG(struct ChanNode *chan), UNUSED_ARG(char **argv), UNUSED_ARG(char argc), UNUSED_ARG(struct Event *event)) typedef void cmd_bind_t(struct ClientSocket *client, struct UserNode *user, struct ChanNode *chan, char **argv, char argc, struct Event *event); -typedef void trigger_callback_t(struct ChanNode *chan, char *trigger); +typedef void trigger_callback_t(int clientid, struct ChanNode *chan, char *trigger); struct cmd_function { char *name; @@ -37,36 +60,69 @@ struct cmd_function { struct cmd_binding { char *cmd; int botid; + int clientid; struct cmd_function *func; unsigned int flags; - char *parameters; + char *parameters[MAXPARAMETERS]; + int paramcount; int global_access; char *channel_access; + int triggered; struct cmd_binding *next; }; struct trigger_cache { int botid; + int clientid; char *trigger; struct trigger_cache *next; }; +extern int statistics_commands; + void init_modcmd(); void free_modcmd(); -struct ClientSocket* get_prefered_bot(int botid); + +#define get_prefered_bot(BOTID) get_botwise_prefered_bot(BOTID, 0) +struct ClientSocket* get_botwise_prefered_bot(int botid, int clientid); + int register_command(int botid, char *name, cmd_bind_t *func, int paramcount, char *channel_access, int global_access, unsigned int flags); int set_trigger_callback(int botid, trigger_callback_t *func); -int changeChannelTrigger(int botid, struct ChanNode *chan, char *new_trigger); -int bind_cmd_to_function(int botid, char *cmd, struct cmd_function *func); -int bind_cmd_to_command(int botid, char *cmd, char *func); -int unbind_cmd(int botid, char *cmd); + +#define changeChannelTrigger(BOTID,CHAN,NEW) changeBotwiseChannelTrigger(BOTID, 0, CHAN, NEW) +int changeBotwiseChannelTrigger(int botid, int clientid, struct ChanNode *chan, char *new_trigger); + +#define bind_cmd_to_function(BOTID,CMD,FUNC) bind_botwise_cmd_to_function(BOTID, 0, CMD, FUNC) +int bind_botwise_cmd_to_function(int botid, int clientid, char *cmd, struct cmd_function *func); + +#define bind_cmd_to_command(BOTID,CMD,FUNC) bind_botwise_cmd_to_command(BOTID, 0, CMD, FUNC) +int bind_botwise_cmd_to_command(int botid, int clientid, char *cmd, char *func); + +#define unbind_cmd(BOTID,CMD) unbind_botwise_cmd(BOTID, 0, CMD) +int unbind_botwise_cmd(int botid, int clientid, char *cmd); + +int unbind_botwise_allcmd(int clientid); + +#define bind_set_parameters(BOTID,CMD,PARAMETERS) bind_botwise_set_parameters(BOTID, 0, CMD, PARAMETERS) +void bind_botwise_set_parameters(int botid, int clientid, char *cmd, char *parameters); + +#define bind_set_global_access(BOTID,CMD,GACCESS) bind_botwise_set_global_access(BOTID, 0, CMD, GACCESS) +void bind_botwise_set_global_access(int botid, int clientid, char *cmd, int gaccess); + +#define bind_set_channel_access(BOTID,CMD,CACCESS) bind_botwise_set_channel_access(BOTID, 0, CMD, CACCESS) +void bind_botwise_set_channel_access(int botid, int clientid, char *cmd, char *chanaccess); + +#define find_cmd_binding(BOTID,CMD) find_botwise_cmd_binding(BOTID, 0, CMD) +struct cmd_binding *find_botwise_cmd_binding(int botid, int clientid, char *cmd); + +#define bind_unbound_required_functions(BOTID) bind_botwise_unbound_required_functions(BOTID, 0) +void bind_botwise_unbound_required_functions(int botid, int clientid); + struct cmd_function *find_cmd_function(int botid, char *name); struct ClientSocket *getTextBot(); -void bind_set_parameters(int botid, char *cmd, char *parameters); -void bind_set_global_access(int botid, char *cmd, int gaccess); -void bind_set_channel_access(int botid, char *cmd, char *chanaccess); -struct cmd_binding *find_cmd_binding(int botid, char *cmd); +void register_command_alias(int botid, char *alias); +struct cmd_binding *getAllBinds(struct cmd_binding *last); #endif \ No newline at end of file