• Welcome to Valhalla Legends Archive.
 

[VB6] Skywing's Ban Command Processor

Started by Joe[x86], September 13, 2005, 04:48 PM

Previous topic - Next topic

Joe[x86]

Original Code

Note, this will not work. Its half C++ (C?) and half VB6. I've ported a good deal of it, but I may have gotten some of it wrong. From lines 27 to 50, I'm not sure if line 29 should be inside the if block, as his didn't have the endif } in it. Perhaps only the very next line should have been in there? Anyhow, I hope this helps someone. Constructive critiism is welcome, but only constructive.

'TODO:
'- Settings.Trigger refers to the bots trigger.
'- Settings.HasOps refers to the bot having ops.
'- HasFlag(Username, Flag) should be changed to point to the access system.

Public Sub Outbot(Username As String, Command As String)
  If Left(S, 1) = Settings.Trigger Then Select Case Split(Command, " ")(0)
    Case Settings.Trigger & "ban"
      If Not (HasFlag(Username, "O") And Settings.HasOps) Then Exit Sub
      Channeluser *currentuser = 0;
      Dim bContinue As Boolean: bContinue = True
      Dim BanUser As String, BanMsg As String, TmpName As String
      Dim icnt As Integer: For icnt = 0 To (Len(ptxt) - 1) Step 1
        If Mid(Command, icnt, 1) = "," or Mid(Command, icnt, 1) = Chr(34) Then
          bContinue = False
          Exit Sub
        End If
      Next icnt
      If bContinue Then
        sscanf(trigger + 4, "%s %s", banuser, banmsg);
        BanUser = LCase(BanUser)
        usershere->rewind();
        If Not CBool(InStr(1, banuser, "*")) And Not CBool(InStr(1, banuser, "?"))) Then
          While Not usershere.at_end()
            currentuser = usershere.get()
            TmpName = LCase(currentuser.name)
            If (Not TmpName = BanUser) And (currentuser.icon And &H2 = &H2) Then
              bContinue = False
              ++*usershere;
            End If
          Wend
          If bContinue Then
            if(checkpriv(banuser, 'S') || checkexisting(botlist, banuser)) {
            sprintf(outstr, "/w %s %s is safelisted", !strcmp(puser, bnemuentry) ? botname : puser, banuser);
            Call AddQ(sb, outstr)
          Else
            sprintf(outstr, "/ban %s", ptxt + 4)
            Call AddQ(sb, outstr)
          End If
        End If
      Else
        While Not usershere.at_end()
          currentuser = usershere.get()
          TmpName = LCase(currentuser.name)
          If (TmpName = BanUser) And (Not HasFlags(TmpName, "S")) And (Not currentuser.icon And &H2 = &H2)) And (Not checkexisting(botlist, banuser)) Then
            sprintf(outstr, "/ban %s %s", tmpname, ptxt + 4 + strlen(banuser) + 1);
            Call AddQ(sb, outstr)
          End If
          +*usershere;-
        Wend
      End If
  Case Else
      '
  End Select
End Sub
Quote from: brew on April 25, 2007, 07:33 PM
that made me feel like a total idiot. this entire thing was useless.

Yegg

Good job so far. This is the kind of thing I do when I am really bored. :)

Joe[x86]

Nearly all ported, except the AddQ calls (not sure what is what (sb and outstr)), sprintf calls (what does that do?) and the big combinations of +'s, -'s, and variables. Also, a few things aren't defined, and this uses his method of finding users in the channel, getting their names, and their flags, etc.
Quote from: brew on April 25, 2007, 07:33 PM
that made me feel like a total idiot. this entire thing was useless.

Yegg

sprintf() copies a formatted string to another string. Use cplusplus.com as a reference for all standard C/C++ libraries.

rabbit

Joe, you have a bunch of stuff mucked up.  I didn't test this, but it should at least run (when you create the usershere class, that is):
Public Sub Outbot(Username As String, Command As String)
If Left(S, 1) = Settings.Trigger Then
Select Case Split(Command, " ")(0)
Case Settings.Trigger & "ban"
If Not (HasFlag(Username, "O") And Settings.HasOps) Then Exit Sub
Channeluser *currentuser = 0;
Dim bContinue As Boolean: bContinue = True
Dim BanUser As String, BanMsg As String, TmpName As String
Dim icnt As Integer

For icnt = 0 To (Len(ptxt) - 1) Step 1
If Mid(Command, icnt, 1) = "," or Mid(Command, icnt, 1) = Chr(34) Then
bContinue = False
Exit Sub
End If
Next icnt

If bContinue Then
sscanf(trigger + 4, "%s %s", banuser, banmsg);
BanUser = LCase(BanUser)
usershere.rewind()

If Not CBool(InStr(1, banuser, "*")) And Not CBool(InStr(1, banuser, "?"))) Then
While Not usershere.at_end()
currentuser = usershere.get()
TmpName = LCase(currentuser.name)

If (Not TmpName = BanUser) And (currentuser.icon And &H2 = &H2) Then
bContinue = False
'usershere is a class, not sure how it defines ++
usershere.someMember = usershere.someMember + 1
End If
Wend

If bContinue Then
If checkpriv(banuser, "S") Or checkexisting(botlist, banuser) Then
outstr = "/w " & Iif(InStr(1, puser, bnemuentry) = 0, botname, puser) & " " & banuser & " is safelisted"
Call AddQ(sb, outstr)
Else
outstr = "/ban " & Mid(ptxt, 4)
Call AddQ(sb, outstr)
End If
End If
Else
While Not usershere.at_end()
currentuser = usershere.get()
TmpName = LCase(currentuser.name)

If (TmpName = BanUser) And Not HasFlags(TmpName, "S")) And currentuser.icon And &H2) <> &H2 And _
Not checkexisting(botlist, banuser) Then
sprintf(outstr, "/ban %s %s", tmpname, ptxt + 4 + strlen(banuser) + 1);
Call AddQ(sb, outstr)
End If

'I've never seen this before!
'+*usershere;-
End If
End If
End If
End Select
End If
End Sub
Grif: Yeah, and the people in the red states are mad because the people in the blue states are mean to them and want them to pay money for roads and schools instead of cool things like NASCAR and shotguns.  Also, there's something about ketchup in there.

Joe[x86]

#5
Woah man, nice tabs! =p
Quote from: brew on April 25, 2007, 07:33 PM
that made me feel like a total idiot. this entire thing was useless.

Blaze

Quote
Channeluser *currentuser = 0;
Might want to fix that... :P
Quote
Mitosis: Haha, Im great arent I!
hismajesty[yL]: No

rabbit

Quote from: Joe on September 13, 2005, 10:09 PM
Woah man, nice tabs! =p
They are 1/2 the width in Notepad2, so I don't complain ^^
Grif: Yeah, and the people in the red states are mad because the people in the blue states are mean to them and want them to pay money for roads and schools instead of cool things like NASCAR and shotguns.  Also, there's something about ketchup in there.