├── .gitignore
├── Boilerplate
├── Overlays
│ ├── API_Key.js
│ └── TemplateOverlay.html
├── Template_StreamlabsSystem.py
├── UI_Config.json
└── lib
│ └── Settings_Module.py
├── README.md
└── Wiki
└── Images
├── Folder_Structure_1.png
└── Folder_Structure_2.png
/.gitignore:
--------------------------------------------------------------------------------
1 | ��B o i l e r p l a t e / S e t t i n g s / *
2 | B o i l e r p l a t e / S e t t i n g s / *
3 | Boilerplate/Settings/settings.js
4 | Boilerplate/Settings/settings.json
5 |
--------------------------------------------------------------------------------
/Boilerplate/Overlays/API_Key.js:
--------------------------------------------------------------------------------
1 | var API_Key = "6d5c9235a6b14f70afcdac8db52da17c"; var API_Socket = " ws://127.0.0.1:3337/streamlabs";
--------------------------------------------------------------------------------
/Boilerplate/Overlays/TemplateOverlay.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
10 |
11 |
12 |
13 |
78 |
79 |
--------------------------------------------------------------------------------
/Boilerplate/Template_StreamlabsSystem.py:
--------------------------------------------------------------------------------
1 | #---------------------------
2 | # Import Libraries
3 | #---------------------------
4 | import os
5 | import sys
6 | import json
7 | sys.path.append(os.path.join(os.path.dirname(__file__), "lib")) #point at lib folder for classes / references
8 |
9 | import clr
10 | clr.AddReference("IronPython.SQLite.dll")
11 | clr.AddReference("IronPython.Modules.dll")
12 |
13 | # Import your Settings class
14 | from Settings_Module import MySettings
15 | #---------------------------
16 | # [Required] Script Information
17 | #---------------------------
18 | ScriptName = "Template Script"
19 | Website = "https://www.streamlabs.com"
20 | Description = "!test will post a message in chat"
21 | Creator = "AnkhHeart"
22 | Version = "1.0.0.0"
23 |
24 | #---------------------------
25 | # Define Global Variables
26 | #---------------------------
27 | global SettingsFile
28 | SettingsFile = ""
29 | global ScriptSettings
30 | ScriptSettings = MySettings()
31 |
32 | #---------------------------
33 | # [Required] Initialize Data (Only called on load)
34 | #---------------------------
35 | def Init():
36 |
37 | # Create Settings Directory
38 | directory = os.path.join(os.path.dirname(__file__), "Settings")
39 | if not os.path.exists(directory):
40 | os.makedirs(directory)
41 |
42 | # Load settings
43 | SettingsFile = os.path.join(os.path.dirname(__file__), "Settings\settings.json")
44 | ScriptSettings = MySettings(SettingsFile)
45 | ScriptSettings.Response = "Overwritten pong! ^_^"
46 | return
47 |
48 | #---------------------------
49 | # [Required] Execute Data / Process messages
50 | #---------------------------
51 | def Execute(data):
52 | if data.IsChatMessage() and data.GetParam(0).lower() == ScriptSettings.Command and Parent.IsOnUserCooldown(ScriptName,ScriptSettings.Command,data.User):
53 | Parent.SendStreamMessage("Time Remaining " + str(Parent.GetUserCooldownDuration(ScriptName,ScriptSettings.Command,data.User)))
54 |
55 | # Check if the propper command is used, the command is not on cooldown and the user has permission to use the command
56 | 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):
57 | Parent.BroadcastWsEvent("EVENT_MINE","{'show':false}")
58 | Parent.SendStreamMessage(ScriptSettings.Response) # Send your message to chat
59 | Parent.AddUserCooldown(ScriptName,ScriptSettings.Command,data.User,ScriptSettings.Cooldown) # Put the command on cooldown
60 |
61 |
62 | return
63 |
64 | #---------------------------
65 | # [Required] Tick method (Gets called during every iteration even when there is no incoming data)
66 | #---------------------------
67 | def Tick():
68 | return
69 |
70 | #---------------------------
71 | # [Optional] Parse method (Allows you to create your own custom $parameters)
72 | #---------------------------
73 | def Parse(parseString, userid, username, targetid, targetname, message):
74 |
75 | if "$myparameter" in parseString:
76 | return parseString.replace("$myparameter","I am a cat!")
77 |
78 | return parseString
79 |
80 | #---------------------------
81 | # [Optional] Reload Settings (Called when a user clicks the Save Settings button in the Chatbot UI)
82 | #---------------------------
83 | def ReloadSettings(jsonData):
84 | # Execute json reloading here
85 | ScriptSettings.__dict__ = json.loads(jsonData)
86 | ScriptSettings.Save(SettingsFile)
87 | return
88 |
89 | #---------------------------
90 | # [Optional] Unload (Called when a user reloads their scripts or closes the bot / cleanup stuff)
91 | #---------------------------
92 | def Unload():
93 | return
94 |
95 | #---------------------------
96 | # [Optional] ScriptToggled (Notifies you when a user disables your script or enables it)
97 | #---------------------------
98 | def ScriptToggled(state):
99 | return
100 |
--------------------------------------------------------------------------------
/Boilerplate/UI_Config.json:
--------------------------------------------------------------------------------
1 | {
2 | "output_file": "Settings/settings.json",
3 | "Command": {
4 | "type": "textbox",
5 | "value": "!ping",
6 | "label": "Command",
7 | "tooltip": "The command that will be responded to.",
8 | "group": "Core"
9 | },
10 | "Permission": {
11 | "type": "dropdown",
12 | "value": "everyone",
13 | "items": ["everyone","moderator","subscriber","user_specific","editor"],
14 | "label": "Permission",
15 | "tooltip": "Who is able to use the command",
16 | "group": "Core"
17 | },
18 | "Info": {
19 | "type": "textbox",
20 | "value": "",
21 | "label": "Info",
22 | "tooltip": "This field should only be filled when using the user_specific permission.",
23 | "group": "Core"
24 | },
25 | "Cooldown": {
26 | "type": "slider",
27 | "value": 4,
28 | "min": 1,
29 | "max": 100,
30 | "ticks": 1,
31 | "label": "Cooldown (seconds)",
32 | "tooltip": "How long the command should go on cooldown for",
33 | "group": "Core"
34 | },
35 | "Response": {
36 | "type": "textbox",
37 | "value": "Pong!",
38 | "label": "Command",
39 | "tooltip": "The message that will be sent to chat when using the command.",
40 | "group": "Core"
41 | }
42 | }
--------------------------------------------------------------------------------
/Boilerplate/lib/Settings_Module.py:
--------------------------------------------------------------------------------
1 | import os
2 | import codecs
3 | import json
4 |
5 | class MySettings(object):
6 | def __init__(self, settingsfile=None):
7 | try:
8 | with codecs.open(settingsfile, encoding="utf-8-sig", mode="r") as f:
9 | self.__dict__ = json.load(f, encoding="utf-8")
10 | except:
11 | self.Command = "!ping"
12 | self.Response = "pong! ^_^"
13 | self.Cooldown = 10
14 | self.Permission = "everyone"
15 | self.Info = ""
16 |
17 | def Reload(self, jsondata):
18 | self.__dict__ = json.loads(jsondata, encoding="utf-8")
19 | return
20 |
21 | def Save(self, settingsfile):
22 | try:
23 | with codecs.open(settingsfile, encoding="utf-8-sig", mode="w+") as f:
24 | json.dump(self.__dict__, f, encoding="utf-8")
25 | with codecs.open(settingsfile.replace("json", "js"), encoding="utf-8-sig", mode="w+") as f:
26 | f.write("var settings = {0};".format(json.dumps(self.__dict__, encoding='utf-8')))
27 | except:
28 | Parent.Log(ScriptName, "Failed to save settings to file.")
29 | return
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Streamlabs-Chatbot-Python-Boilerplate
2 |
3 | Information on the Python Scripting Structure for the Streamlabs Chatbot can be located on github Wiki above.
--------------------------------------------------------------------------------
/Wiki/Images/Folder_Structure_1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AnkhHeart/Streamlabs-Chatbot-Python-Boilerplate/5249b6ba5ac2e8671e5e93c9144318544713b146/Wiki/Images/Folder_Structure_1.png
--------------------------------------------------------------------------------
/Wiki/Images/Folder_Structure_2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AnkhHeart/Streamlabs-Chatbot-Python-Boilerplate/5249b6ba5ac2e8671e5e93c9144318544713b146/Wiki/Images/Folder_Structure_2.png
--------------------------------------------------------------------------------