Compare commits
7 Commits
572817a006
...
72ea8f7b71
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
72ea8f7b71 | ||
|
|
3d0f2b0a90 | ||
|
|
5d9831fc30 | ||
|
|
e05183ffeb | ||
|
|
f0601974be | ||
|
|
ff4b9af8b4 | ||
|
|
b3667bb2fc |
@ -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()
|
||||||
|
|||||||
@ -4,6 +4,7 @@ from commands.command_base import AbstractCommand
|
|||||||
|
|
||||||
from json import loads
|
from json import loads
|
||||||
from urllib.parse import urlencode
|
from urllib.parse import urlencode
|
||||||
|
from urllib.parse import parse_qs
|
||||||
import requests
|
import requests
|
||||||
|
|
||||||
import config
|
import config
|
||||||
@ -42,9 +43,15 @@ class Command_tts_v2(AbstractCommand, metaclass=ABCMeta):
|
|||||||
elif "Discord" in source:
|
elif "Discord" in source:
|
||||||
for name in config.allowedTTS_List:
|
for name in config.allowedTTS_List:
|
||||||
print(name)
|
print(name)
|
||||||
|
|
||||||
|
|
||||||
|
for key_ in fixedData:
|
||||||
|
praxis_logger_obj.log(key_)
|
||||||
|
|
||||||
|
|
||||||
tempName = user.lower()
|
tempName = user.lower()
|
||||||
if name == tempName:
|
if name == tempName:
|
||||||
self.send_TTS(user, rest)
|
self.send_TTS(fixedData.author.nick, rest)
|
||||||
else:
|
else:
|
||||||
returnString = self.send_TTS(user, rest)
|
returnString = self.send_TTS(user, rest)
|
||||||
|
|
||||||
|
|||||||
16
config.py
16
config.py
@ -3,9 +3,6 @@ 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
|
||||||
|
|
||||||
@ -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
70
obsWebSocket.py
Normal 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
|
||||||
45
standalone_obsWebSocket.py
Normal file
45
standalone_obsWebSocket.py
Normal 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)
|
||||||
@ -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
|
||||||
|
|||||||
@ -3,9 +3,6 @@ from os import F_OK
|
|||||||
import tempText_Module
|
import tempText_Module
|
||||||
import time
|
import time
|
||||||
import config as config
|
import config as config
|
||||||
import db
|
|
||||||
import tts
|
|
||||||
import threading
|
|
||||||
|
|
||||||
from flask import Flask
|
from flask import Flask
|
||||||
|
|
||||||
|
|||||||
104
timers_module.py
Normal file
104
timers_module.py
Normal file
@ -0,0 +1,104 @@
|
|||||||
|
import os
|
||||||
|
import json
|
||||||
|
import time
|
||||||
|
import datetime
|
||||||
|
import utilities_script as utility
|
||||||
|
|
||||||
|
class timer():
|
||||||
|
def __init__(self, name, startTime, endTime, trigger, trigger_exec, tempTimer = True):
|
||||||
|
self.name = name
|
||||||
|
self.startTime = startTime
|
||||||
|
self.endTime = endTime
|
||||||
|
self.trigger = trigger
|
||||||
|
self.trigger_exec = trigger_exec
|
||||||
|
self.tempTimer = tempTimer # If enabled this will cause the Timer to be deleted upon shutdown or startup
|
||||||
|
|
||||||
|
class Timers_Module():
|
||||||
|
def __init__(self):
|
||||||
|
super().__init__()
|
||||||
|
self.timersList = []
|
||||||
|
|
||||||
|
def main(self):
|
||||||
|
self.createTimer()
|
||||||
|
|
||||||
|
def updateTimersList(self):
|
||||||
|
pass
|
||||||
|
|
||||||
|
def createTimer(self, days=0, hours=0, minutes=0, seconds=0, microseconds=0, trigger="", trigger_exec="", tempTimer=True):
|
||||||
|
temp = datetime.datetime.now()
|
||||||
|
targetTime = temp + datetime.timedelta(days=days, hours=hours, minutes=minutes, seconds=seconds, microseconds=microseconds)
|
||||||
|
|
||||||
|
newTimer= timer()
|
||||||
|
newTimer.startTime = temp
|
||||||
|
newTimer.endTime = targetTime
|
||||||
|
newTimer.trigger = trigger
|
||||||
|
newTimer.trigger_exec = trigger_exec
|
||||||
|
newTimer.tempTimer = tempTimer
|
||||||
|
|
||||||
|
self.timersList.append(newTimer)
|
||||||
|
|
||||||
|
def checkTimer(self, name):
|
||||||
|
|
||||||
|
name, startTime, endTime, trigger, trigger_exec, tempTimer = self.readFile(name)
|
||||||
|
if endTime < datetime.datetime.now():
|
||||||
|
print("do timer thing")
|
||||||
|
self.TIMER_EXEC(name, startTime, endTime, trigger, trigger_exec, tempTimer)
|
||||||
|
|
||||||
|
|
||||||
|
def deleteTimer(self, name):
|
||||||
|
self.deleteFile(name)
|
||||||
|
|
||||||
|
|
||||||
|
def TIMER_EXEC(self, name, startTime, endTime, trigger, trigger_exec, tempTimer):
|
||||||
|
print(trigger, trigger_exec, "at", endTime)
|
||||||
|
|
||||||
|
if tempTimer == True:
|
||||||
|
print("deleting " + name)
|
||||||
|
self.deleteTimer(name)
|
||||||
|
|
||||||
|
|
||||||
|
def makeFile(self, name, startTime, endTime, trigger, trigger_exec, tempTimer = True):
|
||||||
|
dir = utility.get_dir("stream_sources/timers")
|
||||||
|
script_dir = os.path.dirname(__file__) #<-- absolute dir the script is in
|
||||||
|
relative_path = name + ".json"
|
||||||
|
real_file_path = os.path.join(script_dir, relative_path)
|
||||||
|
with open(real_file_path, 'rw') as cred_r:
|
||||||
|
data = json.load(cred_r)
|
||||||
|
data['name'] = name
|
||||||
|
data['startTime'] = startTime
|
||||||
|
data['endTime'] = endTime
|
||||||
|
data['trigger'] = trigger
|
||||||
|
data['trigger_exec'] = trigger_exec
|
||||||
|
data['tempTimer'] = tempTimer
|
||||||
|
|
||||||
|
with open(real_file_path, 'w') as cred_w:
|
||||||
|
json.dump(data, cred_w, indent=2)
|
||||||
|
|
||||||
|
def readFile(self, name):
|
||||||
|
dir = utility.get_dir("stream_sources/timers")
|
||||||
|
script_dir = os.path.dirname(__file__) #<-- absolute dir the script is in
|
||||||
|
relative_path = name + ".json"
|
||||||
|
real_file_path = os.path.join(script_dir, relative_path)
|
||||||
|
|
||||||
|
startTime, endTime, trigger, tempTimer = None
|
||||||
|
with open(real_file_path, 'r') as cred_r:
|
||||||
|
data = json.load(cred_r)
|
||||||
|
name = data['name']
|
||||||
|
startTime = data['startTime']
|
||||||
|
endTime = data['endTime']
|
||||||
|
trigger = data['trigger']
|
||||||
|
trigger_exec = data['trigger_exec']
|
||||||
|
tempTimer = data['tempTimer']
|
||||||
|
return name, startTime, endTime, trigger, trigger_exec, tempTimer
|
||||||
|
|
||||||
|
def deleteFile(self, name):
|
||||||
|
dir = utility.get_dir("stream_sources/timers")
|
||||||
|
script_dir = os.path.dirname(__file__) #<-- absolute dir the script is in
|
||||||
|
relative_path = name + ".json"
|
||||||
|
real_file_path = os.path.join(script_dir, relative_path)
|
||||||
|
os.remove(real_file_path)
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
testModule = Timers_Module()
|
||||||
|
testModule.main()
|
||||||
Loading…
Reference in New Issue
Block a user