Clan Hopping

Bale

Minion
No. I use this script that I modified from something that someone else posted around here somewhere.

Just type clanhop name of my clan

And it will go there. It will work for any clan on your whitelist. It ignores your capitalization.

To enable me to type less it's got fuzzy matching to interpret initials and partial names. (So I can just type clanhop hcn to go to Hardcore Nation.)
 

Attachments

  • clanhop.ash
    3.5 KB · Views: 187
Last edited:

lostcalpolydude

Developer
Staff member
It hits the recruiter page every time you call it, I believe. If it was integrated into mafia, it should probably just load that page when you log on, and maybe have an option to reload the list of possible clans.
 

kain

Member
minor problem ...

Code:
> clanhop The Hogs of Destiny

Attempting hop to clan: The Hogs of Destiny
Attempting hop to clan: The Hogs of Destiny Spade Association
Multiple matches found! Can't hop to a clan unless you can be more precise.
done
 

Bale

Minion
minor problem ...

Code:
> clanhop The Hogs of Destiny

Attempting hop to clan: The Hogs of Destiny
Attempting hop to clan: The Hogs of Destiny Spade Association
Multiple matches found! Can't hop to a clan unless you can be more precise.
done

Interesting problem. I'd suggest that you add logic to test for the more exact match. I'd just make the simple way out that the shorter match is more likely to be correct (and more likely to be a substring) and choose that, while printing a warning that it might be in error so that the user can choose a different name next time.

I've got no real incentive to do this, so I'll let you fix it for yourself. If I ever find myself in a situation where I'm whitelisted in two clans where one is a substring of the other, then I'll worry about it.
 
Last edited:

Bale

Minion
Code:
> clanhop The Hogs of Destiny

Attempting hop to clan: The Hogs of Destiny
Attempting hop to clan: The Hogs of Destiny Spade Association
Multiple matches found! Can't hop to a clan unless you can be more precise.
done
Well, for some odd reason I decided to fix it for you. The script will now automatically match to the shorter string which, at least in this case, will be correct.
 
Last edited:

dawdawdo

Member
It hits the recruiter page every time you call it, I believe. If it was integrated into mafia, it should probably just load that page when you log on, and maybe have an option to reload the list of possible clans.

If it put a dropdown menu on the top pane (like the raidmanager GM script) it would only have to load once (of at least very infrequently) since that top pane does not refresh the way the others do. This would actually be very useful...

/em goes to find out how to request a feature.
 

Bale

Minion
I've seriously updated the script since it was last posted. I noticed that it wasn't working for a clans that I got whitelisted into, so I ended up rewriting a bit while I was at it. In addition to fixing the bug I added a new feature.

Now it will automatically search to see if you entered a clans initials. That means you can enter TCK for The Cereal Killers or HOD for The Hogs of Destiny and it will know what you mean. The regex should work for all clan names, so anything on your whitelist can be accessed by typing only part of the name, or the clan's initials.


Code:
[COLOR="Olive"]> clanhop farewell[/COLOR]

[COLOR="#002080"]You are currently whitelisted by 11 clans[/COLOR]
Matching clan found: Farewell Transmission
[COLOR="#008000"]Welcome to your new clan, Farewell Transmission![/COLOR]

[COLOR="#808000"]> clanhop hcn[/COLOR]

[COLOR="#002080"]You are currently whitelisted by 11 clans[/COLOR]
Matching clan found: Hardcore Nation
[COLOR="#008000"]Welcome to your new clan, Hardcore Nation![/COLOR]

[COLOR="#808000"]> clanhop hardcore[/COLOR]

[COLOR="#002080"]You are currently whitelisted by 11 clans[/COLOR]
Matching clan found: Hardcore Nation
Matching clan found: Hardcore State
[COLOR="Red"]Multiple matches found! Making a guess as to the most precise match.[/COLOR]
[COLOR="#002080"]Attempting hop to clan: Hardcore State[/COLOR]
[COLOR="Green"]Welcome to your new clan, Hardcore State.[/COLOR]

[COLOR="Olive"]> clanhop ft[/COLOR]

[COLOR="#002080"]You are currently whitelisted by 11 clans[/COLOR]
Matching clan found: Farewell Transmission
[COLOR="Green"]Welcome to your new clan, Farewell Transmission![/COLOR]

I'm really very fond of the ability to match to any clan's initials. Incidentally, if there is no match at all, it will tell you the names of every clan on your whitelist so that you can figure out the problem.

 

ereinion

Member
I was trying to incorporate this into a logout-script I am making, but it seems to have some problems with the name of one of the clans I am whitelisted to:
Code:
[COLOR=olive]> ash import <clanhop.ash>;clanhop("'); drop table clans;--")[/COLOR]
[COLOR=#002080]You are currently whitelisted by 22 clans[/COLOR]
[COLOR=red]Invalid pattern syntax (clanhop.ash, line 72)[/COLOR]
Returned: void
Let me know if you want a whitelist to the clan to help with debugging.
 

lostcalpolydude

Developer
Staff member
This script is no longer needed. You can just use cli_execute( "/whitelist drop table clans" ) and let mafia send the chat command unmodified since KoL added that.
 

ereinion

Member
This script is no longer needed. You can just use cli_execute( "/whitelist drop table clans" ) and let mafia send the chat command unmodified since KoL added that.
Yeah, I know about the chat command being executable from the cli, but I was a bit concerned about there being a small time-delay between entering a chat command and the command taking effect in KoL? I'm not sure if this actually is an issue, though, but since I am planning on doing a bit of stashing after the clanhopping I wanted to make absolutely sure I was in the correct clan when the next command was executed.
LoL! Your clan was named after Bobby Tables? Yeah, please give me a whitelist so I can try it out. :)
Little Bobby Tables indeed. It looks like Jick sanitizes his database inputs :-D Anyway, you've been given a whitelist :)
 

lostcalpolydude

Developer
Staff member
I believe it's completely safe to expect mafia to do stuff in the correct order there. However, you can check my_clan() to protect against both mafia and KoL weirdness.
 

ereinion

Member
Both ashq print(my_clan()) and ashq import <clanhop.ash>;print(my_clan()) fails with the message "Function 'my_clan( )' undefined. This script may require a more recent version of KoLmafia and/or its supporting scripts. ()" (I can't find it on the wiki either).

I do of course have this function in my script, which I think would do the trick, but if mafia already has the function implemented, that is probably more efficient :)
Code:
string findClanname() {
    string htmlFromClan;
    string pattern;
    boolean[item] itemsToReturn;
    matcher currentClan;
    
    htmlFromClan = visit_url("town_clan.php");
    pattern = "(?<=<center><b>)[\\w\\s\\p{P}]+(?=<\\/b>)";
    currentClan = create_matcher(pattern, htmlFromClan);
    
    if (currentClan.find()) {
        return currentClan.group(0);
    } else {
        exit;
    }
}
 

lostcalpolydude

Developer
Staff member
Now that I'm actually checking, ashref clan tells me that get_clan_id() and get_clan_name() are two functions to choose from.
 

Crowther

Active member
This script cuts off clan names that use characters outside a limited set (A-z ') which didn't really matter much to me, even though I'm in a clan with digits in the name. However, suddenly it mattered to me, so I fixed that by changing this line a little. . .

Code:
        return  group_string(clans_raw, "option value=([0-9]+)>(.+?)<");
Hopefully that doesn't let Bobby Tables do his thing.
 
Top