-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathobs_interactions.py
More file actions
164 lines (141 loc) · 6.06 KB
/
obs_interactions.py
File metadata and controls
164 lines (141 loc) · 6.06 KB
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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
import asyncio
import time
from rich import print
from globals import getOBSWebsocketsManager
from obs_websocket import OBSWebsocketsManager
pngtuber = {
"sceneName": "pngtuber",
"bonjour": "bonjour",
"rainbow": "rainbow", # a rainbow filter on the "bonjour" source
}
unionbreak = {
"sceneName": "unionbreak",
"text": "unionbreak_text",
"meeting": "Emergency Meeting",
}
adbreak = {
"sceneName": "Ad Break",
"shaiaz": "shaiaz",
"text": "Bezos Time",
"bezos": "Bezos",
}
mic_in = {"sceneName": "Audio stuff", "srcName": "Yeti"}
webcam_stuff = {"sceneName": "Webcam stuff", "webcam": "Webcam Scene"}
somnia = {
"src": "Somnia stuff",
"somnia": "somnia",
"somnia_head": "somnia head",
"somnia_text": "somnia says",
"somnia_gun": "somnia gun",
}
class ObsInteractions:
def __init__(self, obs: OBSWebsocketsManager):
self.obs = obs
def bonjour(self):
print("[green]OBS: Toggling Mustache...")
visbility = self.obs.get_source_visibility(
pngtuber["sceneName"], pngtuber["bonjour"]
)
self.obs.set_source_visibility(
pngtuber["sceneName"], pngtuber["bonjour"], not visbility
)
def bonjourRainbow(self):
print("[green]OBS: Toggling MustacheRainbow...")
visbility = self.obs.get_filter_visibility(
pngtuber["bonjour"], pngtuber["rainbow"]
)
self.obs.set_filter_visibility(
pngtuber["bonjour"], pngtuber["rainbow"], not visbility
)
async def memeFormat(self, text: str):
print("[green]OBS: Setting meme format...")
self.obs.set_text("meme text", text)
self.obs.set_scene("meme format")
self.obs.set_filter_visibility("Game/Desktop Clone", "Freeze", True)
await asyncio.sleep(5)
self.obs.set_scene("Game/Desktop")
self.obs.set_filter_visibility("Game/Desktop Clone", "Freeze", False)
async def unionBreak(self, chat, runAds):
print("[green]OBS: Toggling Union Break...")
onBreak = self.obs.get_source_visibility(
unionbreak["sceneName"], unionbreak["text"]
)
if not onBreak:
self.obs.set_source_visibility(
unionbreak["sceneName"], unionbreak["meeting"], True
)
await chat(
"I'm going on a union break. Don't worry, I will be back soon. If you are bored, play around with some !commands, or ask Somnia a question(point redeem)."
)
else:
await chat("I'm back! Hope you didn't miss me too much...")
self.obs.set_source_visibility(
unionbreak["sceneName"], unionbreak["text"], not onBreak
)
enString = "Enabled" if onBreak else "Disabled"
print(f"[green]OBS: Mic in {enString}")
self.obs.set_source_visibility(mic_in["sceneName"], mic_in["srcName"], onBreak)
if not onBreak:
await asyncio.sleep(1)
print(f"disable meeting")
self.obs.set_source_visibility(
unionbreak["sceneName"], unionbreak["meeting"], False
)
# move this to the end because sometimes ads don't work which stops meeting toggle above
await runAds()
async def bezos_time(self, duration: int):
print("[yellow]Ad break started")
self.obs.set_source_visibility(adbreak["sceneName"], adbreak["text"], True)
self.obs.set_source_visibility(adbreak["sceneName"], adbreak["bezos"], True)
await asyncio.sleep(0.5)
self.obs.set_source_visibility(adbreak["sceneName"], adbreak["shaiaz"], True)
await asyncio.sleep(duration)
self.obs.set_source_visibility(adbreak["sceneName"], adbreak["shaiaz"], False)
await asyncio.sleep(0.5)
self.obs.set_source_visibility(adbreak["sceneName"], adbreak["text"], False)
self.obs.set_source_visibility(adbreak["sceneName"], adbreak["bezos"], False)
print("[yellow]Ad break over")
async def reset_webcam_rotation(self):
rotation = self.obs.get_source_transform(
webcam_stuff["sceneName"], webcam_stuff["webcam"]
)["rotation"]
rotated = rotation != 0
if rotated:
self.obs.set_source_transform(
webcam_stuff["sceneName"], webcam_stuff["webcam"], {"rotation": 0}
)
async def australia(self, chat, duration: int):
self.obs.set_source_transform(
webcam_stuff["sceneName"], webcam_stuff["webcam"], {"rotation": 180}
)
await chat(f"Streamer is now in Australia")
await asyncio.sleep(60)
self.obs.set_source_transform(
webcam_stuff["sceneName"], webcam_stuff["webcam"], {"rotation": 0}
)
await chat(f"Turning Streamer right side up")
def showSomnia(self, text: str, peek=False, gun=False):
somnia_img = somnia["somnia"] if not peek else somnia["somnia_head"]
self.obs.set_source_visibility(somnia["src"], somnia_img, True)
self.obs.set_text(somnia["somnia_text"], text)
self.obs.set_source_visibility(somnia["src"], somnia["somnia_text"], True)
if gun:
self.obs.set_source_visibility(somnia["src"], somnia["somnia_gun"], True)
def hide():
self.obs.set_source_visibility(somnia["src"], somnia_img, False)
self.obs.set_source_visibility(somnia["src"], somnia["somnia_text"], False)
self.obs.set_source_visibility(somnia["src"], somnia["somnia_gun"], False)
return hide
if __name__ == "__main__":
# ObsInteractions().bonjour()
# asyncio.run(ObsInteractions().memeFormat("test"))
### Test Union Break
# async def aprint(*args):
# print(*args)
# asyncio.run(ObsInteractions(getOBSWebsocketsManager()).unionBreak(aprint))
### Test Somnia with peek
hide = ObsInteractions(getOBSWebsocketsManager()).showSomnia(
"Hello World", peek=True, gun=True
)
time.sleep(5)
hide()