Compare commits

..

8 Commits

Author SHA1 Message Date
Alex Orid
fae2cacb73 Fixes & New Rewards 2021-05-05 13:15:01 -04:00
Alex Orid
bc11d876c7 fixed comments 2021-05-04 19:08:37 -04:00
Alex Orid
a3da70bd55 Made Discord TTS Command working kinda 2021-05-04 18:57:26 -04:00
Alex Orid
72ea8f7b71 config deletion 2021-05-04 17:36:10 -04:00
Alex Orid
3d0f2b0a90 Working Version 2021-05-04 17:34:15 -04:00
Alex Orid
5d9831fc30 minor fixes 2021-05-04 16:54:45 -04:00
Alex Orid
e05183ffeb Working Version 2021-05-04 16:23:00 -04:00
Alex Orid
f0601974be working concept 2021-05-04 15:23:31 -04:00
14 changed files with 576 additions and 55 deletions

View File

@ -0,0 +1,87 @@
from abc import ABCMeta
from channel_rewards.channelRewards_base import AbstractChannelRewards
from json import loads
from urllib.parse import urlencode
import requests
import threading
import random
class ChannelReward_Suggest_Poll(AbstractChannelRewards, metaclass=ABCMeta):
"""
this is the Suggest a Poll reward.
"""
ChannelRewardName = "Suggest a Poll"
def __init__(self):
super().__init__(ChannelReward_Suggest_Poll.ChannelRewardName, n_args=1, ChannelRewardType=AbstractChannelRewards.ChannelRewardsType.channelPoints)
self.help = ["This is a TTS channel point reward."]
self.isChannelRewardEnabled = True
self.threads = []
def do_ChannelReward(self, source = AbstractChannelRewards.ChannelRewardsSource.default, user = "User", rewardName = "", rewardPrompt = "", userInput = "", bonusData = None):
#print("sending:",user, 16, "!lights hydration")
try:
#if self.is_ChannelReward_enabled:
# thread_ = threading.Thread(target=self.send_Lights_Command, args=(user, 16, "!lights hydration", ""))
# thread_.daemon = True
# self.threads.append(thread_)
# thread_.start()
if self.is_ChannelReward_enabled:
prompt_ = self.get_Phrase("wants to run a poll about,")
thread_ = threading.Thread(target=self.send_TTS, args=("",user + prompt_ + userInput))
thread_.daemon = True
self.threads.append(thread_)
thread_.start()
except:
pass
return None
def send_Lights_Command(self, username, light_group, command, rest):
# todo need to url-escape command and rest
params = urlencode({'user_name': username, 'light_group': light_group, 'command': command, 'rest':rest})
#standalone_lights
url = "http://standalone_lights:42069/api/v1/exec_lights?%s" % params
resp = requests.get(url)
if resp.status_code == 200:
print("Got the following message: %s" % resp.text)
data = loads(resp.text)
msg = data['message']
if msg is not None:
return msg
# todo send to logger and other relevent services
else:
# todo handle failed requests
pass
def send_TTS(self, username, message):
params = urlencode({'tts_sender': username, 'tts_text': message})
#standalone_tts_core
url = "http://standalone_tts_core:60809/api/v1/tts/send_text?%s" % params
resp = requests.get(url)
if resp.status_code == 200:
print("Got the following message: %s" % resp.text)
data = loads(resp.text)
msg = data['message']
if msg is not None:
return msg
# todo send to logger and other relevent services
else:
# todo handle failed requests
pass
def get_Phrase(self, defaultRewardPrompt,
phrases = ["wants to know other people's thoughts on,", "wants to gauge the room on the topic of,"]):
phrases.append(defaultRewardPrompt)
totalPhrases = len(phrases) - 1
targetPhrase = phrases[random.randint(0,totalPhrases)]
return targetPhrase
def get_help(self):
return self.help

View File

