Help - Search - Members - Calendar
Full Version: .apply and .recruit combined
StealthBot.net > StealthBot > Scripting and Plugins > Plugin Projects
The-Black-Ninja
CLICK HERE FOR THE FINISHED PLUGIN


I'm going to be making a sophisticated plugin that combines the .apply plugin idea and the recruit plugin. What it will do is:
  • Allow the enabling of applying by level, icon, %, etc.
  • Changing the criteria for the aspects above on-the-fly
  • If your clanmates "recruit" someone, the option will be there to check the potential recruit for any of the options previously listed
Since I don't own a ladder clan, I need a little advice. The part I'm stuck on is this:

If you set the icon wins level (25, 150, etc.), do you even need the other option to set by overall wins alone? Any other input would be greatly appreciated as I'm doing it for you guys smile.gif

Edit: Added a link to finished plugin and closed topic. -PhiX
Hero.A
That would be really sexy! I would help a tinee bit
The-Black-Ninja
Sweet, there's gonna be lots of testing required cause I'm going to have all kinds of checks to make sure you don't set stuff that condradicts other things.
1ruleyou
I like the idea and im still working on learning VBS i can make simple scripts but if you need anything done or tested im willing to help. Just give me an assignment i guess.
The-Black-Ninja
Okay great, well like I said before, I have no idea how these clans invite people. As I have it right now, here's how I have it:
  • Join By Icon on/off
  • Icon Race (can be Null for no preference)
  • Icon Needed (0 wins, 25 wins, 150 wins, etc.)
  • Include tournament icon yes/no
  • Tournament Icon needed (0 wins, 10 wins, etc.)
  • Join By Wins on/off
  • Wins Needed (will be read off battle.net)
  • Join by Percent on/off
  • Percent needed (will be read off battle.net)
  • Join by Level on/off
  • Level Needed (will be read off battle.net)
These are just the requirements. Is there anything to be added/removed?
Akiri
For DotA its like...

Competitive Play?
->League Play
->Inhouse Play
TDA Safelisted? (Icon/DA Forums)
Prior Clans

The-Black-Ninja
Interesting. Could you explain those a bit more?
HearthCore
He didnt get the script idea..

Akiri, its for LADDER Clans not for DotA !
it gets its information from the battle.net homepage and the status You, as an entering person, have.

DotA things are recorded nowhere!
The-Black-Ninja
Massive headway:
  • I've done away with icons for now since people I've talked to are too confused by the theory; they've suggested I just get rid of icons altogether since wins generally means an icon.
  • The tournament stuff I haven't found on BNet's website, so that's out.
Next question:

What should I do about percent needed? Battle.Net has the percent to two decimals. If you want 50% for a requirement and the person has 49.97%, what should be done? Do I include some +/- a few percent or...?
#define
QUOTE(The-Black-Ninja @ Apr 19 2008, 12:19 AM) *

What should I do about percent needed? Battle.Net has the percent to two decimals. If you want 50% for a requirement and the person has 49.97%, what should be done? Do I include some +/- a few percent or...?

