• Welcome to Valhalla Legends Archive.
 

inserting * in / commands

Started by Camel, May 03, 2003, 09:21 PM

Previous topic - Next topic

Camel

this is for you, paid:
(he wanted to know how to add whispers to a text box box seperate from the one used for normal chat)

Public Sub SendText(strText As String, Optional WhisperBack As String = "", Optional ForceTimerUse As Long, Optional DontChange As Boolean = False)
   Const m = 200
   
#If DEBUG_ <> 0 Then
   If InStr(strText, Chr(0)) <> 0 Then Debug.Assert False
#End If

   If DontChange Then GoTo sendnow
   
   If InStr(strText, "%ver%") Then strText = Replace(strText, "%ver%", version)
   If InStr(strText, "%running%") Then strText = Replace(strText, "%running%", GetTime(GetTickCount - StartTime))
   If InStr(strText, "%connected%") Then strText = Replace(strText, "%connected%", GetTime(GetTickCount - LogTime))
   If InStr(strText, "%uptime%") Then strText = Replace(strText, "%uptime%", GetTime(GetTickCount))
   strText = Replace(strText, "%channel%", Channel)
   strText = Replace(strText, "%server%", frmSetup.SAddr)
   If InStr(strText, "%mp3%") Then strText = Replace(strText, "%mp3%", winamp.GetSongTitle(False))
   If InStr(strText, "%mp3full%") Then strText = Replace(strText, "%mp3full%", winamp.GetSongTitle(True))
   If InStr(strText, "%cpu%") Then strText = Replace(strText, "%cpu%", GetCPUInfo)
   
   If (WhisperBack = MyName) And (MyName <> "") Then
       Addtext D2LtYellow, strText & vbCrLf, True
       Exit Sub
   End If
   
   If (Left(strText, 1) <> "/") And (WhisperBack <> "") Then
       strText = "/m " & WhisperBack & " " & strText
   End If

   Select Case StrReverse(GetID)
       Case "D2DV", "D2XP"
           If (Left(strText, 1) = "/") And (InStr(1, strText, " ") > 0) Then
               Dim s() As String
               s = Split(strText, " ", 2)
               
               Dim Name As String
               Name = s(1)
               If InStr(1, Name, " ") Then Name = Left(Name, InStr(1, Name, " ") - 1)
               
               If (InStr(Name, "*") = 0) Then
                   Select Case s(0)
                       Case "/w", "/m", "/msg", "/whisper", "/whois", "/kick", "/ban", "/unban", "/designate", "/ignore", "/squelch", "/unignore", "/unsquelch"
                           strText = s(0) & " *" & s(1)
                   End Select
               End If
           End If
   End Select
   
sendnow:
   
   SendBuf = SendBuf & MakePacket(&HE, Left(strText, m) & Chr(0))
   CheckSend ForceTimerUse
End Sub

turtles

#1
*sigh
i recently discovered the Modify option. didnt notice it b4 cuz i was logged on as guest when i was examining the forums.

groks post that comes after this was questioning the post i made. and not the one b4 mine.

inserting * in / commands

is title of discussion

when i first saw it i thought he meant
/ban *username*

so i posted a sub i made to handle wildcards  :-\ give me break. i misunderstood the post. :-X

at least the code works.  ;D

as some of the other members/moderators suggested. my code could be improved using the LIKE statement. ill look further into it

and for those who still dont have the flood protection algorithm. refer to my other posts.. so far. my algorithm hasnt failed me yet.  ;D

Grok

Quote from: turtles on May 08, 2003, 05:07 AM
im sure there is a much shorter way to do this.. and... i think i misunderstood the post.. but o well

Ummm, what the hell does that do?  If it is just Instr(), I will have to archive this post to the hall-of-coding-shame.

Yoni


turtles

#4
yea i have  :-\

Yoni

IIRC, your anti-flood algorithm was something like "wait 3 seconds before messages"?
That doesn't work. Test it.

