Valhalla Legends Archive

Programming => Battle.net Bot Development => Topic started by: Gangz on February 07, 2004, 01:20 AM

Title: Unbanning with wildcards and removing users
Post by: Gangz on February 07, 2004, 01:20 AM
K this time i am ahving 2 problems... after i figure these 2 out i pretty much got it figured out..

Unbannign with * script
       

       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
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
       If UCase(Mid(message, 1, 5)) = Form1.varTrigger & "ADD " Then
       Dim User As String
           User = (Mid(message, 6))
        Form1.cboUsers.AddItem User


i can add just not remove =\ because it adds the user with flags such as M O S B
Title: Re:Unbanning with wildcards and removing users
Post by: hismajesty on February 07, 2004, 06:58 AM
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.
Title: Re:Unbanning with wildcards and removing users
Post by: Newby on February 07, 2004, 09:28 AM
Use an array to store your users. :\
Title: Re:Unbanning with wildcards and removing users
Post by: UserLoser. on February 07, 2004, 11:10 AM
Quote from: hismajesty on February 07, 2004, 06:58 AM
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.

Hmm..

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

SendMessage(lstHwnd, LB_DELETESTRING, i_Retval, 0);

Title: Re:Unbanning with wildcards and removing users
Post by: hismajesty on February 07, 2004, 06:22 PM
Yes, UserLoser, but I remember you giving me a direct API call for that a while back. Without having to use SendMessage.
Title: Re:Unbanning with wildcards and removing users
Post by: Gangz on February 08, 2004, 12:22 AM
Eh... I gatta look this one up =\.. its kinda complecated i can see
Title: Re:Unbanning with wildcards and removing users
Post by: UserLoser. on February 08, 2004, 10:35 AM
Quote from: Gangz on February 08, 2004, 12:22 AM
Eh... I gatta look this one up =\.. its kinda complecated i can see

There is a much simpiler way, something like:


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
Title: Re:Unbanning with wildcards and removing users
Post by: Gangz on February 08, 2004, 01:05 PM
Quote from: UserLoser. on February 08, 2004, 10:35 AM
Quote from: Gangz on February 08, 2004, 12:22 AM
Eh... I gatta look this one up =\.. its kinda complecated i can see

There is a much simpiler way, something like:


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

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 =\
Title: Re:Unbanning with wildcards and removing users
Post by: UserLoser. on February 08, 2004, 04:32 PM
Quote from: Gangz on February 08, 2004, 01:05 PM
Quote from: UserLoser. on February 08, 2004, 10:35 AM
Quote from: Gangz on February 08, 2004, 12:22 AM
Eh... I gatta look this one up =\.. its kinda complecated i can see

There is a much simpiler way, something like:


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

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 =\

Try:

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


Sp(0) would be Userloser.
Sp(1) would be M
Title: Re:Unbanning with wildcards and removing users
Post by: Newby on February 08, 2004, 05:10 PM
I was going to say that. But then I got lazy and fell asleep :(
Title: Re:Unbanning with wildcards and removing users
Post by: Networks on February 09, 2004, 01:13 PM
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?
Title: Re:Unbanning with wildcards and removing users
Post by: MyndFyre on February 09, 2004, 01:52 PM
okay, first use [ code ] [ /code ] tags:

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


And here is some Pseudocode for you:


' 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
Title: Re:Unbanning with wildcards and removing users
Post by: o.OV on February 09, 2004, 08:57 PM

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


er.. it should look something like this..


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


Why would you want to even bother making such a simple function.. the Like operator returns a boolean value already...
Title: Re:Unbanning with wildcards and removing users
Post by: MyndFyre on February 09, 2004, 10:03 PM
Quote from: o.OV on February 09, 2004, 08:57 PM
Why would you want to even bother making such a simple function.. the Like operator returns a boolean value already...

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).
Title: Re:Unbanning with wildcards and removing users
Post by: Soul Taker on February 09, 2004, 10:29 PM
Yes, would be a good idea to make a function for wildcard matching which changes the default behavior of some masking characters.
Title: Re:Unbanning with wildcards and removing users
Post by: Networks on February 10, 2004, 07:59 AM
I dont want a function I want a usage for ID_JOIN and ID_TALK please? Assume i have a channellist if you must.
Title: Re:Unbanning with wildcards and removing users
Post by: o.OV on February 10, 2004, 09:53 AM
Quote from: Soul Taker on February 09, 2004, 10:29 PM
Yes, would be a good idea to make a function for wildcard matching which changes the default behavior of some masking characters.

Good point. that reminds me..


   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..


That should keep the flat brackets from causing problems.
Title: Re:Unbanning with wildcards and removing users
Post by: o.OV on February 10, 2004, 10:04 AM
Quote from: Networks on February 10, 2004, 07:59 AM
I dont want a function I want a usage for ID_JOIN and ID_TALK please? Assume i have a channellist if you must.

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

Google, Google, and Google?
Title: Re:Unbanning with wildcards and removing users
Post by: MyndFyre on February 10, 2004, 10:14 AM
Quote from: Networks on February 10, 2004, 07:59 AM
I dont want a function I want a usage for ID_JOIN and ID_TALK please? Assume i have a channellist if you must.

Pseudocode:


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


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)
Title: Re:Unbanning with wildcards and removing users
Post by: Networks on February 12, 2004, 05:03 PM
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:


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



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


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


it told me invalid pattern string y is this?
Can someone please help me with wildcard code that can find matches w/ *]ZeR0[* please
Title: Re:Unbanning with wildcards and removing users
Post by: MyndFyre on February 12, 2004, 05:41 PM
Here is your 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


And let me highlight an interesting section:


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


Forgot a * there smart guy.
Title: Re:Unbanning with wildcards and removing users
Post by: Networks on February 12, 2004, 05:44 PM
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....