WhiteN_Nerdy
Guest
Namd
Von stealthbot gibts ja diese timeban plugin
Nun mein problem, ich brauch dieses plugin so, das es automatisch nicht safelisted user fuer 10 minuten bant, nach diesen 10 minuten aber wieder automatisch entbant. ist sowas moeglich? oder muss ich da ins stealthbot.net forum fragen gehn?
Von stealthbot gibts ja diese timeban plugin
Nun mein problem, ich brauch dieses plugin so, das es automatisch nicht safelisted user fuer 10 minuten bant, nach diesen 10 minuten aber wieder automatisch entbant. ist sowas moeglich? oder muss ich da ins stealthbot.net forum fragen gehn?
'timeban
'1.361
'&Timeban Script:Swent
'&timeban <username> <time> [reason]:untimeban <username>:timebanned:ctbl
'&8970
'&From inside the bot, use "/" as your trigger:The <time> arguement is in minutes, and must be an integer:To use something other than minutes use .timeban <username> <x>/<time> [reason]: <x> can be d (days), h (hours), or s (seconds):Example - ".timeban Joe s/30" would timeban Joe for 30 seconds:Example - ".timeban Joe 5" would timeban Joe for 5 minutes
'// ver 1.36
'// *Fixed banning/unbanning problems for Diablo 2 users
'// ver 1.354
'// *To reduce lag/fl removed one of the AddQ's on unban for timebans 1 minute or shorter
Public tbPath '// holds path to the timebanned users text file
Public tbUsers '// holds data about users that are currently timebanned
Public tbDisplay '// holds command output display type
Public tbBan(2) '// holds ban message
Public tbUnban(2) '// holds user who's being unbanned after an expired timeban
Public tbOffline '// holds users that were offline when their timeban expired
Public tbFSO '// holds the FSO
'/*************************
'* PROGRAM SETTINGS *
'*************************/
'// Access requirements
Const timeban_cmd_access = 60
Const untimeban_cmd_access = 60
Const timebanned_cmd_access = 60
Const ctbl_cmd_access = 60
'// Command names
Const timeban_command = "timeban" '// Command to timeban a user
Const untimeban_command = "untimeban" '// Command to end a user's timeban
Const timebanned_command = "timebanned" '// Command to list users that are currently timebanned
Const ctbl_command = "ctbl" '// Command to clear list of timebanned users
'// Output Display Type
'// 1: Public | 2: Emoted | 3: Whispered
Const tb_display_type = 3
'/*************************
'* DO NOT EDIT BELOW HERE *
'*************************/
Sub timeban_Event_Load()
Set tbFSO = CreateObject("Scripting.FileSystemObject")
tbPath = BotPath & "timebanned_users.dat"
'// Get list of timebanned users from the text file
If Not tbFSO.FileExists(tbPath) Then
Set tbFile = tbFSO.CreateTextFile(tbPath)
ReDim tbUsers(0)
Else
Set tmpFile = tbFSO.GetFile(tbPath)
If tmpFile.Size = 0 Then
ReDim tbUsers(0)
Else
Set File = tbFSO.OpenTextFile(tbPath, 1)
tbUsers = Split(File.ReadAll(), vbCrLf)
File.Close
End If
End If
TimerInterval "timeban", "tbTimer", 1
TimerEnabled "timeban", "tbTimer", True
End Sub
Sub timeban_Event_ServerError(Message)
If Message = "That user is not logged on." Then
'// If timebanned user is offline, display timeban line
If tbBan(0) Then
dsp tbDisplay, Replace(tbBan(1), chr(167), "(offline) "), tbBan(2), vbCyan
tbBan(0) = False
'// If a user's timeban expires and they're offline, rejoin channel to lift the ban
ElseIf tbUnban(0) Then
If Not IsArray(tbOffline) Then ReDim tbOffline(0)
tbOffline(UBound(tbOffline)) = tbUnban(1)
ReDim Preserve tbOffline(UBound(tbOffline) + 1)
If tbUnban(2) = BotVars.Username Then tbDisplay = 4
dsp tbDisplay, tbUnban(1) & " is offline. To lift the ban the bot will now rejoin the channel...", tbUnban(2), vbCyan
AddQ "/rejoin"
tbUnban(0) = False
End If
'// If timebanner doesn't have ops, display timeban line
ElseIf Message = "You are not a channel operator." Then
If tbBan(0) Then
dsp tbDisplay, Replace(tbBan(1), chr(167), vbNullString), tbBan(2), vbCyan
tbBan(0) = False
End If
End If
End Sub
Sub timeban_Event_ServerInfo(Message)
If Instr(LCase(Message), "was unbanned by " & LCase(BotVars.Username)) Then
If tbUnban(0) Then tbUnban(0) = False
'// Protect against other bots' Ban Evasion / AutoBan
ElseIf Instr(LCase(Message), "was banned by") Then
bannedUser = Split(LCase(Message))(0)
If Instr(Message, "Timebanned") Then
If tbBan(0) Then tbBan(0) = False: Exit Sub
End If
'// Are there any users that were untimebanned while offline?
If Not IsArray(tbOffline) Then Exit Sub
If Instr(Message, "Ban Evasion") Or Instr(Message, "AutoBan") Then
'// Check for users that were offline when their timeban expired
For i = 0 to UBound(tbOffline)
If bannedUser = tbOffline(i) Then
tbOffline(i) = vbNullString
PadQueue: PadQueue: PadQueue
AddQ "/unban " & psD2 & bannedUser
AddQ "/w " & psD2 & bannedUser & " You have been unbanned."
End If
Next
End If
End If
End Sub
Sub timeban_Event_UserTalk(Username, Flags, Message, Ping)
GetDBEntry Username, myAccess, myFlags
If Not (Left(Message, 1) = BotVars.Trigger Or Left(Message, 1) = "/") Then Exit Sub '// Not a command
'// AddChat response if command is coming from inside bot
If Username = BotVars.Username Then tbDisplay = 4 Else tbDisplay = tb_display_type End If
'// Get command and arguements
If Len(Message) < 2 Then Exit Sub
cmd = Split(Mid(LCase(Trim(Message)), 2))
'// Call the appropriate command sub
Select Case cmd(0)
Case timeban_command, "tban": timeban_cmd cmd, Username, myAccess, Message
Case untimeban_command, "utban": untimeban_cmd cmd, Username, myAccess
Case timebanned_command, "tbanned": timebanned_cmd Username, myAccess
Case ctbl_command: ctbl_cmd Username, myAccess
End Select
End Sub
Sub timeban_Event_UserJoins(Username, Flags, Message, Ping, Product, Level, OriginalStatString)
tbanData = GetTimebanData(Username)
If IsArray(tbanData) Then
If Len(tbanData(2)) > 0 Then reason = Replace(tbanData(2), chr(164), "|")
AddQ "/ban " & psD2 & Username & " Timebanned" & reason & ". " & tbGetTimeLeft(tbanData(4)), 1
End If
End Sub
Sub timeban_Event_UserInChannel(Username, Flags, Message, Ping, Product)
tbanData = GetTimebanData(Username)
If IsArray(tbanData) Then
If Len(tbanData(2)) > 0 Then reason = Replace(tbanData(2), chr(164), "|")
AddQ "/ban " & psD2 & Username & " Timebanned" & reason & ". " & tbGetTimeLeft(tbanData(4)), 1
End If
End Sub
Sub timeban_Event_PressedEnter(Text)
If Len(Text) < 2 Or Left(Text, 1) <> "/" Then Exit Sub
cmd = Split(Mid(LCase(Trim(Text)), 2), " ")
Select Case cmd(0)
Case timeban_command, untimeban_command, timebanned_command, ctbl_command, "tban", "utban", "tbanned"
VetoThisMessage
timeban_Event_UserTalk BotVars.Username, "", Text, 0
End Select
End Sub
Sub timeban_tbTimer_Timer()
'// Is anyone timebanned?
If Join(tbUsers, vbNullString) = vbNullString Then Exit Sub
For i = 0 to UBound(tbUsers)
If tbUsers(i) <> vbNullString Then
arrUser = Split(tbUsers(i), "|")
If DateDiff("s", Now, arrUser(4)) <= 0 Then
'// This user's timeban has ended
tbUsers(i) = vbNullString
tbUnban(0) = True: tbUnban(1) = arrUser(0): tbUnban(2) = BotVars.Username
AddQ "/unban " & psD2 & arrUser(0)
If DateDiff("s", arrUser(3), Now) > 60 Then AddQ arrUser(0) & "'s timeban has expired."
AddQ "/w " & psD2 & arrUser(0) & " Your timeban has expired. You have been unbanned."
End If
End If
Next
End Sub
Sub timeban_Event_Close()
If tbFSO.FileExists(tbPath) Then
tbFSO.DeleteFile(tbPath)
End If
If Join(tbUsers) <> vbNullString Then
Set File = tbFSO.OpenTextFile(tbPath, 2, True)
For i = 0 to UBound(tbUsers)
If tbUsers(i) <> vbNullString Then
File.WriteLine tbUsers(i)
End If
Next
File.Close
End If
End Sub
Sub timeban_cmd(cmd, Username, Access, Message)
If Access < timeban_cmd_access Then Exit Sub
If UBound(cmd) < 2 Then
If UBound(cmd) = 1 Then
If cmd(1) = "on" Or cmd(1) = "off" Then Exit Sub
End If
tb_error 1, Username: Exit Sub
End If
'// Make sure the the user isn't already timebanned
If IsArray(GetTimebanData(cmd(1))) Then
tb_error 2, Username: Exit Sub
End If
'// Make sure the user isn't an op (commented out until GetInternalData is fixed)
bnetFlags = GetInternalDataByUsername(cmd(1), 1)
If bnetFlags = 2 Or bnetFlags = 18 Then
tb_error 3, Username: Exit Sub
End If
'// Store the current date variable
curDate = Now()
'// Get duration of timeban
If Instr(cmd(2), "/") Then strArg = cmd(2) Else strArg = "n/" & cmd(2) End If
arrDuration = Split(strArg, "/")
'// Make sure the time arguement is an integer
If IsNumeric(arrDuration(1)) Then
If Int(arrDuration(1)) - arrDuration(1) <> 0 Then
tb_error 4, Username: Exit Sub
End If
Else
tb_error 4, Username: Exit Sub
End If
'// Make sure they've entered a valid time letter
If UBound(Filter(Array("d","h","n","s"), arrDuration(0))) = -1 Then
tb_error 5, Username: Exit Sub
End If
'// Get date/time at which user will unbanned
utbDate = DateAdd(arrDuration(0), arrDuration(1), curDate)
'// Create a string showing the number of days/hours/minutes/seconds user will be timebanned for
Select Case arrDuration(0)
Case "d": strTime = arrDuration(1) & " day"
Case "h": strTime = arrDuration(1) & " hour"
Case "n": strTime = arrDuration(1) & " minute"
Case "s": strTime = arrDuration(1) & " second"
End Select
If arrDuration(1) > 1 Then strTime = strTime & "s"
'// Get the reason
If UBound(cmd) > 2 Then
arrMsg = Split(Message)
For i = 3 to UBound(arrMsg)
reason = reason & arrMsg(i) & " "
Next
dspReason = " [" & RTrim(reason) & "]"
reason = Replace(dspReason, "|", chr(164))
End If
'// Add user with timebanner's name, reason, current date/time, and date/time of unban
ReDim Preserve tbUsers(UBound(tbUsers) + 1)
tbUsers(UBound(tbUsers)) = Join(Array(cmd(1), Username, reason, curDate, utbDate), "|")
'// Save the ban message in case this user is offline
tbBan(0) = True: tbBan(1) = "Timebanned " & cmd(1) & " " & chr(167) & "for " & strTime & dspReason & ".": tbBan(2) = Username
AddQ "/ban " & psD2 & cmd(1) & " Timebanned for " & strTime & dspReason
End Sub
Sub untimeban_cmd(cmd, Username, Access)
If Access < untimeban_cmd_access Then Exit Sub
tbanData = GetTimebanData(cmd(1))
'// Make sure this user isn't already timebanned
If IsArray(tbanData) Then
tbUsers(tbanData(5)) = vbNullString
tbUnban(0) = True: tbUnban(1) = cmd(1): tbUnban(2) = Username
AddQ "/unban " & psD2 & cmd(1)
dsp tbDisplay, cmd(1) & " is no longer timebanned.", Username, vbCyan
Else
dsp tbDisplay, "That user is not timebanned.", Username, vbCyan
End If
End Sub
Sub timebanned_cmd(Username, Access)
If Access < timebanned_cmd_access Then Exit Sub
ReDim dispUsers(0)
For i = 0 to UBound(tbUsers)
If tbUsers(i) <> vbNullString Then
arrUser = Split(tbUsers(i), "|")
dispUsers(UBound(dispUsers)) = arrUser(0) & " (" & tbGetTimeLeft(arrUser(4)) & ")"
ReDim Preserve dispUsers(UBound(dispUsers) + 1)
End If
Next
If Join(dispUsers, vbNullString) = vbNullString Then
dsp tbDisplay, "No users are timebanned.", Username, vbCyan
Else
ReDim Preserve dispUsers(UBound(dispUsers) - 1)
dsp tbDisplay, "Timebanned users: " & Join(dispUsers, ", "), Username, vbCyan
End If
End Sub
Sub ctbl_cmd(Username, Access)
If Access < ctbl_cmd_access Then Exit Sub
ReDim tbUsers(0)
dsp tbDisplay, "Timebanned user list cleared.", Username, vbCyan
End Sub
Function GetTimebanData(Username)
For i = 0 to UBound(tbUsers)
If tbUsers(i) <> vbNullString Then
arrUser = Split(tbUsers(i), "|")
If arrUser(0) = LCase(Username) Then
ReDim Preserve arrUser(5): arrUser(5) = i
GetTimebanData = arrUser
Exit Function
End If
End If
Next
End Function
Function tbGetTimeLeft(UTBDate)
daysLeft = DateDiff("d", Now, UTBDate)
hoursLeft = DateDiff("h", Now, UTBDate)
minutesLeft = DateDiff("n", Now, UTBDate)
secondsLeft = DateDiff("s", Now, UTBDate)
If daysLeft > 2 Then
tbGetTimeLeft = "Days left: " & daysLeft
ElseIf hoursLeft > 1 Then
tbGetTimeLeft = "Hours left: " & hoursLeft
ElseIf minutesLeft > 1 Then
tbGetTimeLeft = "Minutes left: " & minutesLeft
Else
tbGetTimeLeft = "Seconds left: " & secondsLeft
End If
End Function
Sub tb_error(errNum, Username)
Select Case errNum
Case 1: errString = "Proper format: " & BotVars.Trigger & "timeban <username> <time>"
Case 2: errString = "That user is already timebanned."
Case 3: errString = "You can't timeban a channel operator."
Case 4: errString = "The Time arguement must be an integer."
Case 5: errString = "You used an invalid time letter. Valid letters: d, h, s"
End Select
dsp tbDisplay, "Timeban command error: " & errString, Username, vbRed
End Sub