R77 Community Forum Archive
Programming => Scripting => Requests => Topic started by: ArticWolve on November 13, 2008, 05:52:31 AM
-
Can you please script this Phrasewarn plugin for Stealth Bot? Criteria is listed below.
When a phrasewarn word is said, a warn is recorded and they are told via a whisper they have a warn against them. Responses can be turned on or off via a command.
The punishment can be set to Kick, Ban, Timeban, Exiled, (if the bot has ops) or removal of access (if they have any).
When carrying out the above (Kick, Ban, Timeban, Exiled (Ban command first then exiled)), the reason should read "[PWARN] Your PWarn amount has reached its maximum. Please see the bot's administrator to get un" & PWarnpunishment "." (Unless of course its RA)
Use of a database for number of warns and the reason they were warned, along with the date and time of the incident(s) so no one can accuse it of being edited.
PWList uses a text file for easy access to add multiple words at once.
Script prefix is pwarns
Edit: Script has a User Bypass list. If user has Flags "A", "M", or "O", or on a Safelist database (IE Safe.dat) User cannot be warned. Also, this script should be designed to work with modacc (Mod Access), Timeban, and Phrases that are not tolerated.
Safedel and safeadd are disabled.
The commands are as follows:
IN BOT ONLY
/pwall
~Addchats the following information:
User in Cyan; Warn amounts in Orange unless warn amount >= Max warns then Red; the word that they got warned for should appear in Blue
"ADMIN", "MODERATOR", "OWNER" FLAGS
Definition of Admin: User has at least 100 access or has flag of "R"
Definition of Moderator: Bot holds Shaman and is WAR3 or has flag of "M"
Definition of Owner: User has at least 150 access AND has flag of "O"
These commands will have the trigger built into the command. I am using " ? " for "R", "M", "O" commands.
"R" "M" "O"
?pw <on/off>
~Sets the pwarn script on/off
~~On means it will record warns
~~Off means no one will be warned
?pwstatus
~Shows the status of ?pw
~~Whispers the current status of ?PW and the current punishment
.papprove <Username>
~Allows Username to be readded to the safelist
.pdisprove <Username>
~Does not allow Username to be readded to the safelist
.psafelist
~Displays usernames who are pending approval to be added back to the safelist.
90 Access
.pwa [NEW AMOUNT]
~Changes the max warn amount before an action is carried out.
.pwp [NEW PUNISHMENT]
~Changes the current punishment to [NEW PUNISHMENT]. Can only be set to: Kick, Ban, Exile, Timeban, or RA (Removal of Access).
.pwspam <on/off>
~Toggles responses on or off.
70 Access
?addpwarn <Phrase>
~Adds PHRASE to the Pwarnlist
~~Must be at least 3 letters long
~~Use of * means wildcard
~~~So if hat is on the pwlist
~~~you will get warned for saying that
?delpwarn <Phrase>
~Removes PHRASE from the Pwarnlist
~~Returns Error if word is not on list
30 Access
.cpw [Username]
~whisper member's current warn count
~~Users with the flags "A", "M", "O" or access of 60 or higher can use this command to check someoneelse's warn amount.
20 Access
.pwlist
~shows the words that will earn you a warn and cost you a ban, kick, exile, etc
~~Command can only be used once every 10 seconds (plus 3 per every word to prevent flooding)
~~~So if Pwlist is:
~~~Then the next time it could be said is 16 seconds later (IF THIS IS POSSIBLE!)
Edit:
Better description: Basicallly, the bot checks if the user has access or not.
Is this user spamming a phrase? Then PWarnReason = Spamming
If not, is the user Abusing Access? (IE 5 warns/bans/kicks within 1 minute total) If Yes PWarnReason = Abuse of Access
If not, bot checks to see if the user is safelisted. If so, user is removed from safelist after PWA/2 is met. User cannot be readded to safelist unless approved by any Admin, Moderator, or the Owner of the Bot.
If PWarnKick = "False" then the Bot records Username, Offense (Phrase if a word), Date (Day Month Year) and time, and whispers user "[PWarn] You have been warned for " & PWarnReason. Else it kicks the person from the channel with [/color]"[PWarn] You have been warned for " & PWarnReason as the kick message.
THIS IS BASIC TEMPLATE OF WHAT I WOULD LIKE SO FAR (And what I can get across without being misunderstood). Will edit when I would like something else added.
-
I might do this.
-
Doesn't mind me. I know you are busy with Fail Bot and all, so take your time.
-
AddChats with multiple colors are beta only, FYI.
I would do this script, but Hero already beat me to it =/
-
You can do it ;\
-
Hmm doesn't mind me who makes it, I just want it so it works. Also I forgot one detail that I added ><
-
At the moment, you can use the computer at anytime. I don't. For now, you do it. I will be off and on for awhile now up to a month.
-
Fine. I will do this.
This looks like its going to be a monster script. It's possible for me to do though.
-
Cool i want this 2
-
Thanks a million Vector!
-
I will supplement shadow's request for the /pwall command to StealthBot 2.6r3. I can't do multi-colors in 2.6r3. It will be vbCyan.
I will also put this up on the server.
-
Meh..... oh well... Make it Orange ><
-
Just to tell you right away, the phrase warn plugin has to add a dummy account:
If GetSetting("pw", "Dummy") = "" Then
SetSetting "pw", "Dummy", True, "", False
Command BotVars.Username, "/set DummyAcc 999", True
AddChat vbGreen, "[PW] Set up the dummy account for the timeban command."
End If
Case "kick", "ban"
AddQ "/" & pwWarnAction & " " & PsD2 & Username & " Phrase warns activated"
Case "timeban"
Call timeban_Event_UserTalk("DummyAcc", "", BotVars.Trigger & "timeban " & Username & " " & pwNumMinutes, 0)
End Select
This is so it can reference the timeban plugin without me having to more code in the plugin than I have to.
-
Just have people change it MANUALLY to their account ><
-
I will use the bot's username instead.
-
Better ><
-
I will not add .plist, and I will also not build the trigger into the command.
the reason for .plist is because the user is safelisted already with 20+ access.
-
I see no .plist >< .pwlist is the words that are "phrasewarned." Also, this BYPASSES the safelist......
And those that have any of the "Admin", "Owner", "Moderator" flags are the only ones immune....
-
.papprove <Username>
~Allows Username to be readded to the safelist
.pdisprove <Username>
~Does not allow Username to be readded to the safelist
.psafelist
~Displays usernames who are pending approval to be added back to the safelist.
Explain these a bit more.
-
Meh okay....
Example: Assume Max Warns before the "Final" punishment is given is 5.
At 1, he recieves a verbal warning by the bot.
At 2, his access is set to 0 and flags to L. Another verbal warning is given by the bot. Removed from safelist; added to Safelist pending.
>> .papprove <Name>
>> User is (re)added to the safelist. First checks the disproved list; if on it, removes user and adds them to the safelist.
>> .pdisprove <Name>
>> User CAN NEVER be added to the safelist unless .papprove <Name> is used.
At 3, Removed from safelist; added to Safelist pending; the punishment Level 3 is carried out: Kick/Timeban
At 4, Removed from safelist; added to Safelist pending; the punishment Level 2 is carried out: Removal of access/Temporary Restricted Access (modacc)
At 5, Removed from safelist; added to Safelist pending; the punishment Level 1 is carried out: Removal of Access/Banned/Exiled
-
Alright. This is your script request, but it's getting way too complicated. I don't want to do more than I have to.
- User, upon reaching max warn count, will be punished based on pwWarnAction
- I will add pending safelist
And asking me to put in another plugin is just insane... I've already got to reference timeban.
I'm just saying what to me is feasible right now. Anything more, and the StealthBot community might not like it.
Kat, you had no freaking clue as to the script you were requesting.
@Shadow: renamed "pw <on/off>" to "pww <on/off>" as the former would turn the script off -.-
I will place this on the plugin server once it is bug free.
'pw
'0.1
'&Phrase Warns:Vector:Warns people for saying specific words or phrases
'*
'*Type /r77 open pw for more information on this plugin. Go to %topic=281 also for more info.
'*
'*timeban.plug
'*Moderation Related
'// COMMANDS: (be sure to use your bot's trigger for these)
'// /pwall = Lists all warns. (in-bot only)"
'// COMMANDS ONLY AVAILABLE WITH FLAG A, M, OR O
'// pww <on/off> = sets whether the plugin will warn users or not
'// pwstatus = returns whether users will be warned or not
'// papprove = Approves a user to be added to the safelist
'// pdisapprove = Denies a user to be added to the safelist
'// psafelist = Shows a list of all users awaiting to be added to the safelist
'// 90 access or more
'// pwa = Changes max warn limit before punishing user
'// pwp = Changes the current punishment (see below)
'// pwspam = Toggles responses on or off
'// 70 access or more
'// addpwarn = Adds a phrase warn
'// delpwarn = Removes a phrase warn
'// 30 access or more
'// cpw = Whispers a username the warn count of another user
'// default action after warn limit has been reached (kick/ban)
'// Punishments:
'// kick = kicks a user for saying a phrase ban
'// ban = bans a user for saying a phrase ban
'// timeban = timebans a user for saying a phrase ban
'// exile = exiles the user if they say a phrase ban
'// ra = removes access if a user says a phrase ban
Private pwWarnAction
pwWarnAction = "kick"
'// Default minutes to time ban user if timeban is used
Dim pwNumMinutes
pwNumMinutes = 5
Const warnFile = "plugins\PhraseWarnUsers.txt"
'// Locks commands to prevent spam
Private pwCmdLocked
pwCmdLocked = False
'// holds the amount of time a user needs to wait before issuing another command
Dim pwSpamTime
pwSpamTime = 0
Dim flagAcc
flagAcc = Array("a", "m", "o")
'// default amount of warnings before taking action
Dim pwWarnLimit
pwWarnLimit = 3
'// Will the plugin warn users?
Private pwWarnEnabled
pwWarnEnabled = True
'// Will the plugin whisper users when they are warned?
Private pwWhisperMessage
pwWhisperMessage = True
Private preparePWString
Dim fso
Set fso = CreateObject("Scripting.FileSystemObject")
Dim dicPhraseWarns, dicWarnedUsers, dicReasons, dicWords, dicSafeList
Set dicPhraseWarns = CreateObject("Scripting.Dictionary")
set dicWarnedUsers = CreateObject("Scripting.Dictionary")
Set dicReasons = CreateObject("Scripting.Dictionary")
Set dicPhrases = CreateObject("Scripting.Dictionary")
Set dicPendSafeList = CreateObject("Scripting.Dictionary")
Sub pw_Event_Load()
AddChat vbGreen, "Vector's Phrase Warn plugin v" & psVersions.Item("pw") & " loaded."
If Getsetting("pw", "warnLimit") = "" Then
SetSetting "pw", "warnLimit", pwWarnLimit, "Number of warns before action is carried out", False
Else
pwWarnLimit = GetSetting("pw", "warnLimit")
End If
If Getsetting("pw", "warnEnabled") = "" Then
SetSetting "pw", "warnEnabled", pwWarnEnabled, "Determines whether users will be warned or not", False
Else
pwWarnEnabled = GetSetting("pw", "warnEnabled")
End If
If GetSetting("pw", "warnAction") = "" Then
SetSetting "pw", "warnAction", pwWarnAction, "Action to take when user reaches maximum warn level", False
Else
pwWarnAction = GetSetting("pw", "warnAction")
End If
If GetSetting("pw", "whisperMessage") = "" Then
SetSetting "pw", "whisperMessage", pwWhisperMessage, "Determines whether or not the bot whispers a user when they receive a warn", False
Else
pwWhisperMessage = GetSetting("pw", "whisperMessage")
End If
If GetSetting("pw", "Dummy") = "" Then
SetSetting "pw", "Dummy", True, "", False
Command BotVars.Username, "/set " & BotVars.Username & " 999", True
AddChat vbGreen, "[PW] Set up the dummy account for the timeban command."
End If
If GetSetting("pw", "PhraseWarns") Then
preparePWString = Lcase(GetSetting("pw", "PhraseWarns"))
splString = Split(preparePWString, ", ")
For i=0 to Ubound(splString)
dicPhraseWarns.Item(splString(i)) = 1
Next
End If
If fso.FileExists(warnFile) Then
Set initWarns = fso.OpenTextFile(warnFile, 1, True)
lines = Split(initWarns.ReadAll, vbNewLine)
For i=0 to Ubound(lines)
user = Split(lines(i), ":")(0)
warnCount = Split(lines(i), ":")(1)
reason = Split(lines(i), ":")(2)
dicWarnedUsers.Item(user) = warnCount
dicReasons.Item(user) = reason
Next
initWarns.Close
End If
End Sub
Sub pw_Event_PressedEnter(text)
If Lcase(text) = "/pwall" Then
If dicWarnedUsers.Count = 0 Then
AddChat vbCyan, "There are currently no users with any warns."
Exit Sub
End If
For each key in dicWarnedUsers.Keys
getWC = dicWarnedUsers.Item(key)
AddChat vbOrange, key & " has " & getWC & " warns. He/She was last warned for the word/phrase """ _
& dicPhrases.Item(key) & """."
Next
End If
Call pw_ProcessInput(BotVars.Username, text, 4)
End Sub
Sub pw_Event_WhisperFromUser(Username, Flags, Message)
Call pw_ProcessInput(Username, Message, 3)
End Sub
Sub pw_Event_UserTalk(Username, Flags, Message, Ping)
Call pw_ProcessInput(Username, Message, 1)
GetDBEntry Username, a, f
If InArray(flagAcc, f) Then Exit Sub
If Not pwWarnEnabled Then Exit Sub
countWords = Ubound(Split(Message))
If dicPhraseWarns.Exists(Message) Then
If dicWarned.Users.Item(Username) = pwWarnLimit Then
dicWarnedUsers.Remove(Username)
Select Case Lcase(pwWarnAction)
Case "kick", "ban"
AddQ "/" & pwWarnAction & " " & PsD2 & Username & " Phrase warn count reached"
Case "timeban"
Call timeban_Event_UserTalk(BotVars.Username, "", BotVars.Trigger & "timeban " & Username & " " & pwNumMinutes, 0)
Case "exile"
Command BotVars.Username, "/exile " & Username & " Phrase warn count reached", True
Case "ra"
GetDBEntry Username, a, f : If a <> -1 Then Command BotVars.Username, "/rem " & Username, True
Case Else
AddChat vbRed, "Invalid phrase warn punishment. Use ""ban"", ""kick"", ""exile"", ""timeban"", or ""ra""."
End Select
If IsSafelisted(Username) Then
Command BotVars.Username, "/safedel " & Username, True
dicPendSafeList.Item(Username) = 1
End If
Else
dicWarnedUsers.Item(Username) = dicWarnedUsers.Item(Username) + 1
If pwWhisperMessage Then AddQ "/w " & PsD2 & Username & " You have been warned for the phrase """ & Message & """. You have " & dicWarnedUsers.Item(Username) & " warns."
End If
ElseIf countWords > 0 Then
For Each key in dicPhraseWarns.Keys
If InStr(Lcase(Message), key) Then
If dicWarnedUsers.Users.Item(Username) = pwWarnLimit Then
dicWarnedUsers.Remove(Username)
Select Case Lcase(pwWarnAction)
Case "kick", "ban"
AddQ "/" & pwWarnAction & " " & PsD2 & Username & " Phrase warns activated"
Case "timeban"
Call timeban_Event_UserTalk(BotVars.Username, "", BotVars.Trigger & "timeban " & Username & " " & pwNumMinutes, 0)
Case "exile"
Command BotVars.Username, "/exile " & Username & " Phrase warn count reached", True
Case "ra"
GetDBEntry Username, a, f
If a <> -1 Then Command BotVars.Username, "/rem " & Username, True
Case Else
AddChat vbRed, "Invalid phrase warn punishment. Use ""ban"", ""kick"", ""exile"", ""timeban"", or ""ra""."
End Select
If IsSafelisted(Username) Then
Command BotVars.Username, "/safedel " & Username, True
dicPendSafeList.Item(Username) = 1
End If
Exit Sub
Else
dicWarnedUsers.Item(Username) = dicWarnedUsers.Item(Username) + 1
If pwWhisperMessage Then AddQ "/w " & PsD2 & Username & " You have been warned for the phrase """ & key & """. You have " & dicWarnedUsers.Item(Username) & " warns."
Exit Sub
End If
End If
Next
End If
End Sub
Sub pw_Event_ProcessInput(Username, Message, Origin)
If Left(Message, Len(BotVars.Trigger)) <> BotVars.Trigger And Left(Message, 1) <> "/" Then Exit Sub
If pwCmdLocked Then Exit Sub
If Len(Message) = Len(Botvars.Trigger) Then Exit Sub
GetDBEntry Username, a, f
If Origin = 4 Then
Cmd = Split(Mid(Lcase(Trim(Message)), 2), " ")
Else
Cmd = Split(Mid(Lcase(Trim(Message)), Len(BotVars.Trigger) + 1), " ")
End If
ucmd = Ubound(cmd)
Select Case cmd(0)
Case "pww"
If Not InArray(flagAcc, f) Then Exit Sub
If cmd(1) = "on" Then
pwWarnEnabled = True
DSP Origin, "Users will be warned if they say a flagged phrase.", Username, vbWhite
ElseIf cmd(1) = "off" Then
pwWarnEnabled = False
DSP Origin, "Users will be not warned if they say a flagged phrase.", Username, vbWhite
End If
Case "pwp"
If a < 90 Then Exit Sub
If ucmd < 0 Or ucmd > 1 Then Exit Sub
tempCheck = Array("kick", "ban", "exile", "timeban", "ra")
found = false
For i=0 to Ubound(tempCheck)
If Lcase(tempCheck(i)) = cmd(1) Then
found = True
End If
Next
If found Then
pwWarnAction = cmd(1)
DSP Origin, "Changed phrase warn punishment to " & cmd(1), Username, vbWhite
Else
DSP Origin, "Invalid punishment. Possible punishments: " & Join(tempCheck, ", ")
End If
Case "pwa"
If a < 90 Then Exit Sub
If ucmd = 0 Then Exit Sub
If Not IsNumeric(cmd(1)) Then
DSP Origin, "Amount must be an integer.", Username, vbWhite
Exit Sub
End If
pwWarnLimit = cmd(1)
DSP Origin, "Changed the maximum warn level to " & cmd(1)
Case "pwstatus"
If Not InArray(flagAcc, f) Then Exit Sub
If ucmd = 1 Then Exit Sub
DSP Origin, "Phrase warn status: " & pwWarnEnabled & ". Curren punishment: " & pwWarnAction, Username, vbWhite
Case "papprove"
If Not InArray(flagAcc, f) Then Exit Sub
If ucmd <> 1 Then Exit Sub
If Not dicPendSafeList.Exists(cmd(1)) Then
DsP Origin, "That user is not pending addition to the safelist.", Username, vbWhite
Else
DSP Origin, cmd(1) & " has been approved to the safelist.", Username, vbWhite
dicPendSafeList.Remove(cmd(1))
Command BotVars.Username, "/safeadd " & cmd(1), True
End If
Case "pdisapprove"
If ucmd = 0 Or ucmd > 1 Then Exit Sub
If Not InArray(flagAcc, f) Then Exit Sub
If Not dicPendSafeList.Exists(cmd(1)) Then
DsP Origin, "That user is not pending addition to the safelist.", Username, vbWhite
Else
DSP Origin, "Denied " & cmd(1) & " from being re-added to the safelist.", Username, vbWhite
dicPendSafeList.Remove(cmd(1))
End If
Case "psafelist"
If ucmd = 0 Or ucmd > 1 Then Exit Sub
If Not InArray(flagAcc, f) Then Exit Sub
For each key in dicPendSafeList.Keys
pendString = pendString & key & ", "
Next
DSP Origin, "The following users are waiting approval to the safelist: " & Left(pendString, Len(pendString) - 2), Username, vbWhite
Case "cpw"
If a < 30 Then Exit Sub
If ucmd = 0 Or ucmd > 1 Then Exit Sub
If ucmd = 0 Then
DSP Origin, "You have " & dicWarnedUsers.Item(Username) & " warns.", Username, vbWhite
Exit Sub
End If
If Not dicWarnedUsers.Exists(cmd(1)) And a > 60 Then
DSP Origin, "That user does not exist."
ElseIf a < 60 Then
DSP Origin, "You do not have enough access to check the status of another user.", Username, vbWhite
Else
DSP Origin, cmd(1) & " has " & dicWarnedUsers.Item(cmd(1)) & " warns.", Username, vbWhite
End If
Case "pwlist"
If a < 20 Then Exit Sub
DSP Origin, "The following words/phrases will give you a warning: " & preparePWString, Username, vbWhite
Case "addpwarn"
If a < 70 Then Exit Sub
If ucmd < 1 Then Exit Sub
addPhrase = Split(Message, cmd(0) & " ")(1)
DSP Origin, "Added the phrase """ & addPhrase & """ to the phrase warn list.", Username, vbWhite
dicPhraseWarns.Item(addPhrase) = 1
Case "delpwarn"
If a < 70 Then Exit Sub
If ucmd < 1 Then Exit Sub
getPhrase = Split(Message, cmd(0) & " ")(1)
If Not dicPhraseWarns.Exists(getPhrase) Then
DSP Origin, "That is not a valid word/phrase on the phrase list.", Username, vbWhite
Else
dicPhraseWarns.Remove(getPhrase)
DSP Origin, "Removed the word/phrase " & getPhrase & " from the phrase list.", Username, vbWhite
End If
End Select
countWords = Ubound(Split(Message))
'// Determine length of time before the command can be used again
pwSpamTime = Int(10 + (countWords * 3))
pwCmdLocked = True
TimerInterval "pw", "UnlockCommands", pwSpamTime
TimerEnabled "pw", "UnlockCommands", True
End Sub
Sub pw_UnlockCommands_Timer()
pwCmdLocked = False
TimerEnabled "pw", "UnlockCommands", False
End Sub
Function InArray(Arr, Item)
If Not IsArray(Arr) Then
InArray = False
Else
Found = False
If Len(item) > 1 Then
For i=0 to Len(Item) - 1
getFlag = Mid(Item, i+1, 1)
For ii=0 to Ubound(Arr)
If Lcase(arr(ii)) = Lcase(getFlag) Then
InArray = True
Exit Function
End If
Next
Next
Else
For i = LBound(Arr) To UBOund(Arr)
If LCase(Arr(i)) = LCase(Item) Then
InArray = True
Exit Function
End If
Next
InArray = False
End If
End If
End Function
Sub pw_Event_Close()
SetSetting "pw", "warnLimit", pwWarnLimit, "Number of warns before action is carried out", False
SetSetting "pw", "warnAction", pwWarnAction, "Action to take when user reaches maximum warn level", False
SetSetting "pw", "warnEnabled", pwWarnEnabled, "Determines whether users will be warned or not", False
SetSetting "pw", "whisperMessage", pwWhisperMessage, "Determines whether or not the bot whispers a user when they receive a warn", False
preparePWString = vbNullString
For Each key in dicPhraseWarns.Keys
preparePWString = preparePWString & key & ", "
Next
If Len(preparePWString) <= 2 Then Exit Sub
preparePWString = Left(preparePWString, Len(preparePWStreing) - 2)
SetSetting "pw", "PhraseWarns", preparePWString, "List of phrase warns", False
Set writeWarns = fso.OpenTextFile(warnFile, 2, True)
For Each key in dicWarnedUsers.Keys
writeWarns.WriteLine key & ":" & dicWarnedUsers.Item(key) & ":" & dicReasons.Item(key)
Next
writeWarns.Close
End Sub
-
Fair enough. Anyways, will test soon as possible.....