Valhalla Legends Forums Archive | Battle.net Bot Development | Unbanning with wildcards and removing users

AuthorMessageTime
Gangz
K this time i am ahving 2 problems... after i figure these 2 out i pretty much got it figured out..

Unbannign with * script
[code]

Dim argSplit As Variant, temp As String
argSplit = Split(message)
If UCase(argSplit(0)) = Form1.varTrigger & "UNBAN" Then
templen = Len(argSplit(0) & argSplit(1)) + 1: If templen <> Len(message) Then temp = Mid(message, templen + 1)
If InStr(argSplit(1), "*") Then
For X = 0 To Form1.cbobanned.ListCount - 1
If Form1.cbobanned.List(X) Like argSplit(1) Then Form1.cboQueue.AddItem "/unban " & Form1.cbobanned.List(X) & temp
Next X
Else: Form1.cboQueue.AddItem "/unban " & argSplit(1) & temp
End If
End If
[/code] im not asking anyone to re-write i it to work just point out erros =\

And i also was wondering how to remove users from a userlist..

this is the adding code
[code] If UCase(Mid(message, 1, 5)) = Form1.varTrigger & "ADD " Then
Dim User As String
User = (Mid(message, 6))
Form1.cboUsers.AddItem User[/code]

i can add just not remove =\ because it adds the user with flags such as M O S B
February 7, 2004, 7:20 AM
hismajesty
You have to use an API call to remove from a ListBox. I don't remember it off the top of my head though, try msdn.
February 7, 2004, 12:58 PM
Newby
Use an array to store your users. :\
February 7, 2004, 3:28 PM
UserLoser.
[quote author=hismajesty link=board=17;threadid=5148;start=0#msg42944 date=1076158704]
You have to use an API call to remove from a ListBox. I don't remember it off the top of my head though, try msdn.
[/quote]

Hmm..

[code]int i_Retval = SendMessage(lstHwnd, LB_FINDSTRING, 0, (LPARAM)"My listbox item");

SendMessage(lstHwnd, LB_DELETESTRING, i_Retval, 0);[/code]
February 7, 2004, 5:10 PM
hismajesty
Yes, UserLoser, but I remember you giving me a direct API call for that a while back. Without having to use SendMessage.
February 8, 2004, 12:22 AM
Gangz
Eh... I gatta look this one up =\.. its kinda complecated i can see
February 8, 2004, 6:22 AM
UserLoser.
[quote author=Gangz link=board=17;threadid=5148;start=0#msg43082 date=1076221356]
Eh... I gatta look this one up =\.. its kinda complecated i can see
[/quote]

There is a much simpiler way, something like:

[code]
Dim I as Long
For I = 0 To MyList.ListCount
If UCase(MyList.List(i)) = UCase(UserToRemove) Then MyList.RemoveItem I: Exit For
Next I
[/code]
February 8, 2004, 4:35 PM
Gangz
[quote author=UserLoser. link=board=17;threadid=5148;start=0#msg43122 date=1076258159]
[quote author=Gangz link=board=17;threadid=5148;start=0#msg43082 date=1076221356]
Eh... I gatta look this one up =\.. its kinda complecated i can see
[/quote]

There is a much simpiler way, something like:

[code]
Dim I as Long
For I = 0 To MyList.ListCount
If UCase(MyList.List(i)) = UCase(UserToRemove) Then MyList.RemoveItem I: Exit For
Next I
[/code]
[/quote]
wont work.. that is were i get caught up to... On the list it adds as Userloser. M ... So i need it to remove the whole line =\
February 8, 2004, 7:05 PM
UserLoser.
[quote author=Gangz link=board=17;threadid=5148;start=0#msg43142 date=1076267104]
[quote author=UserLoser. link=board=17;threadid=5148;start=0#msg43122 date=1076258159]
[quote author=Gangz link=board=17;threadid=5148;start=0#msg43082 date=1076221356]
Eh... I gatta look this one up =\.. its kinda complecated i can see
[/quote]

There is a much simpiler way, something like:

[code]
Dim I as Long
For I = 0 To MyList.ListCount
If UCase(MyList.List(i)) = UCase(UserToRemove) Then MyList.RemoveItem I: Exit For
Next I
[/code]
[/quote]
wont work.. that is were i get caught up to... On the list it adds as Userloser. M ... So i need it to remove the whole line =\
[/quote]

Try:
[code]
Dim I as Long
Dim Sp() as String
For I = 0 To MyList.ListCount
Sp() = Split(MyList.List(I), " ")
If UCase(Sp(0)) = UCase(UserToRemove) Then MyList.RemoveItem I: Exit For
Next I
[/code]

Sp(0) would be Userloser.
Sp(1) would be M
February 8, 2004, 10:32 PM
Newby
I was going to say that. But then I got lazy and fell asleep :(
February 8, 2004, 11:10 PM
Networks
Public Function WildCard(ByVal WC As String, ByVal SearchStr As String) As Boolean
      If WC Like SearchStr Then
           WildCard = True
           Exit Function
      Else
           WildCard = False
      End If
End Function

Could someone give me a usage for when someone joins the channel and meets specifications for a wildcard ban?
February 9, 2004, 7:13 PM
Myndfyr
okay, first use [ code ] [ /code ] tags:
[code]
Public Function WildCard(ByVal WC As String, ByVal SearchStr As String) As Boolean
If WC Like SearchStr Then
WildCard = True
Exit Function
Else
WildCard = False
End If
End Function
[/code]

And here is some Pseudocode for you:

[code]
' Assume that mySrchStr is declared as a String variable

' Sorry, this code looks like Visual Basic 7.... You should be able to
' get the meaning out of it though, hence _pseudo_code...
Public Function User_Joined (ByVal usr As String, ByVal flags As Integer, ByVal stats As String, ByVal ping As Integer) Handles Me.connection.UserJoined

If WildCard mySrchStr, usr
DoMyWildcardAction
End If

End Function[/code]
February 9, 2004, 7:52 PM
o.OV
[code]
Public Function WildCard(ByVal WC As String, ByVal SearchStr As String) As Boolean
If WC Like SearchStr Then
WildCard = True
Exit Function
Else
WildCard = False
End If
End Function
[/code]

er.. it should look something like this..

[code]
Public Function WildCard(ByVal WC As String, ByVal SearchStr As String) As Boolean
wildcard = (WC Like SearchStr)
End Function
[/code]

Why would you want to even bother making such a simple function.. the Like operator returns a boolean value already...
February 10, 2004, 2:57 AM
Myndfyr
[quote author=o.OV link=board=17;threadid=5148;start=0#msg43433 date=1076381860]
Why would you want to even bother making such a simple function.. the Like operator returns a boolean value already...
[/quote]

I disagree. What happens when somewhere down the line, he wants to change his wildcard processing?

This is good encapsulation (although I doubt he knew that).
February 10, 2004, 4:03 AM
Soul Taker
Yes, would be a good idea to make a function for wildcard matching which changes the default behavior of some masking characters.
February 10, 2004, 4:29 AM
Networks
I dont want a function I want a usage for ID_JOIN and ID_TALK please? Assume i have a channellist if you must.
February 10, 2004, 1:59 PM
o.OV
[quote author=Soul Taker link=board=17;threadid=5148;start=0#msg43467 date=1076387375]
Yes, would be a good idea to make a function for wildcard matching which changes the default behavior of some masking characters.
[/quote]

Good point. that reminds me..

[code]
leftFlat = "["
ChrW1 = ChrW$(1)
TempA = MainStr
Position = InStr(TempA, leftFlat)
If Position Then
For X = 0 To 255
Mid$(TempA, Position, 1) = Chr1
Position = InStr(TempA, leftFlat)
If Position = 0 Then Exit For
Next X
End If
'TempA is to be used with the Like operator in place _
of MainStr
'Same should be done for the other one..
[/code]

That should keep the flat brackets from causing problems.
February 10, 2004, 3:53 PM
o.OV
[quote author=Networks link=board=17;threadid=5148;start=15#msg43496 date=1076421543]
I dont want a function I want a usage for ID_JOIN and ID_TALK please? Assume i have a channellist if you must.
[/quote]

So you plucked the code off of someone and you can't figure out how it works?

Google, Google, and Google?
February 10, 2004, 4:04 PM
Myndfyr
[quote author=Networks link=board=17;threadid=5148;start=15#msg43496 date=1076421543]
I dont want a function I want a usage for ID_JOIN and ID_TALK please? Assume i have a channellist if you must.
[/quote]

Pseudocode:

[code]
Switch (EventID)
Case ID_JOIN:
If MatchesWildcard(Username, SEARCHSTRING) Then
BanUser Username
Else
ChannelList.Add User
WriteUserJoinedMessage User, Product
End If
End Case
Case ID_TALK:
If MatchesWildcard(Username, SEARCHSTRING) Then
BanUser Username
Else
WriteUserSpokeMessage User, Message
End If
End Case
End Switch
[/code]

Wow..... That was hard.... You should almost be able to move that right into VB by changing the Switch statement and replacing the Write...Message subroutine identifiers...

(Excuse my VB grammar, I'm not sure how the Select...Case operator works.... I know that in C and its derivitives, we use case case:... break)
February 10, 2004, 4:14 PM
Networks
I need some help with wildcarding code:

I want to be abled to ban tags like: *]ZeR0[*
in that format for example

my wildcard function is:

[code]
Public Function matches(ByVal uName As String, ByVal Check As String) As Boolean
Call PrepareCheck(Check)
If uName = Empty Then
matches = False
Exit Function
End If
If LCase$(uName) Like LCase$(Check) Then matches = True
End Function
Function PrepareCheck(ByVal toCheck As String) As String
toCheck = Replace(toCheck, "[", "ÿ")
toCheck = Replace(toCheck, "]", "Ö")
toCheck = Replace(toCheck, "~", "Ü")
toCheck = Replace(toCheck, "#", "¢")
toCheck = Replace(toCheck, "-", "£")
toCheck = Replace(toCheck, "&", "¥")
toCheck = Replace(toCheck, "@", "¤")
toCheck = Replace(toCheck, "{", "ƒ")
toCheck = Replace(toCheck, "}", "á")
toCheck = Replace(toCheck, "^", "í")
toCheck = Replace(toCheck, "`", "ó")
toCheck = Replace(toCheck, "_", "ú")
toCheck = Replace(toCheck, "+", "ñ")
toCheck = Replace(toCheck, "$", "Ñ")
PrepareCheck = LCase(toCheck)
End Function [/code]


I tested the function and it works fairly well except it wont find matches with *]ZeR0[* even when there is one:

[code]
For II = 1 To Form1.Users.ListItems.Count
If matches(Form1.Users.ListItems(II), "*]zer0[") = True Then
AddC vbGreen, Form1.Users.ListItems(II) & " was found."
End If
Next II [/code]

it told me invalid pattern string y is this?
Can someone please help me with wildcard code that can find matches w/ *]ZeR0[* please
February 12, 2004, 11:03 PM
Myndfyr
Here is your code:

[code]
For II = 1 To Form1.Users.ListItems.Count
If matches(Form1.Users.ListItems(II), "*]zer0[") = True Then
AddC vbGreen, Form1.Users.ListItems(II) & " was found."
End If
Next II
[/code]

And let me highlight an interesting section:

[font=courier]
If matches(Form1.Users.ListItems(II), "*]zer0[" ) = True Then
[/font]

Forgot a * there smart guy.
February 12, 2004, 11:41 PM
Networks
Not really cuz when its: *]ZeR0[ it says invalid pattern and if its *]zer0[* doesn't find it...
Plus i have a user w/ a ]zer0[ tag in users

Smart guy....
February 12, 2004, 11:44 PM

Search