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 

User Flag Checking

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


Joined: 11 Apr 2003
Posts: 123
Location: Netherlands, Enschede

PostPosted: Fri Oct 29, 2004 3:00 pm    Post subject: User Flag Checking Reply with quote

I've been looking all over the source files and website but I cant seem to find a number of functions that will alow me to directly or indirectly check for a flag. I've found all sorts of functions that do a little or less.

I want users that have the flag +W to allow to use certain commands. All the function should do is return false or true. But when I use some functions the compiler can't find the struct or function. Adding the according .h file to my module will results in more errors...

Does anyone have a used bit of code that I can use or does someone have ideas as to which functions I have to use?

Most functions are small and need the help of 100 other functions. Can't believe I can't find a function that lets developers check for a flag. My general opinion is that the eggdrop is created in a rush and the support for third party modules has been hacked into it by other people... Crying or Very sad
Back to top
View user's profile Send private message
Galadhrim
Op


Joined: 11 Apr 2003
Posts: 123
Location: Netherlands, Enschede

PostPosted: Mon Apr 18, 2005 9:41 am    Post subject: Reply with quote

*bump* Very Happy

After giving up last October I've found some time to go through alot of code and found the corresponding structs and function that allow you to look for the required flags.

Code:

/*
 * The user record. You can find this using get_user_by_handle(userlist, text);
 * Neither variables have to be malloc'ed before hand. The variable userlist is global and already filled by the bot.
 */
struct userrec {
   struct userrec *next;
   char handle[HANDLEN + 1];
   unsigned long flags;
   unsigned long flags_udef;
   struct chanuserrec *chanrec;
   struct user_entry *entries;
};

/*
 * The user record of a channel. You can access this via the struct member variable *chanrec.
 */
struct chanuserrec {
   struct chanuserrec *next;
   char channel[81];
   time_t laston;
   unsigned long flags;
   unsigned long flags_udef;
   char *info;
};

/*
 * The flag record of a user. You can find this using getget_user_flagrec(u, fr, u->handle);
 * Neither variables have to be malloc'ed before hand.
 */      
struct flag_record {
   int match;
   int global;
   int udef_global;
   int bot;
   int chan;
   int udef_chan;
};


Now the only thing I can't seem to find is how to check for the user flags A-Z. According to the code they are available for programmers to use, but I cannot find anything to check for them. There is a function called bread_down_flags(), but I have no idea how to use it.

When I print the flags in IRC for my admin user (afghjlmnoptvwxW) i get these numbers. I can check them with the preset hex values and see if I'm global op or master, but again not the user definable flags:

Code:
dprintf(DP_SERVER, "privmsg %s : flag_record: match: %i; global: %i; udef_global: %i; bot: %i; chan: %i; udef_chan: %i;\r\n", chan, fr->match, fr->global, fr->udef_global, fr->bot, fr->chan, fr->udef_chan);

gives:
Code:
 flag_record: match: 134938216; global: 0; udef_global: 0; bot: 0; chan: 135003104; udef_chan: 135001216;


Silly thing is that the variable global is empty but the match is filled. The match variable is the global value Shocked I have no idea what the chan variable is for but I never use channel flags so that ok for me.

Is there anyone who knows what to look for? I can try and use the empty flags I and S but those might be used in later versions. I just want to use the flags W and V Crying or Very sad
Back to top
View user's profile Send private message
Galadhrim
Op


Joined: 11 Apr 2003
Posts: 123
Location: Netherlands, Enschede

PostPosted: Mon Apr 18, 2005 10:17 am    Post subject: Reply with quote

Yay I found it by accident Very Happy Very Happy Very Happy

Code:

if( strlen(u->handle)>0){
         struct flag_record fr = { FR_GLOBAL, 0, 0, 0, 0, 0 };
             char x[100];

             fr.global = u->flags;
         fr.udef_global = u->flags_udef;
             build_flags(x, &fr, 0);
             
         dprintf(DP_SERVER, "privmsg %s : User %s :\r\n", chan, u->handle);
         dprintf(DP_SERVER, "privmsg %s :  flags: %s;\r\n", chan, x);
      
         if(strstr(x, "S") != NULL) dprintf(DP_SERVER, "privmsg %s : %s  has flag S\r\n", chan, u->handle);
         if(strstr(x, "I") != NULL) dprintf(DP_SERVER, "privmsg %s : %s has flag I\r\n", chan, u->handle);
             
      }


So when you set the global flags for the user in the partyline you can use this to check for flags.
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