turtles

#6
Quote from: Yoni on May 08, 2003, 05:33 PM
IIRC, your anti-flood algorithm was something like "wait 3 seconds before messages"?
That doesn't work. Test it.

if u were thinking the flood protection is for IIRC
erm. sorry. the flood protection is for bnet chat client. i dunno about IIRC

Yoni

Try using 66 characters per message instead of 65.

turtles

Quote from: Yoni on May 08, 2003, 05:46 PM
Try using 66 characters per message instead of 65.

im assuming u are talking about bnet chat and yea.  i tried 66. it flooded out b4 the 50th send

Yoni

#9
Err... IIRC stands for "if I recall correctly". It's an Internet abbreviation.

And if your algorithm floods off, it doesn't exactly work, does it?

Camel

Quote from: turtles on May 08, 2003, 05:44 PM
Quote from: Yoni on May 08, 2003, 05:33 PM
IIRC, your anti-flood algorithm was something like "wait 3 seconds before messages"?
That doesn't work. Test it.

if u were thinking the flood protection is for IIRC
erm. sorry. the flood protection is for bnet chat client. i dunno about IIRC

+1 to turtles for making me fall off my chair laughing

turtles

#11
mm. oops. i thought it was some type of internet relay chat =P

im not familiar with all the slangs used on the interenet.. glad i can make ya laugh camel =)

and yea. i did test it... and it does work. if u want a shorter delay. u increase the number. the MSperBYTE or w/e name i gave it. should be between .06 and .07

the smaller the number. the less likely u are to flood out.

and i have tested with 66 characters..
i was well aware of it b4 i posted my script.. thats why its included in my post.
http://forum.valhallalegends.com/phpbbs/index.php?board=17;action=display;threadid=1249

even a delay of 10 seconds wont save u. i dont think 20 seconds would save u  either. u would never reach the 500th send. IIRC =) i said it involves a second algorithm. and i dont kno it. and its not worth the hassle to figure out

and i did mention it would flood off if it was more then 65 characters. so cant say i didnt take that into account. the algorithm is made to handle regular messaging. for my bot.. i have setup a limiter that chops off anything past 65 characters.

tA-Kane

#12
Quotei have setup a limiter that chops off anything past 65 characters.
Chopping off characters is eww++
Macintosh programmer and enthusiast.
Battle.net Bot Programming: http://www.bash.org/?240059
I can write programs. Can you right them?

http://www.clan-mac.com
http://www.eve-online.com

turtles

#13
Quote from: tA-Kane on May 08, 2003, 09:14 PM
Quote from: turtles link=board=17;threai have setup a limiter that chops off anything past 65 characters.quote]
Chopping off characters is eww++

heh. not a bright idea? =\ well. I HATE THE IDEA TOO  :'(  but its part of the flood protection scheme. i cant help it.. unless someone else can tell me the second algorithm involved in the determining the time to wait...
just a thought... but the second algorithm for sends over 65 characters in length would have wait times that are too long to be called efficient. would get more info sent out safely using the given algorithm and character limit i have set..

with the second algorithm wait times would be around a minute or more?

I remembered testing it once..

i dont remember what i did exactly.. ill give general idea.

pseudo fact1:  ;)
bot floods out on 48th send of 200 characters per send

pseudo fact2:
bot will not flood out if u stop at 47th send of 200 characters per send

pseudo test:

47 sends of 200 characters per send

+

10 minutes of me watching tV
(delay time)

+

20 more sends placed into query

=

result:
bot flood outs on the 10th of the 20 sends

the time at which it took to recover enough to send 10 sends of 200 character per send was about 10 minutes.. not worth ur effort to figure out the algorithm now is it =\ get more information sent out if u stick with 65 characters per send

if u want efficiency for your bot. u will stick with the 65 character send limit

Camel

...
just freakin' reconnect automaticly when you flood off!