'0.935
'// Plugin Script
'// Designed and Scripted By:
'// Xelloss
'//**********************************//
'// CHANGELOG //
'//**********************************//
'// ver .89 by Swent
'// *script now reads from [url]http://users.domaindlx.com/plugs/[/url]
'// ver .90 by Swent
'// *Added code from update plugin
'// *Added automatic plugin updates (see autoUpdatePlugins sub)
'// ver .91 by Swent
'// *Fixed error with .getscript command (problem in AddScript sub)
'// *Fixed the .lset command (it works now)
'// ver .92 by Swent
'// *Fixed type mismatch error in the scriptTimer sub
'// ver .93 by Swent (the big re-write)
'// *Reduced redundant code by adding the ExecuteEvent sub
'// *Replaced the setsub, setsubstat, and getsubstat functions with the new eventExists function.
'// *Modified the changeEnabled sub and renamed it pStatusCmd
'// *Removed the callsub, isNewVersion, reloadscript subs/functions (all unnecessary)
'// *Cleaned up the code overall (added appropriate capitalization, renamed variables, added comments, removed unnecessary code)
'// sub-ver .931 by Swent
'// *Fixed problem with bold/underlined command output by adding the SetChrCodes sub.
'// sub-ver .932 by Jack
'// *New plugin server
'// sub-ver .933 by Jack
'// *Minor edit in changelog
'// sub-ver .934 by Jack
'// *Fixed typo "Pluginsetings"
'// sub-ver .935 by Jack
'// *Stupid mistake somewhere somehow
'//**********************************//
'// NOTES ON PLUGIN SUBS/FUNCTIONS //
'//**********************************//
'// [ Default Settings Subs/Functions ]
'// - SetSetting
'// USAGE: SetSetting "prefix", "SettingName", Setting, "Comment", Overwrite
'// Overwrite is a boolean (True or False). You almost always want to set it to True.
'// - GetSetting
'// USAGE: Setting = GetSetting("prefix", "SettingName")
'// [ Timer Subs/Functions ]
'// - CreateTimer
'// USAGE: CreateTimer "prefix", "TimerName"
'// - TimerInterval
'// USAGE: TimerInterval "prefix", "TimerName", Interval
'// Interval is in seconds (must be an integer).
'// - TimerEnabled
'// USAGE: TimerEnabled "prefix", "TimerName", Enabled
'// Enabled is a boolean (True or False).
'// - GetTimerEnabled
'// USAGE: Enabled = GetTimerEnabled("prefix", "TimerName")
'// Enabled will hold a boolean (True or False).
'// - GetTimeLeft
'// USAGE: timeLeft = GetTimeLeft("prefix", "TimerName")
'// timeLeft will hold the number of seconds left until your timer sub is executed.
'// - GetTimeWaiting
'// USAGE: timeWaiting = GetTimeWaiting("prefix", "TimerName")
'// timeWaiting will hold the number seconds since the last time your timer sub was executed.
'// - RemoveTimer
'// USAGE: RemoveTimer "prefix", "TimerName"
'// [ Message Display Sub ]
'// - dsp
'// USAGE: dsp DisplayID, Message, Username, Color
'// DisplayID must be one of the following integer values:
'// 1 = AddQ
'// 2 = Emote
'// 3 = Whisper
'// 4 = AddChat
'// Color needs to be a vbcolor:
'// vbGreen, vbRed, vbCyan, vbYellow, vbBlue, vbMagenta, vbBlack, vbOrange, vbWhite
'//**********************************//
'// THE PLUGIN SCRIPT //
'//**********************************//
'// [[[ CONSTANT AND GLOBAL DECLARATIONS, OBJECT REFERENCES ]]]
Public Const PS_UPDATE_PATH = "http://scripting.berzerkerweb.com/"
Public psD2 '// holds "*" If Bot is using D2
Public psBold '// holds chr code for bold text
Public psUL '// holds chr code for underlined text
Set psPlugins = CreateObject("Scripting.Dictionary") '// holds plugin files
Set psVersions = CreateObject("Scripting.Dictionary") '// holds plugin versions
Set psTimerInterval = CreateObject("Scripting.Dictionary") '// holds timer intervals
Set psTimerCount = CreateObject("Scripting.Dictionary") '// holds timer counts
Set psTimerEnabled = CreateObject("Scripting.Dictionary") '// holds timer statuses
Set psSettings = CreateObject("Scripting.Dictionary") '// holds plugin settings
Set psFSO = CreateObject("Scripting.FileSystemObject") '// holds the FSO
'// [[[ PUBLIC SUBS/FUNCTIONS ]]]
Public Sub SetSetting(Prefix, SettingName, SettingValue, Comment, Overwrite)
If psSettings.Exists(Prefix & "::" & SettingName) and Overwrite Then
psSettings.Item(Prefix & "::" & SettingName) = SettingValue & "::" & Comment
ElseIf Not psSettings.Exists(Prefix & "::" & SettingName) Then
psSettings.Add Prefix & "::" & SettingName, SettingValue & "::" & Comment
End If
End Sub
Public Function GetSetting(Prefix, SettingName)
If psSettings.Exists(Prefix & "::" & SettingName) then
GetSetting = Split(psSettings.Item(Prefix & "::" & SettingName),"::")(0)
Else
GetSetting = "" 'vbnullstring
End If
End Function
Public Sub CreateTimer(Prefix, TimerName)
psTimerInterval.Add Prefix & "::" & TimerName, 1
psTimerCount.Add Prefix & "::" & TimerName, 1
psTimerEnabled.Add Prefix & "::" & TimerName, false
End Sub
Public Sub RemoveTimer(Prefix, TimerName)
psTimerInterval.Remove Prefix & "::" & TimerName
psTimerCount.Remove Prefix & "::" & TimerName
psTimerEnabled.Remove Prefix & "::" & TimerName
End Sub
Public Sub TimerInterval(Prefix, TimerName, Interval)
psTimerInterval.Item(Prefix & "::" & TimerName) = Interval
psTimerCount.Item(Prefix & "::" & TimerName) = Interval
End Sub
Public Sub TimerEnabled(Prefix, TimerName, Enabled)
psTimerEnabled.Item(Prefix & "::" & TimerName) = Enabled
End Sub
Public Function GetTimerEnabled(Prefix, TimerName)
GetTimerEnabled = psTimerEnabled.Item(Prefix & "::" & TimerName)
End Function
Public Function GetTimeLeft(Prefix, TimerName)
GetTimeLeft = psTimerCount.Item(Prefix & "::" & TimerName) - 1
End Function
Public Function GetTimerWaiting(Prefix, TimerName)
GetTimerWaiting = psTimerInterval.Item(Prefix & "::" & TimerName) - psTimerCount.Item(Prefix & "::" & TimerName) + 1
End Function
Public Sub dsp(DisplayID, Message, Username, Color)
Select Case DisplayID
Case 1: AddQ Message
Case 2: AddQ "/me " & Message
Case 3: AddQ "/w " & psD2 & Username & " " & Message
Case 4: AddChat Color, Message
End Select
End Sub
'// [[[ INTERNAL SUBS/FUNCTIONS ]]]
Private Sub SetChrCodes()
psBold = Chr(255) & "cb"
psUL = Chr(255) & "cu"
End Sub
Private Sub Include(FilePath) '// Thanks imhotep[nu]
On Error Resume Next
Set fileStream = psFSO.OpenTextFile(FilePath, 1)
includeFile = fileStream.ReadAll
fileStream.Close
ExecuteGlobal(includeFile)
End Sub
Private Sub AddScript(Prefix, filename, version)
psPlugins.Add Prefix, filename
If psVersions.Exists(Prefix) Then
psVersions.Item(Prefix) = version
Else
psVersions.Add Prefix, version
End If
SetSetting Prefix, "enabled", True, "", False
If eventExists(Prefix, "timer") then
CreateTimer Prefix, "scripttimer"
End If
Include filename
On Error Resume Next
Execute(Prefix & "_event_load()")
End Sub
Private Function eventExists(Prefix, EventName)
Set FileStream = psFSO.OpenTextFile(psPlugins.Item(Prefix), 1, False, 0)
pluginFile = FileStream.ReadAll
FileStream.Close
If Instr(LCase(pluginFile), "_" & LCase(EventName)) > 0 Then eventExists = True
End Function
Private Function InternalGetTimerEnabled(arg)
InternalGetTimerEnabled = psTimerEnabled.Item(arg)
End Function
Private Function tmpTypoSwitch()
If psFSO.FileExists(BotPath & "plugins\pluginsetings.ini") Then
Dim OldName, NewName
AddChat vbBlue, "Fixing plugin typo"
OldName = BotPath() & "plugins\pluginsetings.ini"
NewName = BotPath() & "plugins\pluginsettings.ini"
Call psFSO.CopyFile(OldName, NewName, True)
AddChat vbGreen, "Fixing typo completed"
Call psFSO.DeleteFile(OldName)
AddChat vbGreen, "Deleted old file!"
End If
End Function
Private Sub pStatusCmd(Username, Message, DisplayID)
GetDBEntry Username, myAccess, myFlags
If (Left(Message, 1) = BotVars.Trigger Or Left(Message, 1) = "/") And (myaccess >= 100 or DisplayID = 4) Then
VetoThisMessage
statusCmd = Split(Mid(Trim(LCase(Message)), 2))
If psPlugins.Exists(statusCmd(0)) then
statusCmd(1) = mid(message, instr(1, message, " ")+1)
If statusCmd(1) = "on" Then
If Not GetSetting(statusCmd(0), "enabled") Then
SetSetting statusCmd(0), "enabled", true, "", true
dsp DisplayID, "The " & statusCmd(0) & " plugin has been enabled.", username, vbGreen
Else
dsp DisplayID, "The " & statusCmd(0) & " plugin is already enabled.", username, vbYellow
End If
ElseIf statusCmd(1) = "off" Then
If GetSetting(statusCmd(0), "enabled") Then
SetSetting statusCmd(0), "enabled", false, "", true
dsp DisplayID, "The " & statusCmd(0) & " plugin has been disabled.", username, vbRed
Else
dsp DisplayID, "The " & statusCmd(0) & " plugin is already disabled.", username, vbYellow
End If
End If
End If
End If
End Sub
Private Sub LoadSettings()
Call tmpTypoSwitch()
If psFSO.FileExists("plugins\pluginsettings.ini") Then
Set psFile = psFSO.OpenTextFile("plugins\pluginsettings.ini", 1)
Lines = Split(psFile.ReadAll, vbCrLf)
For Each Line in Lines
If left(Line,1) = "[" Then
curPrefix = Mid(Line,2,InStr(Line,"]")-2)
ElseIf left(Line, 1) = ";" Then
curComment = Mid(Line,2)
ElseIf InStr(Line,"=") Then
temp = Split(Line,"=")
settingName = temp(0)
settingValue = temp(1)
If psSettings.Exists(curPrefix & "::" & settingName) Then
psSettings.Item(curPrefix & "::" & settingName) = settingValue & "::" & curComment
Else
psSettings.Add curPrefix & "::" & settingName, settingValue & "::" & curComment
End If
curComment = vbNullString
End If
Next
psFile.Close
End If
End Sub
Private Sub LoadPlugins()
'// Make sure we can find the plugins folder
On Error Resume Next
Set pluginFolder = psFSO.GetFolder(BotPath() & "plugins\").Files
If Err.Number <> 0 Then '// This should never happen since we're using BotPath()
AddChat vbRed, "The Plugin Script encountered a problem while trying to locate your plugins folder."
Exit Sub
End If
'// Load the plugins
For Each File In pluginFolder
fileExtension = Mid(File, instrrev(File, ".",-1)+1)
'// Is it a plug file?
If LCase(fileExtension) = "plug" then
Set pluginFile = psfso.OpenTextFile(File, 1)
curPrefix = Mid(pluginFile.ReadLine(), 2)
curVersion = Mid(pluginFile.ReadLine(), 2)
pluginFile.close
'// Has a plugin with the same prefix already been loaded?
If psPlugins.Exists(curPrefix) then
AddChat vbred, "Can not have 2 plugins with the same prefix (2 Plugins have prefix " & curPrefix & ")"
Else
'// Load the plugin
psPlugins.Add curPrefix, File
psVersions.Add curPrefix, curVersion
SetSetting curPrefix, "enabled", true, "", false
If eventExists(curPrefix, "timer") then
CreateTimer curPrefix, "scripttimer"
End If
Include File
End If
End If
Next
AddChat vbGreen, psPlugins.Count & " plugins loaded. Type /plist in the bot to view them."
AddChat vbGreen, "Type /updates in the bot to view updates and new plugins that are available for download."
End Sub
Private Sub SaveSettings()
psKeys = psSettings.Keys
prefixes = psPlugins.Keys
psItems = psSettings.Items
If psFSO.FileExists("plugins\pluginsettings.ini") then
psFSO.DeleteFile("plugins\pluginsettings.ini")
End If
Set psFile = psFSO.OpenTextFile("plugins\pluginsettings.ini", 2, true)
psFile.WriteLine("[ps]")
For i = 0 to psSettings.Count - 1
pstemp = Split(psKeys(i), "::")
If pstemp(0) = "ps" then
pstemp2 = split(psItems(i), "::")
If pstemp2(1) <> "" then
psFile.WriteLine(vbNewLine & ";" & pstemp2(1))
End If
psFile.WriteLine(pstemp(1) & "=" & pstemp2(0))
End If
Next
psFile.WriteLine(vbNewLine & String(50, "_"))
For j = 0 to psPlugins.Count - 1
psFile.WriteLine("[" & prefixes(j) & "]")
For i = 0 to psSettings.count - 1
pstemp = split(psKeys(i), "::")
If pstemp(0) = prefixes(j) then
pstemp2 = split(psItems(i), "::")
psFile.WriteLine("")
If pstemp2(1) <> "" then
psFile.WriteLine(";" & pstemp2(1))
End If
psFile.WriteLine(pstemp(1) & "=" & pstemp2(0))
End If
Next
psFile.WriteLine(vbNewLine & String(50, "_"))
Next
psFile.Close
End Sub
Private Sub BackUpFile(Path, Name, Version)
Set FileStream = psFSO.OpenTextFile(Path & Name & ".txt", 1)
fileContents = FileStream.ReadAll
FileStream.Close
backUpFileName = Path & Name & "-backup(v" & Version & ")"
Do
i = i + 1
If Not psFSO.FileExists(backUpFileName & i & ".txt") Then
Set File = psFSO.OpenTextFile(backUpFileName & i & ".txt", 2, True)
File.WriteLine(fileContents)
AddChat vbCyan, "Current " & Name & ".txt file has been backed up in file> " & backUpFileName & i & ".txt"
Exit Do
End If
Loop
End Sub
Private Sub autoUpdatePluginScript()
'// Get script.txt version on server and user's version
curPSVersion = scINet.OpenURL(PS_UPDATE_PATH & "sctxtver.txt")
Set myPluginScript = psFSO.OpenTextFile(BotPath() & "script.txt", 1)
myPSVersion = Mid(myPluginScript.ReadLine(), 2)
myPluginScript.close
'// Is there are new script.txt version available?
If CDbl(curPSVersion) > CDbl(myPSVersion) Then
BackUpFile BotPath(), "script", myPSVersion
AddChat vbBlue, "Downloading update for the plugin script."
DownloadFile PS_UPDATE_PATH & "script.txt", "script.txt"
AddChat vbGreen, "Your plugin script has been updated."
AddChat vbGreen, "Reload your script file by clicking on the settings menu and choosing 'reload script'."
End If
End Sub
Private Sub autoUpdatePlugins()
Content = scInet.OpenURL(PS_UPDATE_PATH & "list.txt")
Lines = Split(Content, vbCrLf)
For i = 0 to UBound(Lines) - 1
curLine = Split(Lines(i), "|||")
script_name = curLine(0)
script_prefix = curLine(1)
script_version = curLine(2)
script_description = curLine(3)
'// Is there a newer version available for this plugin?
If psPlugins.Exists(script_prefix) And CDbl(psVersions.Item(script_prefix)) < CDbl(script_version) Then
updateNow = MsgBox("A new version (v" & script_version & ") is available for your " & script_name & " plugin. Would you " & _
"like to automatically update this plugin now?", vbYesNoCancel + vbQuestion + vbApplicationModal, "New Version Notification")
If updateNow = vbYes Then
psPrefix = script_prefix
Content = scInet.OpenURL(PS_UPDATE_PATH & "pinfo/" & psPrefix & ".txt")
'// Get the plugin file name
cvars = Split(Content, "|")
If Right(cvars(0),1) = "," Then
cvars(0) = Left(cvars(0), Len(cvars(0)) - 1)
End If
File = Split(cvars(0), ",")(0)
AddChat vbBlue, "Getting File: " & File
If File <> "" Then
DownloadFile PS_UPDATE_PATH & File, BotPath() & "Plugins\" & File
End If
AddChat vbGreen, "Your " & script_name & " plugin was successfully updated."
AddChat vbGreen, "You MUST reload the script by clicking on the Settings menu and choosing 'Reload Script'."
End If
End If
Next
End Sub
Private Sub DownloadFile(strURL, strPath) '// Thanks SoCxFiftyToo
'// Get a byte array from the Given URL
arrBytes = scINet.OpenURL(cstr(strURL), 1)
'// Write the data to a file
Set objWriteFile = psFSO.OpenTextFile(strPath, 2, True)
objWriteFile.Write byteArr2Str(arrBytes)
objWriteFile.Close
End Sub
Private Function byteArr2Str(byteInput) '// Thanks SoCxFiftyToo
Set Stream = CreateObject("ADODB.Stream")
Stream.Type = 1
Stream.Open
Stream.Write byteInput
Stream.Position = 0
Stream.Type = 2
Stream.CharSet = "x-ansi"
strTemp = Stream.ReadText
byteArr2Str = strTemp
Stream.Close
End Function
Private Sub ExecuteEvent(Name, Parameters)
Err.Clear
If Not GetSetting("ps", "debugmode") Then On Error Resume Next
'// Get plugin prefixes and file paths
prefixes = psPlugins.Keys
filePaths = psPlugins.Items
'// In each plugin execute the specified event with parameter values passed from the event's sub below
For i = 0 to psPlugins.Count - 1
If GetSetting(prefixes(i), "enabled") And eventExists(prefixes(i), Name) Then
If Parameters(0) <> vbNullString Then
For j = 0 to UBound(Parameters)
paramString = paramString & "Parameters(" & j & ")" & ","
Next
paramString = Left(paramString, Len(paramString)-1)
End If
Execute("Call " & prefixes(i) & "_event_" & Name & "(" & paramString & ")")
If Err.Number <> 0 Then
AddChat vbRed, Name & " Call Error On File> " & filePaths(i)
AddChat vbRed, "Error Number: " & err.number & " Description: " & err.description
Err.Clear
End If
End If
paramString = vbNullString
Next
End Sub
'// [[[ EVENTS ]]]
'// Fires when the bot executes.
Sub Event_load()
'// Load the plugin settings from pluginsettings.ini
Call LoadSettings()
'// Create the debug mode status setting
SetSetting "ps", "debugmode", False, "debugmode stores the debug mode status", False
'// Create plugins folder if it doesn't exist yet
If Not psFSO.FolderExists("plugins\") Then
psFSO.CreateFolder("plugins\")
AddChat vbgreen, "The plugins folder has been added to your Stealthbot directory."
AddChat vbgreen, "To use plugins you must place plugin files in that folder and reload your script file."
End If
'// Load the plugins
Call LoadPlugins()
'// Enable the script timer with 1 second interval
scTimer.Interval = 1000
scTimer.Enabled = true
'// Put chr codes for bold and underlined text in globals
Call SetChrCodes()
ExecuteEvent "Load", Array(vbNullString)
ExecuteEvent "LoadDisplay", Array(vbNullString)
End Sub
'// Fires when the server sends a blue info-type message. (includes ban and kick messages.)
Sub Event_ServerInfo(Message)
ExecuteEvent "ServerInfo", Array(Message)
End Sub
'// Fires when the server sends a red error-type message. (includes "that user is not logged on." etc.)
Sub Event_ServerError(Message)
ExecuteEvent "ServerError", Array(Message)
End Sub
'// Fires when a user on battle.net talks.
Sub Event_UserTalk(Username, Flags, Message, Ping)
If Right(LCase(Message), 3) = " on" Or Right(LCase(Message), 4) = " off" Then pStatusCmd Username,Message,1
ExecuteEvent "UserTalk", Array(Username,Flags,Message,Ping)
End Sub
'// Fires when a user speaks with /emote.
Sub Event_UserEmote(Username, Flags, Message)
ExecuteEvent "UserEmote", Array(Username,Flags,Message)
End Sub
'// Fires when a whisper is recieved.
Sub Event_WhisperFromUser(Username, Flags, Message)
If Right(LCase(Message), 3) = " on" Or Right(LCase(Message), 4) = " off" Then pStatusCmd Username,Message,1
ExecuteEvent "WhisperFromUser", Array(Username,Flags,Message)
End Sub
'// Fires when a user joins the channel.
Sub Event_UserJoins(Username, Flags, Message, Ping, Product, Level, OriginalStatString)
ExecuteEvent "UserJoins", Array(Username,Flags,Message,Ping,Product,Level,OriginalStatString)
End Sub
'// Fires when a user leaves the channel.
Sub Event_UserLeaves(Username, Flags)
ExecuteEvent "UserLeaves", Array(Username,Flags)
End Sub
'// Fires when battle.net updates a user's flags in the channel.
Sub Event_FlagUpdate(Username, NewFlags, Ping)
ExecuteEvent "FlagUpdate", Array(Username,NewFlags,Ping)
End Sub
'// Fires after a successful login.
Sub Event_LoggedOn(Username, Product)
'// Delete the update plugin if it still exists
updatePlugin = BotPath() & "plugins\updatePluginUpdater.plug"
If psFSO.FileExists(updatePlugin) Then psFSO.DeleteFile(updatePlugin)
'// Connect to plugin server and check for script.txt and plugin updates
AddChat vbYellow, "[PLUGIN SERVER] Connecting..."
testServer = scINet.OpenURL(PS_UPDATE_PATH)
If Not(testServer = vbNullString Or InStr(testServer, "page cannot be displayed")) Then
AddChat vbGreen, "[PLUGIN SERVER] Connected!"
Call autoUpdatePluginScript()
Call autoUpdatePlugins()
Else
AddChat vbRed, "Please note that the Plugin Server is down at the moment. You will not be able to use the /updates or /getscript commands."
End If
'// Is bot using D2?
If Product = "VD2D" Or Product = "PX2D" Then psD2 = "*" Else psD2 = vbNullString End If
ExecuteEvent "LoggedOn", Array(Username,Product)
End Sub
'// Fires once for each user in the channel upon joining a channel.
Sub Event_UserInChannel(Username, Flags, Message, Ping, Product)
ExecuteEvent "UserInChannel", Array(Username,Flags,Message,Ping,Product)
End Sub
'// Flags in this case stores the channel's flags.
Sub Event_ChannelJoin(ChannelName, Flags)
ExecuteEvent "ChannelJoin", Array(ChannelName,Flags)
End Sub
'// Executes after the user presses enter in the send box on the bot. Text will always be processed by the bot and sent to battle.net before arriving here.
Sub Event_PressedEnter(Text)
'* /// Built-In Plugin Script Commands /// *
If Instr(Text, " ") = 0 Then tmpText = Text & " " Else tmpText = Text End If
cmd = Split(Trim(LCase(tmpText)), " ")
'* Command to view all new plugins and updates available for download - Thanks SoCxFiftyToo!
If cmd(0) = "/updates" Or cmd(0) = BotVars.Trigger & "updates" Then
VetoThisMessage
If psPlugins.Exists("update") Then Exit Sub
Content = scInet.OpenURL(PS_UPDATE_PATH & "list.txt")
If Content = vbNullString Or Instr(Content, "page cannot be displayed") Then
AddChat vbRed, "The plugin server is down. Please try again later."
Exit Sub
End If
Lines = Split(Content, vbCrLf)
AddChat vbWhite, " "
AddChat vbYellow, psUL & psBold & "Available Scripts For Download"
AddChat vbGreen, "Green text represents new scripts"
AddChat vbCyan, "Teal text represents updated scripts"
For i = 0 to UBound(Lines) - 1
curLine = Split(Lines(i), "|||")
script_name = curLine(0)
script_prefix = curLine(1)
script_version = curLine(2)
script_description = curLine(3)
'// Lets check if we should display this script to the user
If Not psPlugins.Exists(script_prefix) Then
'// Script is not installed
IsAvail = vbGreen
ElseIf CDbl(psVersions.Item(script_prefix)) < CDbl(script_version) Then
'// Script is newer than the currently installed version
IsAvail = vbCyan
Else
IsAvail = 0
End If
'// Yep, this script should be displayed
If IsAvail <> 0 Then '// IsAvail will be set to the proper color, or 0 if current version is installed
AddChat vbWhite, String(58, "-")
AddChat IsAvail, "Script Name: " & psUL & script_name
AddChat IsAvail, "Script Version: " & script_version
AddChat IsAvail, "Description: " & script_description
AddChat IsAvail, "Prefix: " & psBold & script_prefix
End If
Next
AddChat vbWhite, String(58, "-")
AddChat vbYellow, "Type /getscript PREFIX (where PREFIX is the prefix of the script that you want)."
'* Command to download a plugin from the plugin server - Thanks SoCxFiftyToo!
ElseIf cmd(0) = BotVars.Trigger & "getscript" Or cmd(0) = "/getscript" Then
If psPlugins.Exists("update") Then Exit Sub
VetoThisMessage
prefix = Mid(Text, 12)
serverTest = scInet.OpenURL(PS_UPDATE_PATH)
If serverTest = vbNullString Or Instr(serverTest, "page cannot be displayed") Then
AddChat vbRed, "The plugin server is down. Please try again later."
Exit Sub
End If
Content = scInet.OpenURL(PS_UPDATE_PATH & "pinfo/" & prefix & ".txt")
If Instr(LCase(Content), "the page cannot be found") Then
AddChat vbRed, "Invalid command: The prefix '" & prefix & "' does not exist."
AddChat vbRed, "Type /updates to view the prefixes of available plugins."
Else
AddChat vbWhite, "*** NOTE ***"
AddChat vbWhite, "If you get any messages asking to continue execution of the script,"
AddChat vbWhite, "you MUST hit Continue. Stopping the script WILL CAUSE ERRORS!"
'// Get the script name
cvars = Split(Content, "|")
script_name = cvars(1)
'// Get the plugin and additional files
If Right(cvars(0),1) = "," Then
cvars(0) = Left(cvars(0), Len(cvars(0)) - 1)
End If
Files = Split(cvars(0), ",")
newPluginPath = BotPath() & "Plugins\" & Files(0)
'// If plugin is currently installed, only download the first file in the list
'// The first file will always be the actual script.
If psPlugins.Exists(prefix) Then
iMax = 0
Else
iMax = UBound(Files)
End If
'// Get the files needed for the script
For i = 0 to iMax
AddChat vbBlue, "Getting File: " & Files(i)
If Files(i) <> "" Then
DownloadFile PS_UPDATE_PATH & Files(i), BotPath() & "Plugins\" & Files(i)
End If
Next
'// Is this a new plugin or an update?
If Not psPlugins.Exists(prefix) Then
'// We are installing a new script, lets load it up!!
AddScript prefix, newPluginPath, cvars(2)
AddChat vbGreen, "The " & script_name & " plugin was installed and loaded successfully."
Else
AddChat vbGreen, "The " & script_name & " plugin was updated successfully."
AddChat vbGreen, "You MUST reload the script by clicking on the Settings menu and choosing 'Reload Script'."
End If
End If
'* Command to turn debugging on/off
ElseIf cmd(0) = BotVars.Trigger & "debug" Or cmd(0) = "/debug" Then
VetoThisMessage
If cmd(1) = "on" Then
AddChat vbCyan, "Debug Mode has been Enabled."
psDebugOn = True
SetSetting "ps", "debugmode", true, "this stores the debug mode status", true
ElseIf cmd(1) = "off" Then
AddChat vbCyan, "Debug Mode has been Disabled."
psDebugOn = False
SetSetting "ps", "debugmode", false, "this stores the debug mode status", true
End If
'* Command to load plugin settings
ElseIf cmd(0) = BotVars.Trigger & "lset" Or cmd(0) = "/lset" Then
VetoThisMessage
AddChat vbyellow, "Loading plugin settings..."
Call loadsettings()
AddChat vbgreen, "Settings loaded."
'* Command to list all plugins currently loaded
ElseIf cmd(0) = BotVars.Trigger & "plist" Or cmd(0) = "/plist" Then
VetoThisMessage
AddChat vbWhite, " ", vbCyan, psBold & "Your Plugin List"
prefixes = psPlugins.Keys
pluginFilePaths = psPlugins.Items
For i = 0 to psPlugins.count - 1
fileName = Mid(pluginFilePaths(i), InStr(LCase(pluginFilePaths(i)), "plugins\")+8)
If GetSetting(prefixes(i), "enabled") then
AddChat vbWhite, String(58, "-")
AddChat vbBlue, "Prefix: " & psBold & prefixes(i)
AddChat vbCyan, "Version: " & psVersions.Item(prefixes(i))
AddChat vbCyan, "Filename: " & fileName
AddChat vbCyan, "Status: " & "Enabled"
Else
AddChat vbWhite, String(58, "-")
AddChat vbBlue, "Prefix: " & psBold & prefixes(i)
AddChat vbCyan, "Version: " & psVersions.Item(prefixes(i))
AddChat vbCyan, "Filename: " & fileName
AddChat vbYellow, "Status: " & "Disabled"
End If
Next
'* Command to enable/disable plugins
ElseIf Right(LCase(Text), 3) = " on" Or Right(LCase(Text), 4) = " off" Then
pStatusCmd BotVars.Username, Text, 4
End If
ExecuteEvent "PressedEnter", Array(Text)
End Sub
'// Executes when the bot recieves a profile return from the server.
Sub Event_KeyReturn(KeyName, KeyValue)
ExecuteEvent "KeyReturn", Array(KeyName,KeyValue)
End Sub
'// Executes when the bot is closed. You can use this sub to write things to disk before the bot shuts down.
Sub Event_Close()
ExecuteEvent "Close", Array(vbNullString)
Call SaveSettings()
End Sub
'// [[[ SCRIPT TIMER ]]]
'// Executes every x milliseconds, as set by using its .interval property.
Sub scTimer_Timer()
pskeys = psTimerEnabled.Keys
psitems = psTimerEnabled.Items
Err.Clear
If Not GetSetting("ps", "debugmode") then
On Error Resume Next
End If
For i = 0 to psTimerEnabled.count - 1
If InternalGetTimerEnabled(pskeys(i)) Then
temp = Split(pskeys(i),"::")
prefix = temp(0)
timerName = temp(1)
If GetSetting(prefix, "enabled") then
If psTimerCount.Item(pskeys(i)) = 1 then
Execute(prefix & "_" & timerName & "_timer()")
If err.number <> 0 And err.number <> 13 Then
AddChat vbred, "Timer Call Error On Script: prefix> " & prefix & " timername> " & timerName
AddChat vbred, "Error Number: " & err.number & " description: " & err.description
Err.Clear
End If
psTimerCount.Item(pskeys(i)) = psTimerInterval.Item(pskeys(i))
Else
psTimerCount.Item(pskeys(i)) = psTimerCount.Item(pskeys(i)) - 1
End If
End If
End If
Next
End Sub