egghelp.org community Forum Index
[ egghelp.org home | forum home ]
egghelp.org community
Discussion of eggdrop bots, shell accounts and tcl scripts.
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Mod Function Arguments

 
Post new topic   Reply to topic    egghelp.org community Forum Index -> Modules & Programming
View previous topic :: View next topic  
Author Message
rrc55
Voice


Joined: 11 Mar 2009
Posts: 29

PostPosted: Sat Jan 23, 2010 8:22 pm    Post subject: Mod Function Arguments Reply with quote

Hi noob here working on my first mod.

I can kind of see how commands are added to the bind table but how does eggdrop know what arguments to pass to my functions when the command is issued?

Thanks.
Back to top
View user's profile Send private message
nml375
Revered One


Joined: 04 Aug 2006
Posts: 2857

PostPosted: Sun Jan 24, 2010 10:40 am    Post subject: Reply with quote

If you are referring to the different bindings, each type of binding has a specific set of arguments that the called C function is expected to accept. All in all, very much alike the normal bind command.

Perhaps an example taken from the channels module, the .+chan dcc chat command:
Code:
/* The actual C function that will be mapped to the tcl namespace
 * Compared to the tcl "bind dcc", having "handle idx text" as arguments
 */
static void cmd_pls_chan(struct userrec *u, int idx, char *par)
{
  char *chname;
  struct chanset_t *chan;
...
}

/* Now to map the function into a dcc partyline command
 * DCC CHAT COMMANDS
 *
 * Function call should be:
 *    int cmd_whatever(idx,"parameters");
 *
 * NOTE: As with msg commands, the function is responsible for any logging.
 */
static cmd_t C_dcc_irc[] = {
...
  {"+chan",    "n",     (Function) cmd_pls_chan,   NULL},
...
  {NULL,       NULL,    NULL,                      NULL}
};


The C_dcc_irc array is then used with add_builtins and del_builtins, which is then responsible for creating the tcl command and mapping it to your function, and register the proper binding.

There are many kinds of "builtins", and each one has it's own setup of expected argument list, so you'll have to check/dig through the code to see what's needed for your kind of command/binding/builtin
_________________
NML_375, idling at #eggdrop@IrcNET
Back to top
View user's profile Send private message
rrc55
Voice


Joined: 11 Mar 2009
Posts: 29

PostPosted: Mon Jan 25, 2010 11:39 pm    Post subject: Reply with quote

Got it thanks.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    egghelp.org community Forum Index -> Modules & Programming All times are GMT - 4 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Forum hosting provided by Reverse.net

Powered by phpBB © 2001, 2005 phpBB Group
subGreen style by ktauber