@ -0,0 +1,87 @@
from abc import ABCMeta
from channel_rewards.channelRewards_base import AbstractChannelRewards
from json import loads
from urllib.parse import urlencode
import requests
import threading
import random
class ChannelReward_TTS_Message(AbstractChannelRewards, metaclass=ABCMeta):
"""
this is the TTS Message reward.
"""
ChannelRewardName = "Send a TTS Message"
def __init__(self):
super().__init__(ChannelReward_TTS_Message.ChannelRewardName, n_args=1, ChannelRewardType=AbstractChannelRewards.ChannelRewardsType.channelPoints)
self.help = ["This is a TTS channel point reward."]
self.isChannelRewardEnabled = True
self.threads = []
def do_ChannelReward(self, source = AbstractChannelRewards.ChannelRewardsSource.default, user = "User", rewardName = "", rewardPrompt = "", userInput = "", bonusData = None):
#print("sending:",user, 16, "!lights hydration")
try:
#if self.is_ChannelReward_enabled:
# thread_ = threading.Thread(target=self.send_Lights_Command, args=(user, 16, "!lights hydration", ""))
# thread_.daemon = True
# self.threads.append(thread_)
# thread_.start()
if self.is_ChannelReward_enabled:
prompt_ = self.get_Phrase(rewardPrompt)
thread_ = threading.Thread(target=self.send_TTS, args=(user, userInput))
thread_.daemon = True
self.threads.append(thread_)
thread_.start()
except:
pass
return None
def send_Lights_Command(self, username, light_group, command, rest):
# todo need to url-escape command and rest
params = urlencode({'user_name': username, 'light_group': light_group, 'command': command, 'rest':rest})
#standalone_lights
url = "http://standalone_lights:42069/api/v1/exec_lights?%s" % params
resp = requests.get(url)
if resp.status_code == 200:
print("Got the following message: %s" % resp.text)
data = loads(resp.text)
msg = data['message']
if msg is not None:
return msg
# todo send to logger and other relevent services
else:
# todo handle failed requests
pass
def send_TTS(self, username, message):
params = urlencode({'tts_sender': username, 'tts_text': message})
#standalone_tts_core
url = "http://standalone_tts_core:60809/api/v1/tts/send_text?%s" % params
resp = requests.get(url)
if resp.status_code == 200:
print("Got the following message: %s" % resp.text)
data = loads(resp.text)
msg = data['message']
if msg is not None:
return msg
# todo send to logger and other relevent services
else:
# todo handle failed requests
pass
def get_Phrase(self, defaultRewardPrompt,
phrases = [""]):
phrases.append(defaultRewardPrompt)
totalPhrases = len(phrases) - 1
targetPhrase = phrases[random.randint(0,totalPhrases)]
return targetPhrase
def get_help(self):
return self.help

View File

@ -0,0 +1,87 @@
from abc import ABCMeta
from channel_rewards.channelRewards_base import AbstractChannelRewards
from json import loads
from urllib.parse import urlencode
import requests
import threading
import random
class ChannelReward_Workout_Pushups(AbstractChannelRewards, metaclass=ABCMeta):
"""
this is the Do 20 push-ups reward.
"""
ChannelRewardName = "Do 20 push-ups"
def __init__(self):
super().__init__(ChannelReward_Workout_Pushups.ChannelRewardName, n_args=1, ChannelRewardType=AbstractChannelRewards.ChannelRewardsType.channelPoints)
self.help = ["This is a Do 20 push-ups channel point reward."]
self.isChannelRewardEnabled = True
self.threads = []
def do_ChannelReward(self, source = AbstractChannelRewards.ChannelRewardsSource.default, user = "User", rewardName = "", rewardPrompt = "", userInput = "", bonusData = None):
#print("sending:",user, 16, "!lights hydration")
try:
#if self.is_ChannelReward_enabled:
# thread_ = threading.Thread(target=self.send_Lights_Command, args=(user, 16, "!lights hydration", ""))
# thread_.daemon = True
# self.threads.append(thread_)
# thread_.start()
if self.is_ChannelReward_enabled:
prompt_ = self.get_Phrase(" wants The Curious Nerd, to do 20 pushups")
thread_ = threading.Thread(target=self.send_TTS, args=("", user + prompt_))
thread_.daemon = True
self.threads.append(thread_)
thread_.start()
except:
pass
return None
def send_Lights_Command(self, username, light_group, command, rest):
# todo need to url-escape command and rest
params = urlencode({'user_name': username, 'light_group': light_group, 'command': command, 'rest':rest})
#standalone_lights
url = "http://standalone_lights:42069/api/v1/exec_lights?%s" % params
resp = requests.get(url)
if resp.status_code == 200:
print("Got the following message: %s" % resp.text)
data = loads(resp.text)
msg = data['message']
if msg is not None:
return msg
# todo send to logger and other relevent services
else:
# todo handle failed requests
pass
def send_TTS(self, username, message):
params = urlencode({'tts_sender': username, 'tts_text': message})
#standalone_tts_core
url = "http://standalone_tts_core:60809/api/v1/tts/send_text?%s" % params
resp = requests.get(url)
if resp.status_code == 200:
print("Got the following message: %s" % resp.text)
data = loads(resp.text)
msg = data['message']
if msg is not None:
return msg
# todo send to logger and other relevent services
else:
# todo handle failed requests
pass
def get_Phrase(self, defaultRewardPrompt,
phrases = [""]):
phrases.append(defaultRewardPrompt)
totalPhrases = len(phrases) - 1
targetPhrase = phrases[random.randint(0,totalPhrases)]
return targetPhrase
def get_help(self):
return self.help

