Valhalla Legends Archive

Programming => Battle.net Bot Development => Topic started by: TeEhEiMaN on June 24, 2003, 04:19 PM

Title: Wild Card Ban Help
Post by: TeEhEiMaN on June 24, 2003, 04:19 PM
ok this is what I got so far and I know its way off, but Im not sure what to do.


If Username = Form5.txtMaster.Text Then
If Left((LCase(Message)), 6) = (Form5.txtTrigger.Text & "ban *") Then
Dim bUsername As String
bUsername = Right(Message, (Len(Message) - 5))
If bUsername Like (lvChannel) Then
CleanSlateBot1.Send "/ban " & bUsername
End If
End If
Title: hmm, that looks like ...
Post by: Kp on June 24, 2003, 04:29 PM
... you're trying to ban the channel's name? :)  Not sure, since you didn't post what lvChannel is.  Either way, the correct solution would be to iterate over in-channel users and do that Like test on each of them, adding the ban if it is true.
Title: Re:Wild Card Ban Help
Post by: ______ on June 24, 2003, 05:54 PM
im taking he wants to ban a person in that channel


Dim bUsername As String
bUsername = Right(Message, (Len(Message) - 5)
dim tempusr as string
for i = 1 to lvchannel.listitems.count
tmpusr = lvchannel.listitems(i).text
if lcase(bUsername) like lcase(tmpusr) then
CleanSlateBot1.Send "/ban " & tmpusr
endif
next i

Title: Re:Wild Card Ban Help
Post by: DarkMinion on June 24, 2003, 06:13 PM

int wildcmp(char *wild, char *string)
{   
   char *cp, *mp;   
   while ((*string) && (*wild != '*')) {
      if ((*wild != *string) && (*wild != '?')) {
         return 0;      
      }
      wild++;
      string++;
   }         
   while (*string) {
      if (*wild == '*') {
         if (!*++wild) {
            return 1;
         }
         mp = wild;
         cp = string+1;
      }
      else if ((*wild == *string) || (*wild == '?')) {         
         wild++;
         string++;
      }
      else {
         wild = mp;
         string = cp++;
      }
   }
   while (*wild == '*') {
      wild++;
   }   
   return !*wild;
}

void WildCardBan(const char *szWild, const char *szMsg)
{
   for(int i = 0; i < ChanList.Count(); i++){
      if(wildcmp(strlwr((char *)szWild), strlwr(ChanList.Get(i))) && !IsSafe(ChanList.Get(i)))
         Send("/ban %s %s", ChanList.Get(i), szMsg);
   }
}
Title: Re:Wild Card Ban Help
Post by: TeEhEiMaN on June 24, 2003, 07:43 PM
Sweet thx so much
Title: Re:Wild Card Ban Help
Post by: Camel on June 24, 2003, 07:53 PM
Public Function Matches(ByVal UserName As String, ByVal Format As String) As Boolean
   'MSDN: Note   To match the special characters left bracket ([), question mark (?), number sign (#), and asterisk (*), enclose them in brackets. The right bracket (]) can't be used within a group to match itself, but it can be used outside a group as an individual character.
   Format = Replace(Format, "[", "[[]")
   Format = Replace(Format, "#", "[#]")
   Matches = (UserName Like Format)
End Function


if you want to be able to use ? as a literal charactor, add Format = Replace(Format, "?", "[?]") otherwise it will be interperated as a single unknown charactor