Help with clan application blacklisting

HasteBro

Member
I'm trying to modify MrEdge73's AcceptApplications function to include a blacklist, but I can't get it to work.

I got the adding/removing names part working just fine, but it won't do anything when I test it with the application function.

The BlackList map is the username and userid, like this:
Code:
HasteBro 930575

Here's what I tried:
PHP:
string appl(boolean ProcessAll)
	{
		string[string]BlackList;
		file_to_map("BlackList.txt", BlackList);
		
		string outstring="";
		matcher APPCHECK = create_matcher("y <b>(\\d+)</b> p", visit_url("clan_office.php"));
						
		if(APPCHECK.find())
		{
			outstring="There are "+APPCHECK.group( 1 )+" new member applications.<br />";
			
			if (ProcessAll==true)
			{
				int dudes = 0;
				matcher Applicants = create_matcher("who=(\\d+)\">(.+?)<", visit_url(clan_applications.php));
#"
				while (Applicants.find())
				{
					foreach i in blacklist
					{
						if( BlackList[i] == Applicants.group( 1 ) )
						{
							visit_url("clan_applications.php?request"+Applicants.group( 1 )+"=2&action=process");
							outstring = outstring+""+ i +" ("+ BlackList[i] +") was rejected due to being on the blacklist. <br />";
						}

						else
						{
							visit_url("clan_applications.php?request"+Applicants.group( 1 )+"=1&action=process");
							outstring = outstring+"Accepted "+Applicants.group( 2 )+" into the clan! <br />";
							dudes = dudes+1;
						}
					}
				}
				outstring = outstring+"HastyBuffer welcomed "+to_string(dudes)+" new member(s)! <br />";
			}
		}
		
		else
			outstring="There are no new member applications <br />";
		
		
		outstring="<FONT color=#365f91>"+outstring+"</FONT><br />";
		
		return outstring;
	}

Even if the person is listed in the BlackList, he gets accepted into the clan. I can't see what I'm doing wrong here.
 

Theraze

Active member
Are you comparing a string to an int? You load your map as a string, but your matcher appears to be set to look for an int and probably returns one...
 

HasteBro

Member
According to the wiki group() returns a string, not an int. But I tried it anyway: "Cannot apply operator == to BlackList[] (int) and group() (string)"
 

Quertle

New member
So why not make line 22:
Code:
if( to_int( BlackList[i] ) == to_int( Applicants.group( 1 ) ) )

Also, be aware that
Code:
visit_url(clan_applications.php));
should read
Code:
visit_url("clan_applications.php"));
 

Theraze

Active member
Okay then. How about this:
Code:
                while (Applicants.find()) 
                { 
                    boolean blacklisted = false;
                    foreach i in BlackList 
                    { 
                        if( BlackList[i] == Applicants.group( 1 ) ) 
                        { 
                            visit_url("clan_applications.php?request"+Applicants.group( 1 )+"=2&action=process"); 
                            outstring = outstring+""+ i +" ("+ BlackList[i] +") was rejected due to being on the blacklist. <br />"; 
                            blacklisted = true;
                        } 
                    } 
                    if (!blacklisted)
                    { 
                        visit_url("clan_applications.php?request"+Applicants.group( 1 )+"=1&action=process"); 
                        outstring = outstring+"Accepted "+Applicants.group( 2 )+" into the clan! <br />"; 
                        dudes = dudes+1; 
                    } 
                }
Basically, your blacklist check will try to add them to the clan if there is ANY non-matching entry. Which may or may not join them to the clan or process on the proper applicant. What you want to do instead is check through your blacklist check and if it matches, note that you won't want to keep them around.

Edit:
The other thing I'd suggest is throwing in a check for what your blacklist is actually coming out as.
ashq string[string]BlackList; file_to_map("BlackList.txt", BlackList); foreach i in BlackList print_html(i+" is "+BlackList);

And... there we are. You define your blacklist as BlackList and then do your foreach i in blacklist. blacklist != BlackList.
 
Last edited:

HasteBro

Member
Ok, got the rejecting applicants who are in the list working, but now accepting doesn't happen at all if the code for accepting is inside the foreach loop. The only downside for having the code outside the loop is that if someone is rejected, it will print that the person was rejected then accepted (results in him being only rejected), so it's not much of a problem.

Edit: wow, I totally didn't notice it was outside in your code, theraze, sorry about that XP
 
Last edited:
Top