42 lines
1.6 KiB
Python
42 lines
1.6 KiB
Python
from abc import ABCMeta
|
|
|
|
from channel_rewards.channelRewards_base import AbstractChannelRewards
|
|
|
|
from json import loads
|
|
from urllib.parse import urlencode
|
|
import requests
|
|
|
|
class ChannelReward_Hydration_v2(AbstractChannelRewards, metaclass=ABCMeta):
|
|
"""
|
|
this is the hydration reward.
|
|
"""
|
|
ChannelRewardName = "Hydrate"
|
|
|
|
def __init__(self):
|
|
super().__init__(ChannelReward_Hydration_v2.ChannelRewardName, n_args=1, ChannelRewardType=AbstractChannelRewards.ChannelRewardsType.channelPoints)
|
|
self.help = ["This is a hydration channel point reward."]
|
|
self.isChannelRewardEnabled = True
|
|
|
|
def do_ChannelReward(self, source = AbstractChannelRewards.ChannelRewardsSource.default, user = "User", rewardName = "", rewardPrompt = "", userInput = "", bonusData = None):
|
|
self.dothething(user, 16, "!lights hydration", "")
|
|
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:
|
|
praxis_logger_obj.log("Got the following message: %s" % resp.text)
|
|
data = loads(resp.text)
|
|
msg = data['message']
|
|
if msg is not None:
|
|
pass
|
|
# todo send to logger and other relevent services
|
|
else:
|
|
# todo handle failed requests
|
|
pass
|
|
|
|
def get_help(self):
|
|
return self.help |