/
Template_StreamlabsSystem.py
99 lines (82 loc) · 3.56 KB
/
Template_StreamlabsSystem.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
#---------------------------
# Import Libraries
#---------------------------
import os
import sys
import json
sys.path.append(os.path.join(os.path.dirname(__file__), "lib")) #point at lib folder for classes / references
import clr
clr.AddReference("IronPython.SQLite.dll")
clr.AddReference("IronPython.Modules.dll")
# Import your Settings class
from Settings_Module import MySettings
#---------------------------
# [Required] Script Information
#---------------------------
ScriptName = "Template Script"
Website = "https://www.streamlabs.com"
Description = "!test will post a message in chat"
Creator = "AnkhHeart"
Version = "1.0.0.0"
#---------------------------
# Define Global Variables
#---------------------------
global SettingsFile
SettingsFile = ""
global ScriptSettings
ScriptSettings = MySettings()
#---------------------------
# [Required] Initialize Data (Only called on load)
#---------------------------
def Init():
# Create Settings Directory
directory = os.path.join(os.path.dirname(__file__), "Settings")
if not os.path.exists(directory):
os.makedirs(directory)
# Load settings
SettingsFile = os.path.join(os.path.dirname(__file__), "Settings\settings.json")
ScriptSettings = MySettings(SettingsFile)
ScriptSettings.Response = "Overwritten pong! ^_^"
return
#---------------------------
# [Required] Execute Data / Process messages
#---------------------------
def Execute(data):
if data.IsChatMessage() and data.GetParam(0).lower() == ScriptSettings.Command and Parent.IsOnUserCooldown(ScriptName,ScriptSettings.Command,data.User):
Parent.SendStreamMessage("Time Remaining " + str(Parent.GetUserCooldownDuration(ScriptName,ScriptSettings.Command,data.User)))
# Check if the propper command is used, the command is not on cooldown and the user has permission to use the command
if data.IsChatMessage() and data.GetParam(0).lower() == ScriptSettings.Command and not Parent.IsOnUserCooldown(ScriptName,ScriptSettings.Command,data.User) and Parent.HasPermission(data.User,ScriptSettings.Permission,ScriptSettings.Info):
Parent.BroadcastWsEvent("EVENT_MINE","{'show':false}")
Parent.SendStreamMessage(ScriptSettings.Response) # Send your message to chat
Parent.AddUserCooldown(ScriptName,ScriptSettings.Command,data.User,ScriptSettings.Cooldown) # Put the command on cooldown
return
#---------------------------
# [Required] Tick method (Gets called during every iteration even when there is no incoming data)
#---------------------------
def Tick():
return
#---------------------------
# [Optional] Parse method (Allows you to create your own custom $parameters)
#---------------------------
def Parse(parseString, userid, username, targetid, targetname, message):
if "$myparameter" in parseString:
return parseString.replace("$myparameter","I am a cat!")
return parseString
#---------------------------
# [Optional] Reload Settings (Called when a user clicks the Save Settings button in the Chatbot UI)
#---------------------------
def ReloadSettings(jsonData):
# Execute json reloading here
ScriptSettings.__dict__ = json.loads(jsonData)
ScriptSettings.Save(SettingsFile)
return
#---------------------------
# [Optional] Unload (Called when a user reloads their scripts or closes the bot / cleanup stuff)
#---------------------------
def Unload():
return
#---------------------------
# [Optional] ScriptToggled (Notifies you when a user disables your script or enables it)
#---------------------------
def ScriptToggled(state):
return