This is the new home of the egghelp.org community forum.
All data has been migrated (including user logins/passwords) to a new phpBB version.


For more information, see this announcement post. Click the X in the top right-corner of this box to dismiss this message.

User Flag Checking

Discussion of Eggdrop's code and module programming in C.
Post Reply
G
Galadhrim
Op
Posts: 123
Joined: Fri Apr 11, 2003 8:38 am
Location: Netherlands, Enschede

User Flag Checking

Post by Galadhrim »

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... :cry:
G
Galadhrim
Op
Posts: 123
Joined: Fri Apr 11, 2003 8:38 am
Location: Netherlands, Enschede

Post by Galadhrim »

*bump* :D

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: Select all

/*
 * 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: Select all

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: Select all

 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 :shock: 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 :cry:
G
Galadhrim
Op
Posts: 123
Joined: Fri Apr 11, 2003 8:38 am
Location: Netherlands, Enschede

Post by Galadhrim »

Yay I found it by accident :D :D :D

Code: Select all

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.
Post Reply