extra
This commit is contained in:
parent
fa376abad6
commit
0c12cffc53
76
channel_rewards/implemented/ChannelReward_twitchBits.py
Normal file
76
channel_rewards/implemented/ChannelReward_twitchBits.py
Normal file
@ -0,0 +1,76 @@
|
|||||||
|
from abc import ABCMeta
|
||||||
|
|
||||||
|
from channel_rewards.channelRewards_base import AbstractChannelRewards
|
||||||
|
|
||||||
|
from json import loads
|
||||||
|
from urllib.parse import urlencode
|
||||||
|
import requests
|
||||||
|
|
||||||
|
import threading
|
||||||
|
|
||||||
|
class ChannelReward_TwitchBits(AbstractChannelRewards, metaclass=ABCMeta):
|
||||||
|
"""
|
||||||
|
this is the hydration reward.
|
||||||
|
"""
|
||||||
|
ChannelRewardName = "TwitchBits"
|
||||||
|
|
||||||
|
def __init__(self):
|
||||||
|
super().__init__(ChannelReward_TwitchBits.ChannelRewardName, n_args=1, ChannelRewardType=AbstractChannelRewards.ChannelRewardsType.twitch_bits)
|
||||||
|
self.help = ["This is a hydration 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.dothething, args=(user, 16, "!lights hydration", ""))
|
||||||
|
thread_.daemon = True
|
||||||
|
self.threads.append(thread_)
|
||||||
|
thread_.start()
|
||||||
|
if self.is_ChannelReward_enabled:
|
||||||
|
thread_ = threading.Thread(target=self.send_TTS, args=(user, rewardPrompt))
|
||||||
|
thread_.daemon = True
|
||||||
|
self.threads.append(thread_)
|
||||||
|
thread_.start()
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
|
||||||
|
return None
|
||||||
|
|
||||||
|
def dothething(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_help(self):
|
||||||
|
return self.help
|
||||||
76
channel_rewards/implemented/ChannelReward_twitchSubs.py
Normal file
76
channel_rewards/implemented/ChannelReward_twitchSubs.py
Normal file
@ -0,0 +1,76 @@
|
|||||||
|
from abc import ABCMeta
|
||||||
|
|
||||||
|
from channel_rewards.channelRewards_base import AbstractChannelRewards
|
||||||
|
|
||||||
|
from json import loads
|
||||||
|
from urllib.parse import urlencode
|
||||||
|
import requests
|
||||||
|
|
||||||
|
import threading
|
||||||
|
|
||||||
|
class ChannelReward_TwitchSubs(AbstractChannelRewards, metaclass=ABCMeta):
|
||||||
|
"""
|
||||||
|
this is the TwitchSubs reward.
|
||||||
|
"""
|
||||||
|
ChannelRewardName = "TwitchSub"
|
||||||
|
|
||||||
|
def __init__(self):
|
||||||
|
super().__init__(ChannelReward_TwitchSubs.ChannelRewardName, n_args=1, ChannelRewardType=AbstractChannelRewards.ChannelRewardsType.twitch_subs)
|
||||||
|
self.help = ["This is a hydration 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.dothething, args=(user, 16, "!lights hydration", ""))
|
||||||
|
thread_.daemon = True
|
||||||
|
self.threads.append(thread_)
|
||||||
|
thread_.start()
|
||||||
|
if self.is_ChannelReward_enabled:
|
||||||
|
thread_ = threading.Thread(target=self.send_TTS, args=(user, rewardPrompt))
|
||||||
|
thread_.daemon = True
|
||||||
|
self.threads.append(thread_)
|
||||||
|
thread_.start()
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
|
||||||
|
return None
|
||||||
|
|
||||||
|
def dothething(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_help(self):
|
||||||
|
return self.help
|
||||||
@ -14,7 +14,7 @@ praxis_logger_obj.log("\n -Starting Logs: " + os.path.basename(__file__))
|
|||||||
|
|
||||||
api = flask.Flask(__name__)
|
api = flask.Flask(__name__)
|
||||||
# enable/disable this to get web pages of crashes returned
|
# enable/disable this to get web pages of crashes returned
|
||||||
api.config["DEBUG"] = True
|
api.config["DEBUG"] = False
|
||||||
|
|
||||||
def init():
|
def init():
|
||||||
praxis_logger_obj.log("init stuff")
|
praxis_logger_obj.log("init stuff")
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user