View File

@ -0,0 +1,87 @@
from abc import ABCMeta
from channel_rewards.channelRewards_base import AbstractChannelRewards
from json import loads
from urllib.parse import urlencode
import requests
import threading
import random
class ChannelReward_Workout_Situps(AbstractChannelRewards, metaclass=ABCMeta):
"""
this is the Do 20 sit-ups reward.
"""
ChannelRewardName = "Do 20 sit-ups"
def __init__(self):
super().__init__(ChannelReward_Workout_Situps.ChannelRewardName, n_args=1, ChannelRewardType=AbstractChannelRewards.ChannelRewardsType.channelPoints)
self.help = ["This is a Do 20 sit-ups channel point reward."]
self.isChannelRewardEnabled = True
self.threads = []
def do_ChannelReward(self, source = AbstractChannelRewards.ChannelRewardsSource.default, user = "User", rewardName = "", rewardPrompt = "", userInput = "", bonusData = None):
#print("sending:",user, 16, "!lights hydration")
try:
#if self.is_ChannelReward_enabled:
# thread_ = threading.Thread(target=self.send_Lights_Command, args=(user, 16, "!lights hydration", ""))
# thread_.daemon = True
# self.threads.append(thread_)
# thread_.start()
if self.is_ChannelReward_enabled:
prompt_ = self.get_Phrase(" wants The Curious Nerd, to do 20 sit-ups")
thread_ = threading.Thread(target=self.send_TTS, args=("", user + prompt_))
thread_.daemon = True
self.threads.append(thread_)
thread_.start()
except:
pass
return None
def send_Lights_Command(self, username, light_group, command, rest):
# todo need to url-escape command and rest
params = urlencode({'user_name': username, 'light_group': light_group, 'command': command, 'rest':rest})
#standalone_lights
url = "http://standalone_lights:42069/api/v1/exec_lights?%s" % params
resp = requests.get(url)
if resp.status_code == 200:
print("Got the following message: %s" % resp.text)
data = loads(resp.text)
msg = data['message']
if msg is not None:
return msg
# todo send to logger and other relevent services
else:
# todo handle failed requests
pass
def send_TTS(self, username, message):
params = urlencode({'tts_sender': username, 'tts_text': message})
#standalone_tts_core
url = "http://standalone_tts_core:60809/api/v1/tts/send_text?%s" % params
resp = requests.get(url)
if resp.status_code == 200:
print("Got the following message: %s" % resp.text)
data = loads(resp.text)
msg = data['message']
if msg is not None:
return msg
# todo send to logger and other relevent services
else:
# todo handle failed requests
pass
def get_Phrase(self, defaultRewardPrompt,
phrases = [""]):
phrases.append(defaultRewardPrompt)
totalPhrases = len(phrases) - 1
targetPhrase = phrases[random.randint(0,totalPhrases)]
return targetPhrase
def get_help(self):
return self.help

View File