I would suggest taking the ceiling of the wins needed if you don't like decimal value for wins. So a player having 49.97% would need 1 win to get 50%. Ceiling means you always round up to the nearest whole number, never rounding down. 10.01 would be 11 for example.
But really it's completely a preference thing. Since it is impossible to obtain a fraction of a win and rounding down would result in a value < 50%... taking the ceiling seems the best option to me.
The-Black-Ninja
QUOTE(#define @ Apr 19 2008, 02:30 AM) *

I would suggest taking the ceiling of the wins needed if you don't like decimal value for wins. So a player having 49.97% would need 1 win to get 50%. Ceiling means you always round up to the nearest whole number, never rounding down. 10.01 would be 11 for example.
But really it's completely a preference thing. Since it is impossible to obtain a fraction of a win and rounding down would result in a value < 50%... taking the ceiling seems the best option to me.

I like that idea too. I was thinking it would be taken into effect when the requirement is, say 50% again, and the user has less than or equal to half a percent below, ie. 49.50% and upwards.
Hero.A
Thats not ceiling ninja. Thats just plain old CInt - Rounding
Pyro
QUOTE(Hero.A @ Apr 17 2008, 06:24 PM) *
That would be really sexy! I would help a tinee bit
You should fulfill prior commitments before taking on new ones.
Fusic
I can help mate smile.gif

Learned lots more since we talked.
ZaMaK
When will this be finished? Or is it?
The-Black-Ninja
@Zamak: Probably will be finished by the end of the week, there's not much left to do.

@Fusic: Great. I'll post what I get done tonight on here before I go to bed. Have a look through and see if there's anything that needs adding or tweaking smile.gif
ZaMaK
Awesome. I'm really looking forward for this plugin =)
The-Black-Ninja
Well, since no one's offered any input, here it is. Any bug or suggestions, post em. If I don't hear back, it's getting posted in the Scripting and Plugins forum as is.

This was done in Notepad++ so I had to put this back into Notepad and take out the ridiculous tabs. It looks kinda messy, but try to look past that laugh.gif

The script can be found here:
http://ninja.pastebin.com/m4a21def5

Look for the "download" link near the top of the script. Click and, click "Open" at the pop-up, and it should go right into Notepad or Word or whatever text editor you use.

That code will be up for roughly around a month, after which I will have to re-post it, so I would appreciate some feedback before then. Just some simple stuff, you don't actually HAVE to invite users, just like test out the commands, see what does what, look through it, etc.
Hero.A
Tested it some.

To Fix:
I can apply from in bot tongue.gif
On Inbot command use. it does not VetoThisMessage
-- [05:50:43 PM] You have been placed on the Recruit waiting list. Clan ABC will contact you ASAP.
-- [05:50:43 PM] That is not a valid command. Type /help or /? for more info.
I'll put more here as I go
The-Black-Ninja
Okay, I'll look into that. Thanks smile.gif

Fixed.
Fusic
You can't use inbot commands for things like "Delrecruit, Clear, AddRecruit, Rec"

Here is the code with that VetoThisMessage Working.


CODE
'recruit
'1.0
'&RecruitAndApply:The-Black-Ninja
'&rec autoinvite on/off:rec wins on/off:rec percent on/off:rec level on/off:rec setwins #:rec setpercent#.##:rec setlevel #:apply:read:delrecruit <user>:clear:addrecruit <user>
'&
'&The delrecruit command can also be used like this for multiple user removals; .delrecruit user1, user2, user3:If you see, in the ini file, "True" or "Ignored"; True = has been recruited successfully, Ignored = More than one attempt has been made to put the user on the recruit list, so the bot will ignore further attempts to prevent flooding.


'/***************
'* Commands *
'* *
'*************** /
Const recruit_admincmd = "rec" '// Command needed to initiate requirement settings
Const recruit_apply_cmd = "apply" '// Command for users to apply
Const recruit_read = "read" '// Command to read recruits on the list
Const recruit_remrecruit = "delrecruit" '// Command to delete recruits from the list
Const recruit_clear = "clear" '// Command to remove all recruits from the list
Const recruit_add = "addrecruit" '// Command to add recruits to the list - Clan members only

Const recruit_enableAutoInvite = "autoinvite" '// Command to enable/disable automatic invites upon passing requrement test. Followed by "on/off"
Const recruit_enableWins = "wins" '// Command to enable/disable win amount requrement test. Followed by "on/off"
Const recruit_enablepercent = "percent" '// Command to enable/disable win percent amount requrement test. Followed by "on/off"
Const recruit_enablelevel = "level" '// Command to enable/disable level requrement test. Followed by "on/off"

Const recruit_setWins = "setwins" '// Command to adjust win amount requrement. Followed by an integer
Const recruit_setpercent = "setpercent" '// Command to adjust win percent amount requrement. Followed by an integer
Const recruit_setlevel = "setlevel" '// Command to adjust level amount requrement. Followed by an integer


'/**************************
'* Settings and Access *
'* *
'**************************/
recruit_Path = BotPath & "plugins\recruit_List.ini" '// Holds the path to save the recruit list. Must be an ini file.
Const recruit_realm = "Azeroth" '// Your Realm
Const recruit_ClanTag = "ABC" '// Your Clan Tag

Const recruit_adminAccess = 50 '// Access for adjusting all requirements
Const recruit_adminFlags = "" '// Flags for adjusting all requirements

Const recruit_readAccess = 50 '// Access for reading recruit list
Const recruit_readFlags = "" '// Flags for reading recruit list

Const recruit_remAccess = 50 '// Access for removing a recruit from the list
Const recruit_remFlags = "" '// Flags for removing a recruit from the list

Const recruit_addAccess = 50 '// Access for adding a recruit to the list
Const recruit_addFlags = "" '// Flags for adding a recruit to the list

Const recruit_clearAccess = 500 '// Access for removing all recruits from the list
Const recruit_clearFlags = "" '// Flags for removing all recruits from the list

Const recruit_canInviteAccess = 60 '// Access for users who can Invite through the bot or through battle.net (ie. Shamans)
Const recruit_canInviteFlags = "" '// Flags for users who can Invite through the bot or through battle.net (ie. Shamans)



'/***********************
'* Code Begins Here *
'* *
'************************/

Public recruit_inUse, recruit_wins, recruit_level, recruit_percent
Set recruitFSO = CreateObject("Scripting.FileSystemObject")


Sub recruit_Event_Load()

SetSetting "recruit", "EnableAutoInvite", False, "False: if they pass, they will be placed in the Recruit List. True: if they pass, bot will auto-invite users.", False
SetSetting "recruit", "ApplyModeEnabled", False, "False: users will be placed directly in the Recruit List. True: bot will auto-detect requirements first.", False

SetSetting "recruit", "JoinByWins", False, "Is a Win amount required to join?", False
SetSetting "recruit", "WinsNeeded", "50", "How many wins?", False

SetSetting "recruit", "JoinByPercent", False, "Is a Win % required to join?", False
SetSetting "recruit", "PercentNeeded", "50", "What percentage?", False

SetSetting "recruit", "JoinByLevel", False, "Is a Level required to join?", False
SetSetting "recruit", "LevelNeeded", "10", "What Level?", False

If NOT recruitFSO.FileExists(recruit_Path) Then
Set File = recruitFSO.OpenTextFile(recruit_Path, 8, True)
File.WriteLine "[Recruits]"
File.Close
End If

recruit_inUse = False
End Sub


Sub recruit_Event_Userjoins(Username, Flags, Message, Ping, Product, Level, OriginalStatString, Banned)

GetDBEntry Username, myAccess, myFlags
If myAccess < recruit_canInviteAccess OR NOT InStr(LCase(myFlags), LCase(recruit_canInviteFlags)) Then Exit Sub
Set File = recruitFSO.OpenTextFile(recruit_Path, 1, True)
If File.AtEndOfStream Then
File.Close
Exit Sub
Else
content = Split(File.ReadAll, vb script:. Users must have X ladder wins to join.", Username, vb script:. Users do not need ladder wins to join.", Username, vb script:. Users must have X% to join.", Username, vb script:. Users do not need a percent to join.", Username, vb script:. Users must be at or above X Level to join.", Username, vb script:. Users do not need a Level to join.", Username, vb script:. Users will be automatically invited if they pass.", Username, vb script:. Users will be placed on the waiting list if they pass.", Username, vb script:. Ladder wins set to: " & arrCmd(2) & ".", Username, vb script:. Win % set to: " & arrCmd(2) & ".", Username, vb script:. Level set to: " & arrCmd(2) & ".", Username, vbOrange
End If
Else
Dsp dspId, ".:Recruit Script Error:. Level must be a valid integer.", Username, vbRed
Exit Sub
End If
End If
Else
Dsp dspId, ".:Recruit Script Syntax Error:. You did not specify an integer.", Username, vbRed
Exit Sub
End If
End If
End Select
End If

ElseIf arrCmd(0) = recruit_apply_cmd Then
If recruit_inUse Then
Dsp dspId, "Please wait. A user is already being validated...", Username, vbRed
Exit Sub
Else
If LCase(GetInternalDataByUsername(Username, 0)) <> vbNullString Then
Dsp dspId, Username & ", you must leave Clan " & GetInternalDataByUsername(Username, 0) & " before applying.", Username, vbRed
Exit Sub
ElseIf LCase(GetInternalDataByUsername(Username, 0)) = LCase(recruit_ClanTag) Then
Exit Sub
End If

If GetConfigEntry("Recruits", Username, recruit_Path) = "True" Then
Dsp dspId, Username & ", you are already on the Recruit waiting list. Please be patient...", Username, vbRed
WriteConfigEntry "Recruits", Username, "Ignored", recruit_Path
ElseIf GetConfigEntry("Recruits", Username, recruit_Path) = "Ignored" Then
Exit Sub
End If

If GetSetting("recruit", "ApplyModeEnabled") Then
If SciNet.StillExecuting Then
Dsp dspId, "The Bot is in use. Please try again in a few moments.", Username, vbRed
recruit_inUse = False
Exit Sub
End If

recruit_inUse = True
acceptGlobal = False
acceptWins = False
acceptLevel = False
acceptPercent = False
deny = False
denyMsg = vbNullString
acceptMsg = vbNullString
If GetConfigEntry("Recruits", Username, recruit_Path) = vbNullString Then
If GetSetting("recruit", "JoinByWins") Then
recruit_GetWins GetInternalDataByUsername(Username, 3), recruit_Realm, Username, dspId
If CInt(recruit_wins) < CInt(GetSetting("recruit", "WinsNeeded")) Then
denyMsg = denyMsg & "Your Wins (" & recruit_wins & ") must be equal to or greater than " & GetSetting("recruit", "WinsNeeded") & ", "
deny = True
Else
accept = True
End If
End If

If GetSetting("recruit", "JoinByPercent") Then
recruit_GetPercent GetInternalDataByUsername(Username, 3), recruit_Realm, Username, dspId
If CInt(recruit_percent) < CInt(GetSetting("recruit", "PercentNeeded")) Then
denyMsg = denyMsg & "Your Percent (" & recruit_percent & ") must be equal to or greater than " & GetSetting("recruit", "PercentNeeded") & ", "
deny = True
Else
accept = True
End If
End If

If GetSetting("recruit", "JoinByLevel") Then
recruit_GetLevel GetInternalDataByUsername(Username, 3), recruit_Realm, Username, dspId
If CInt(recruit_level) < CInt(GetSetting("recruit", "LevelNeeded")) Then
denyMsg = denyMsg & "Your Level (" & recruit_level & ") must be equal to or greater than " & GetSetting("recruit", "LevelNeeded") & ", "
deny = True
Else
accept = True
End If
End If

If deny Then
Dsp dspId, Left(denyMsg, Len(denyMsg) - 2) & ".", Username, vbGreen
recruit_inUse = False
Exit Sub
End If

If accept Then
If acceptPercent Then acceptMsg = acceptMsg & "Percent (" & recruit_percent & ") accepted, "
If acceptLevel Then acceptMsg = acceptMsg & "Level (" & recruit_level & ") accepted, "
If acceptWins Then acceptMsg = acceptMsg & "Wins (" & recruit_wins & ") accepted, "
If GetSetting("recruit", "EnableAutoInvite") Then
Dsp dspId, Left(acceptMsg, Len(acceptMsg) - 2) & ". Auto-inviting " & Username & "...", Username, vbGreen
If Username = BotVars.Username And Left(Message, 1) = "/" Then VetoThisMessage
Command BotVars.Trigger, "/invite " & Username, True
Else
Dsp dspId, Left(acceptMsg, Len(acceptMsg) - 2) & ". You have been placed on the Recruit waiting list. Clan " & recruit_ClanTag & " will contact you ASAP.", Username, vbGreen
WriteConfigEntry "Recruits", Username, "True", recruit_Path
End If
End If
End If
Else
Dsp dspId, "You have been placed on the Recruit waiting list. Clan " & recruit_ClanTag & " will contact you ASAP.", Username, vbGreen
WriteConfigEntry "Recruits", Username, "True", recruit_Path
End If
End If


ElseIf arrCmd(0) = recruit_read Then

If Username = BotVars.Username And Left(Message, 1) = "/" Then VetoThisMessage
If myAccess < recruit_readAccess OR NOT InStr(LCase(myFlags), LCase(recruit_readFlags)) And Username <> BotVars.Username Then Exit Sub
Set File = recruitFSO.OpenTextFile(recruit_Path, 1, True)
If File.AtEndOfStream Then
File.Close
Dsp dspId, "There are no recruits waiting for approval.", Username, vbGreen
Exit Sub
End If
content = Split(File.ReadAll, vbCrLf)
File.Close
x = 0
For i = 0 To UBound(content) - 1
x = x + 1
If InStr(content, "=") Then output = output & x & ". " & Split(content(i), "=")(0) & ", "
Next
If x = 1 Then
Dsp dspId, "There are no recruits waiting for approval.", Username, vbGreen
Else
Dsp dspId, "Recruits on the waiting list:", Username, vbGreen
Dsp dspId, Left(output, Len(output) - 2), Username, vbGreen
End If


ElseIf arrCmd(0) = recruit_remrecruit Then

If Username = BotVars.Username And Left(Message, 1) = "/" Then VetoThisMessage
If myAccess < recruit_remAccess OR NOT InStr(LCase(myFlags), LCase(recruit_remFlags)) And Username <> BotVars.Username Then Exit Sub
If UBound(arrCmd) < 1 Then
Dsp dspId, "Proper format: " & BotVars.Trigger & recruit_remrecruit & " " & Username, Username, vbGreen
Else
If InStr(arrCmd(1), ", ") Then
users = Split(arrCmd(1), ", ")
For i = 0 To UBound(users) - 1
WriteConfigEntry "Recruits", users(i), vbNullString, recruit_Path
Next
Dsp dspId, "Users have been removed from the Recruit List.", Username, vbGreen
Else
WriteConfigEntry "Recruits", arrCmd(1), vbNullString, recruit_Path
Dsp dspId, arrCmd(1) & " has been removed from the Recruit List.", Username, vbGreen
End If
End If


ElseIf arrCmd(0) = recruit_add Then

If Username = BotVars.Username And Left(Message, 1) = "/" Then VetoThisMessage
If myAccess < recruit_addAccess OR NOT InStr(LCase(myFlags), LCase(recruit_addFlags)) And Username <> BotVars.Username Then Exit Sub
If UBound(arrCmd) < 1 Then
Dsp dspId, "Proper format: " & BotVars.Trigger & recruit_add & " " & Username, Username, vbGreen
Else
If LCase(GetInternalDataByUsenrame) <> LCase(recruit_ClanTag) Then Exit Sub
If GetConfigEntry("Recruits", arrCmd(1), recruit_Path) = "True" Then
Dsp dspId, arrCmd(1) & ", is already on the Recruit waiting list. Please be patient...", Username, vbRed
WriteConfigEntry "Recruits", arrCmd(1), "Ignored", recruit_Path
Exit Sub
ElseIf GetConfigEntry("Recruits", arrCmd(1), recruit_Path) = "Ignored" Then
Exit Sub
End If
WriteConfigEntry "Recruits", arrCmd(1), "True", recruit_Path
Dsp dspId, arrCmd(1) & " has been added to the Recruit List.", Username, vbGreen
End If


ElseIf arrCmd(0) = recruit_clear Then

If Username = BotVars.Username And Left(Message, 1) = "/" Then VetoThisMessage
If myAccess < recruit_clearAccess OR NOT InStr(LCase(myFlags), LCase(recruit_clearFlags)) And Username <> BotVars.Username Then Exit Sub
If recruitFSO.FileExists(recruit_Path) Then recruitFSO.DeleteFile(recruit_Path)
Dsp dspId, "Recruit list has been cleared.", Username, vbGreen
Set File = recruitFSO.OpenTextFile(recruit_Path, 8, True)
File.WriteLine "[Recruits]"
File.Close
End If
End Sub



Public Function recruit_GetWins(rwinsProd, rwinsRealm, rwinsUser, htr)

content = SciNet.OpenURL("http://www.battle.net/war3/ladder/" & rwinsProd & "-player-profile.aspx?Gateway=" & rwinsRealm & "&PlayerName=" & rwinsUser)
data = Split(Split(content, ">Total:<")(1), "</TR>")(0)
data = Split(data, vbNewLine)
For i = 1 To 1
rWins = data(i)
Next
rWins = Split(Split(rWins, """>")(1), "<")(0)
recruit_wins = rWins
End Function


Public Function recruit_GetPercent(rprcntProd, rprcntRealm, rprcntUser, htr)

content = SciNet.OpenURL("http://www.battle.net/war3/ladder/" & rprcntProd & "-player-profile.aspx?Gateway=" & rprcntRealm & "&PlayerName=" & rprcntUser)
data = Split(Split(content, ">Total:<")(1), "</TR>")(0)
data = Split(data, vbNewLine)
For i = 3 To 3
rPrcnt = data(i)
Next
rPrcnt = Split(Split(rPrcnt, """>")(1), "<")(0)
rPrcnt = Replace(rPrcnt, "%", vbNullString)
recruit_percent = rPrcnt
End Function


Public Function recruit_GetLevel(rlvlProd, rlvlRealm, rlvlUser, htr)

sString = StrReverse(GetInternalDataByUsername(rlvlUser, 5))
recruit_level = Split(sString, " ")(1)
End Function
The-Black-Ninja
...Why did you just do that? You're not supposed to even be able to use it inbot.

That's why I replied back with "Fixed."
Fusic
Do what? I didn't add those commands.

I fixed the Bnet message Hero was getting?

Message me on MSN.
The-Black-Ninja
QUOTE(Fusic @ Apr 20 2008, 07:26 PM) *

I fixed the Bnet message Hero was getting?

I've already fixed that message.
QUOTE(Fusic @ Apr 20 2008, 07:26 PM) *

Message me on MSN.

This is called group projects for a reason tongue.gif
Fusic
Oh didn't see you edited it to the main post so I just posted my code that I tested right quick smile.gif
ZaMaK
Is this ready?
( i just read there were problems in above comments)
Post the fixed code when it is =)
The-Black-Ninja
QUOTE(ZaMaK @ Apr 20 2008, 07:37 PM) *

Is this ready?
( i just read there were problems in above comments)
Post the fixed code when it is =)

Why don't you use it and see if you can find any bugs or problems? wink.gif

Well, if no one has anything to say about it, I'm going to put this in Scripting and Plugins.
riffruff
As a coding suggestion...

I would suggest making a sub for every command...This makes editing the script easier, as all you have to do is modify a sub and don't have to worry about messing something up...It also cleans the code up a bit -- having command processing in one location, and having command performance in another location...

This makes it easier to add new commands, and to edit exist commands...
The-Black-Ninja
Thanks Riff, I'll work on this for the next update/release.
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2019 Invision Power Services, Inc.