Author | Message | Time |
---|---|---|
JoeTheOdd | 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. [pre]'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[/pre] | September 13, 2005, 9:48 PM |
Yegg | Good job so far. This is the kind of thing I do when I am really bored. :) | September 13, 2005, 9:49 PM |
JoeTheOdd | 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. | September 13, 2005, 9:54 PM |
Yegg | sprintf() copies a formatted string to another string. Use cplusplus.com as a reference for all standard C/C++ libraries. | September 13, 2005, 11:23 PM |
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): [code]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[/code] | September 13, 2005, 11:39 PM |
JoeTheOdd | Woah man, nice tabs! =p | September 14, 2005, 3:09 AM |
KkBlazekK | [quote] Channeluser *currentuser = 0; [/quote] Might want to fix that... :P | September 14, 2005, 5:57 PM |
rabbit | [quote author=Joe link=topic=12801.msg128073#msg128073 date=1126667389] Woah man, nice tabs! =p [/quote]They are 1/2 the width in Notepad2, so I don't complain ^^ | September 14, 2005, 9:29 PM |