Valhalla Legends Forums Archive | Battle.net Bot Development | Simple Banning

AuthorMessageTime
BorT
How would I ban a User?

Ex: the user types !b Bort Sucker!
How would I make that ban Bort and post the message "Sucker!" after?

Thanks agian,
Bort
March 4, 2004, 3:30 AM
Lenny
You react to the "!b Bort Sucker!" by sending "/ban" + Username + " Sucker!"
March 4, 2004, 3:33 AM
Eli_1
[quote]
You react to the "!b Bort Sucker!" by sending "/ban" + Username + " Sucker!"
[/quote]

well, in the most simple way I can think...
[code]
if left(lcase(message), 3) = trigger & "b " and len(message) > 3 then
CSB.send "/ban " & right(message, len(message) - 3)
end if
[/code]
March 4, 2004, 3:44 AM
BorT
Thanks Eli, and Lenny.
March 5, 2004, 12:21 AM
Myndfyr
[quote author=BorT link=board=17;threadid=5580;start=0#msg47522 date=1078446060]
Thanks Eli, and Lenny.
[/quote]

Do you know why Eli's code works how it does?

[code]
if left(lcase(message), 3) = trigger & "b " and len(message) > 3 then
CSB.send "/ban " & right(message, len(message) - 3)
end if
[/code]

Break it down expression by expression:

lcase(string) returns the lowercase version of the expression. If it was !B, then the expression would be !b.

left(string, integer) returns at most integer number of characters of string from the left side of the string. So if your string message is:
"!b Bort Sucker!"
then left("!b Bort Sucker!", 3) would return "!b ".

Combining the left and lcase functions (or are the operators? I'm not a VB programmer; I know they turn blue, but w/e), your example expression becomes:

left(lcase("!b Bort Sucker!", 3))

which returns "!b ".

Assuming "trigger" is defined elsewhere as "!". your left Boolean expression returns true; "!b " equals "!" & "b ".

The right Boolean expresion, len(message) > 3, uses the Len (Length) operator. Len(string) returns an integer telling you how long the string is. The reason you want to do this is, in case you have a malformed command, such as:

!b

the bot doesn't respond. When it's greater than 3, the bot uses the conditional statements (see below).

The right(string, integer) function does the same as left, except taking the text from the right side of the string. The conditional statement, then, CSB.send (...) should be pretty easy to understand then.
March 5, 2004, 1:45 AM
BorT
Thanks for the Sum up Myndfyre!
Just to clear one thing up:
[code]
if left(lcase(message), 3) = trigger & "b " and len(message) > 4 then
CSB.send "/ban " & right(message, len(message) - 4)
end if
[/code]
If the code were like that, then it wouldnt ban, correct?
March 5, 2004, 3:09 AM
Eli_1
[quote author=BorT link=board=17;threadid=5580;start=0#msg47565 date=1078456174]
Thanks for the Sum up Myndfyre!
Just to clear one thing up:
[code]
if left(lcase(message), 3) = trigger & "b " and len(message) > 4 then
CSB.send "/ban " & right(message, len(message) - 4)
end if
[/code]
If the code were like that, then it wouldnt ban, correct?
[/quote]
well, it would ATTEMPT to ban, only to recieve 'That user is not logged on' from bnet

because: message = "!b BorT bwahahah-Hax)or!$~"
[code]
right(message, len(message) - 4)
[/code]

that would remove the left 4 most characters from the string
causing you to send "orT bwahahahah-Hax)or!$~"
March 5, 2004, 3:54 AM
hismajesty
Subtract 3 chars:
1 char = !
1 char = b
1 char = space
March 5, 2004, 8:16 PM
LoRd
[quote author=hismajesty link=board=17;threadid=5580;start=0#msg47724 date=1078517806]
Subtract 3 chars:
1 char = !
1 char = b
1 char = space
[/quote]

Personally, I find it best to store the trigger as a dynamic variable, then take the length of the variable and subtract it from the message. That way you can change the trigger later on and it's not restricted to one character.
March 5, 2004, 8:21 PM
ChR0NiC
[quote author=hismajesty link=board=17;threadid=5580;start=0#msg47724 date=1078517806]
Subtract 3 chars:
1 char = !
1 char = b
1 char = space
[/quote]

[quote author=LoRd[nK] link=board=17;threadid=5580;start=0#msg47725 date=1078518108]
Personally, I find it best to store the trigger as a dynamic variable, then take the length of the variable and subtract it from the message. That way you can change the trigger later on and it's not restricted to one character.
[/quote]

I find that quite annoying actually, when you got little immature punks saying
queersay LOL
<Operator'sName> LOL
March 6, 2004, 12:14 AM
LoRd
[quote author=ChR0NiC link=board=17;threadid=5580;start=0#msg47803 date=1078532041]
[quote author=hismajesty link=board=17;threadid=5580;start=0#msg47724 date=1078517806]
Subtract 3 chars:
1 char = !
1 char = b
1 char = space
[/quote]

[quote author=LoRd[nK] link=board=17;threadid=5580;start=0#msg47725 date=1078518108]
Personally, I find it best to store the trigger as a dynamic variable, then take the length of the variable and subtract it from the message. That way you can change the trigger later on and it's not restricted to one character.
[/quote]

I find that quite annoying actually, when you got little immature punks saying
queersay LOL
<Operator'sName> LOL
[/quote]

Shouldn't allow immature people to control your bot.

The trigger allows you to give each bot it's own tag, for instance: Op1 say hi, Op2 say hi, Op3 say hi, LoRd[nK]#2: say hi
March 6, 2004, 12:49 AM
Kp
As an extension to this idea that I've had implemented for a very long time, consider having the bot respond to its own name as a trigger (possibly with additional characters). In such a situation, multiple bots on the same configuration profile will each have a unique trigger since the trigger is derived in part from the bot's logon name, which the server guarantees unique.
March 6, 2004, 1:33 AM

Search