• Welcome to Valhalla Legends Archive.
 

Wild Card Ban Help

Started by TeEhEiMaN, June 24, 2003, 04:19 PM

Previous topic - Next topic

TeEhEiMaN

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

Kp

... 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.
[19:20:23] (BotNet) <[vL]Kp> Any idiot can make a bot with CSB, and many do!

______

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


DarkMinion


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);
   }
}

TeEhEiMaN


Camel

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