@ -0,0 +1,87 @@
from abc import ABCMeta
from channel_rewards.channelRewards_base import AbstractChannelRewards
from json import loads
from urllib.parse import urlencode
import requests
import threading
import random
class ChannelReward_Workout_Squats(AbstractChannelRewards, metaclass=ABCMeta):
"""
this is the Do 20 squats reward.
"""
ChannelRewardName = "Do 20 squats"
def __init__(self):
super().__init__(ChannelReward_Workout_Squats.ChannelRewardName, n_args=1, ChannelRewardType=AbstractChannelRewards.ChannelRewardsType.channelPoints)
self.help = ["This is a Do 20 squats channel point reward."]
self.isChannelRewardEnabled = True
self.threads = []
def do_ChannelReward(self, source = AbstractChannelRewards.ChannelRewardsSource.default, user = "User", rewardName = "", rewardPrompt = "", userInput = "", bonusData = None):
#print("sending:",user, 16, "!lights hydration")
try:
#if self.is_ChannelReward_enabled:
# thread_ = threading.Thread(target=self.send_Lights_Command, args=(user, 16, "!lights hydration", ""))
# thread_.daemon = True
# self.threads.append(thread_)
# thread_.start()
if self.is_ChannelReward_enabled:
prompt_ = self.get_Phrase(" wants The Curious Nerd, to do 20 squats")
thread_ = threading.Thread(target=self.send_TTS, args=("", user + prompt_))
thread_.daemon = True
self.threads.append(thread_)
thread_.start()
except:
pass
return None
def send_Lights_Command(self, username, light_group, command, rest):
# todo need to url-escape command and rest
params = urlencode({'user_name': username, 'light_group': light_group, 'command': command, 'rest':rest})
#standalone_lights
url = "http://standalone_lights:42069/api/v1/exec_lights?%s" % params
resp = requests.get(url)
if resp.status_code == 200:
print("Got the following message: %s" % resp.text)
data = loads(resp.text)
msg = data['message']
if msg is not None:
return msg
# todo send to logger and other relevent services
else:
# todo handle failed requests
pass
def send_TTS(self, username, message):
params = urlencode({'tts_sender': username, 'tts_text': message})
#standalone_tts_core
url = "http://standalone_tts_core:60809/api/v1/tts/send_text?%s" % params
resp = requests.get(url)
if resp.status_code == 200:
print("Got the following message: %s" % resp.text)
data = loads(resp.text)
msg = data['message']
if msg is not None:
return msg
# todo send to logger and other relevent services
else:
# todo handle failed requests
pass
def get_Phrase(self, defaultRewardPrompt,
phrases = [""]):
phrases.append(defaultRewardPrompt)
totalPhrases = len(phrases) - 1
targetPhrase = phrases[random.randint(0,totalPhrases)]
return targetPhrase
def get_help(self):
return self.help

View File

@ -16,7 +16,7 @@ class Chyron_Module():
self.addItem( self.addItem(
"WeekDays", "WeekDays",
"► Weekdays: ", "► Weekdays: ",
"Daily Streams @ 12pm Noon EST") "Daily Dev Streams starting around 12pm Noon EST")
self.addItem( self.addItem(
"FriSat", "FriSat",
"► Friday & Saturday: ", "► Friday & Saturday: ",
@ -24,18 +24,18 @@ class Chyron_Module():
self.addItem( self.addItem(
"Commands", "Commands",
"► Commands: ", "► Commands: ",
"!animal, !climateclock, !discord, !page, !roll") "!animal, !climateclock, !discord, !lights, !roll")
self.addItem( #self.addItem(
"Website", # "Website",
"► Want to read about my various projects? visit: ", # "► Want to read about my various projects? visit: ",
"TheCuriousNerd.com") # "TheCuriousNerd.com")
self.addItem( self.addItem(
"Follow", "Follow",
"", "",
"If you like what you see, hit that follow button to see more!") "If you like what you see and want more, hit the follow button to see more!")
self.addItem( self.addItem(
"Discord", "Discord",
"Want to join our discord? type \" !d \" in chat to get the link or visit: ", "Need help with Praxis Bot or one of our other projects? (or for memes) Join our discord! Type: \" !d \" in chat to get the link or visit: ",
"discord.io/thecuriousnerd") "discord.io/thecuriousnerd")
def chyron_stringUpdater(self): def chyron_stringUpdater(self):

View File

@ -31,7 +31,7 @@ class Command_lights_v2(AbstractCommand, metaclass=ABCMeta):
praxis_logger_obj.log("\n Command>: " + command + rest) praxis_logger_obj.log("\n Command>: " + command + rest)
isTwitch = False isTwitch = False
if "Twitch" in source: if "Twitch_ZZZ" in source: #temp changed for steam change back later
for name in config.allowedCommandsList_TwitchPowerUsers: for name in config.allowedCommandsList_TwitchPowerUsers:
print(name) print(name)
tempName = user.lower() tempName = user.lower()

View File

@ -6,6 +6,7 @@ from json import loads
from urllib.parse import urlencode from urllib.parse import urlencode
from urllib.parse import parse_qs from urllib.parse import parse_qs
import requests import requests
import re
import config import config
@ -44,14 +45,11 @@ class Command_tts_v2(AbstractCommand, metaclass=ABCMeta):
for name in config.allowedTTS_List: for name in config.allowedTTS_List:
print(name) print(name)
tempNick = self.contains_value("(?<=nick=')[^']+", bonusData)
for key_ in fixedData:
praxis_logger_obj.log(key_)
tempName = user.lower() tempName = user.lower()
if name == tempName: if name == tempName:
self.send_TTS(fixedData.author.nick, rest) self.send_TTS(tempNick, rest)
else: else:
returnString = self.send_TTS(user, rest) returnString = self.send_TTS(user, rest)
@ -89,7 +87,7 @@ class Command_tts_v2(AbstractCommand, metaclass=ABCMeta):
resp = requests.get(url) resp = requests.get(url)
if resp.status_code == 200: if resp.status_code == 200:
print("Got the following message: %s" % resp.text) print("Got the following message: %s" % resp.text)
data = loads(resp.text) #data = loads(resp.text)
msg = data['message'] msg = data['message']
if msg is not None: if msg is not None:
return msg return msg
@ -98,5 +96,9 @@ class Command_tts_v2(AbstractCommand, metaclass=ABCMeta):
# todo handle failed requests # todo handle failed requests
pass pass
def contains_value(self, search: str, data:str):
contains = re.search(search, data)
return contains.group(0)
def get_help(self): def get_help(self):
return self.help return self.help

View File

@ -3,16 +3,13 @@ import badwords as badwords
credentialsNickname = "praxis_bot" credentialsNickname = "praxis_bot"
#OLD CONFIGS WILL BE DELETED SOON
#twitch_module: bool = False
#discord_module: bool = False
test_module: bool = False test_module: bool = False
user_module: bool = True user_module: bool = True
autoJoin_TwitchChannel = "thecuriousnerd" autoJoin_TwitchChannel = "thecuriousnerd"
autoJoin_TwitchChannels = ["thecuriousnerd"] autoJoin_TwitchChannels = ["thecuriousnerd"]
allowedCommandsList_TwitchPowerUsers = ["thecuriousnerd", "lakotor", "blastofcynicism", "theredpoint"] allowedCommandsList_TwitchPowerUsers = ["thecuriousnerd", "lakotor", "blastofcynicism", "theredpoint"]
allowedTTS_List = ["thecuriousnerd", "lakotor", "blastofcynicism", "theredpoint", "<@76078763984551936>"] allowedTTS_List = ["thecuriousnerd", "lakotor", "blastofcynicism", "theredpoint", "<@76078763984551936>", "<@!76078763984551936>"]
adminUsers_List = ["thecuriousnerd", "<@!76078763984551936>"] adminUsers_List = ["thecuriousnerd", "<@!76078763984551936>"]
#Twitch Module Configs #Twitch Module Configs
@ -21,15 +18,6 @@ blockAll_TwitchChatChannelsMessaging = False # Blocks the ability to send messag
autoEnabled_TwitchTTS = False # Enables TTS for ALL autoEnabled_TwitchTTS = False # Enables TTS for ALL
autoEnabled_TwitchTTS_SpeakersList_Only = False # Enables TTS for Allowed TTS List Only autoEnabled_TwitchTTS_SpeakersList_Only = False # Enables TTS for Allowed TTS List Only
#OLD CONFIGS WILL BE DELETED SOON
#block_TwitchChannelsTTS = [""] # block supersedes the tts_enabled bool
#blockAll_TwitchChatChannelsTTS = False # blockAll supersedes the force bool and force list and tts_enabled bool
#force_TwitchChannelsTTS = [""] # force supersedes the block list
#forceAll_TwitchChatChannelsTTS = False # forceAll supersedes the blockAll bool and block list and force list
#OLD CONFIGS WILL BE DELETED SOON
#twitch_defaultCommandEnabledState = True
#twitch_defaultCommandEnabledState_liveStreamOnly = True # If true this will make commands only available during live streams.
#Discord Module Configs #Discord Module Configs
block_DiscordChannelsMessaging = [""] # Blocks the ability to send messages to Discord channels block_DiscordChannelsMessaging = [""] # Blocks the ability to send messages to Discord channels
@ -44,10 +32,6 @@ blockAll_DiscordChannelsTTS = False # blockAll supersedes the force bool and for
force_DiscordChannelsTTS = [""] # force supersedes the block list force_DiscordChannelsTTS = [""] # force supersedes the block list
forceAll_DiscordChatChannelsTTS = False # forceAll supersedes the blockAll bool and block list and force list forceAll_DiscordChatChannelsTTS = False # forceAll supersedes the blockAll bool and block list and force list
#OLD CONFIGS WILL BE DELETED SOON
#autoEnabled_Discord_rgbLightControl = False
#discord_defaultCommandEnabledState = True
#discord_defaultCommandEnabledState_liveStreamOnly = True # If true this will make commands only available during live streams.
#User Module Configs #User Module Configs
blockAll_TTS_URL_UserModule = True blockAll_TTS_URL_UserModule = True

70
obsWebSocket.py Normal file
View File

@ -0,0 +1,70 @@
import asyncio
import simpleobsws
import json
loop = asyncio.get_event_loop()
ws = simpleobsws.obsws(host='127.0.0.1', port=4444, password='MYSecurePassword', loop=loop) # Every possible argument has been passed, but none are required. See lib code for defaults.
async def default_request():
await ws.connect() # Make the connection to OBS-Websocket
result = await ws.call('GetVersion') # We get the current OBS version. More request data is not required
print(result) # Print the raw json output of the GetVersion request
await asyncio.sleep(1)
requests = result['available-requests'].split(',')
#data = {'source':'test_source', 'volume':0.5}
#result = await ws.call('SetVolume', data) # Make a request with the given data
#print(result)
await ws.disconnect() # Clean things up by disconnecting. Only really required in a few specific situations, but good practice if you are done making requests or listening to events.
return requests
async def make_custom_request(request, data=None):
await ws.connect() # Make the connection to OBS-Websocket
#result = await ws.call(request) # We get the current OBS version. More request data is not required
#print(result) # Print the raw json output of the GetVersion request
await asyncio.sleep(1)
if not data==None:
#data = {'source':'tinycam', 'volume':0.5}
result = await ws.call(request, data=data) # Make a request with the given data
print(result)
await ws.disconnect() # Clean things up by disconnecting. Only really required in a few specific situations, but good practice if you are done making requests or listening to events.
async def on_event(data):
print('New event! Type: {} | Raw Data: {}'.format(data['update-type'], data)) # Print the event data. Note that `update-type` is also provided in the data
async def on_switchscenes(data):
print("\n===========================================\n\n")
print('Scene switched to "{}". It has these sources: {}'.format(data['scene-name'], data['sources']))
def getRequests():
return loop.run_until_complete(default_request())
def makeRequest(request, data):
loop.run_until_complete(make_custom_request(request, data))
def listenForData():
print("\n\nListener:")
loop = asyncio.get_event_loop()
ws = simpleobsws.obsws(host='127.0.0.1', port=4444, password='MYSecurePassword', loop=loop) # Every possible argument has been passed, but none are required. See lib code for defaults.
loop.run_until_complete(ws.connect())
ws.register(on_event) # By not specifying an event to listen to, all events are sent to this callback.
ws.register(on_switchscenes, 'SwitchScenes')
loop.run_forever()
if __name__ == "__main__":
#print("\n\nRequests:")
#loop.run_until_complete(get_requests())
#makeRequest("ToggleStudioMode")
#listenForData()
pass

View File

@ -0,0 +1,45 @@
import flask
from flask import request
import obsWebSocket
import os
import praxis_logging
praxis_logger_obj = praxis_logging.praxis_logger()
praxis_logger_obj.init(os.path.basename(__file__))
praxis_logger_obj.log("\n -Starting Logs: " + os.path.basename(__file__))
api = flask.Flask(__name__)
# enable/disable this to get web pages of crashes returned
api.config["DEBUG"] = False
possibleRequests = []
def init():
possibleRequests = obsWebSocket.getRequests()
for r in possibleRequests:
print("requestname: "+r)
#obsWebSocket.makeRequest("ToggleStudioMode", {'source':'tinycam', 'render':'True'})
#obsWebSocket.makeRequest("SetSourceRender", data={'source':"tinycam", 'render': False, 'scene-name':"Cam feed (main) INFOBOX"})
#obsWebSocket.makeRequest("SetSourceRender", data={'source':"tinycam", 'render': True, 'scene-name':"Cam feed (main) INFOBOX"})
#obsWebSocket.listenForData()
def do_request(requestName, data):
if requestName in possibleRequests:
obsWebSocket.makeRequest(requestName, data)
@api.route('/api/v1/obs/websocket/makeRequest', methods=['GET'])
def makeRequest():
if 'request_name' not in request.args:
return flask.make_response('{\"text\":"Argument \'request_name\' not in request"}', 400)
if 'request_data' not in request.args:
data = None
else:
data = request.args['request_data']
#possibleRequests = obsWebSocket.getRequests()
do_request(request.args['request_name'], data)
if __name__ == "__main__":
init()
api.run(host='0.0.0.0', port=6009)

View File

@ -28,7 +28,7 @@ def send_text(tts_sender, tts_text):
resp = requests.get(url) resp = requests.get(url)
if resp.status_code == 200: if resp.status_code == 200:
print("Got the following message: %s" % resp.text) print("Got the following message: %s" % resp.text)
data = loads(resp.text) #data = loads(resp.text)
#msg = data['message'] #msg = data['message']
#if msg is not None: #if msg is not None:
#pass #pass

View File

@ -161,8 +161,8 @@ class Twitch_Pubsub():
is_actionable = self.is_reward(rewardName, rewardType) is_actionable = self.is_reward(rewardName, rewardType)
if is_actionable: if is_actionable:
praxis_logger_obj.log("Trying to do the thing") praxis_logger_obj.log("Trying to do the thing")
if self.cooldownModule.isCooldownActive("twitchpubsub") == False: #if self.cooldownModule.isCooldownActive("twitchpubsub") == False:
self.exec_reward(sender, rewardName, rewardType, rewardPrompt, userInput, raw_data) self.exec_reward(sender, rewardName, rewardType, rewardPrompt, userInput, raw_data)
except: except:
print("something went wrong with a reward") print("something went wrong with a reward")

View File

@ -35,13 +35,13 @@ def textSource_chyron():
return tempModule.getChyronFile() return tempModule.getChyronFile()
@api.route('/text/<file_name>/') @api.route('/text/<file_name>/')
def textSource_tempText(filename): def textSource_tempText(file_name):
print("trying file: ", filename) print("trying file: ", file_name)
tempModule = tempText_Module.tempText_Module() tempModule = tempText_Module.tempText_Module()
return tempModule.getTempTextFile(filename) return tempModule.getTempTextFile(file_name)
@api.route('/timer/<timer_name>/') @api.route('/timer/<timer_name>/')
def textSource_timers(filename): def textSource_timers(timer_name):
#print("trying file: ", filename) #print("trying file: ", filename)
#tempModule = tempText_Module.tempText_Module() #tempModule = tempText_Module.tempText_Module()
#tempModule.getTempTextFile(filename) #tempModule.getTempTextFile(filename)
@ -49,19 +49,4 @@ def textSource_timers(filename):
if __name__ == "__main__": if __name__ == "__main__":
init() init()
api.run(host="0.0.0.0", port = 5500) api.run(host="0.0.0.0", port = 5500)
#testModule_2 = webSource_Module()
#threads = []
#credentials_manager = credentials.Credentials_Module()
#credentials_manager.load_credentials()
#testModule.dbCredential = credentials_manager.find_DB_Credential(config.credentialsNickname)
#thread_ = threading.Thread(target=testModule.main(port_=6000))
#threads.append(thread_)
#thread_.start()
#for t in threads:
#t.join()