master branch updates #19
84
chyron_module.py
Normal file
84
chyron_module.py
Normal file
@ -0,0 +1,84 @@
|
||||
import config
|
||||
|
||||
class Chyron_Module():
|
||||
def __init__(self):
|
||||
super().__init__()
|
||||
self.chyron_computedString = ""
|
||||
self.chyron_items:list = []
|
||||
|
||||
def chyron_stringUpdater(self):
|
||||
newString = ""
|
||||
for c in self.chyron_items:
|
||||
c.item_stringUpdater()
|
||||
newString = newString + c.itemComputedString
|
||||
for x in range(config.chyronListSpaceCount):
|
||||
newString = newString + " "
|
||||
self.chyron_computedString = newString
|
||||
|
||||
def addItem(self, name, title, content):
|
||||
newItem:ChyronItem = ChyronItem()
|
||||
newItem.setupItem(name, title, content)
|
||||
self.chyron_items.append(newItem)
|
||||
|
||||
def removeItem(self, name):
|
||||
for c in self.chyron_items:
|
||||
if c.itemName == name:
|
||||
self.chyron_items.remove(c)
|
||||
|
||||
|
||||
class ChyronItem():
|
||||
def __init__(self):
|
||||
super().__init__()
|
||||
self.itemName = ""
|
||||
|
||||
self.includeTitle = True
|
||||
self.itemTitle = ""
|
||||
self.itemContent = ""
|
||||
|
||||
self.itemComputedString = ""
|
||||
|
||||
def setupItem(self, name, title, content):
|
||||
print("Setting up Item {", name,"}[", title, content, "]")
|
||||
self.itemName = name
|
||||
self.itemTitle = title
|
||||
self.itemContent = content
|
||||
|
||||
def item_stringUpdater(self):
|
||||
newString = ""
|
||||
if self.includeTitle == True:
|
||||
newString = newString + self.itemTitle
|
||||
newString = newString + self.itemContent
|
||||
self.itemComputedString = newString
|
||||
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
testModule = Chyron_Module()
|
||||
testModule.addItem(
|
||||
"test",
|
||||
"Now: ",
|
||||
"Coding Stream")
|
||||
testModule.addItem(
|
||||
"FriSat",
|
||||
"► Friday & Saturday: ",
|
||||
"Coding Stream")
|
||||
testModule.addItem(
|
||||
"Commands",
|
||||
"► Commands: ",
|
||||
"!animal, !climateclock, !discord, !page, !roll")
|
||||
testModule.addItem(
|
||||
"Website",
|
||||
"► Want to read about my various projects? visit: ",
|
||||
"TheCuriousNerd.com")
|
||||
testModule.addItem(
|
||||
"Follow",
|
||||
"",
|
||||
"► If you like what you see, hit that follow button to see more!")
|
||||
testModule.addItem(
|
||||
"Discord",
|
||||
"► Want to join our discord? type \" !d \" in chat to get the link or visit: ",
|
||||
"discord.io/thecuriousnerd")
|
||||
testModule.chyron_stringUpdater()
|
||||
|
||||
test = testModule.chyron_computedString + "<<<|"
|
||||
print(test)
|
||||
@ -14,6 +14,7 @@ class AbstractCommand(metaclass=ABCMeta):
|
||||
|
||||
class CommandType(Enum):
|
||||
NONE = auto()
|
||||
Praxis = auto()
|
||||
TWITCH = auto()
|
||||
DISCORD = auto()
|
||||
|
||||
|
||||
58
commands/implemented/command_lights_rgb_color.py
Normal file
58
commands/implemented/command_lights_rgb_color.py
Normal file
@ -0,0 +1,58 @@
|
||||
from abc import ABCMeta
|
||||
import lights_module
|
||||
|
||||
from commands.command_base import AbstractCommand
|
||||
|
||||
import random
|
||||
|
||||
import utilities_script as utilities
|
||||
|
||||
class CommandRoll(AbstractCommand, metaclass=ABCMeta):
|
||||
"""
|
||||
this is the roll command.
|
||||
"""
|
||||
command = "!lights"
|
||||
|
||||
def __init__(self):
|
||||
super().__init__(CommandRoll.command, n_args=3, command_type=AbstractCommand.CommandType.Praxis)
|
||||
|
||||
def do_command(self, bot, user_message):
|
||||
tempBool = True
|
||||
if tempBool == True:
|
||||
LightModule = lights_module.Lights_Module()
|
||||
LightModule.main()
|
||||
print("\nRGB Command Detected!")
|
||||
|
||||
tempParsedMessage = user_message.message.split(" ")
|
||||
print("\nParsed Command! ", user_message.message)
|
||||
if (len(tempParsedMessage)) > 2:
|
||||
print("\nRGB Command!")
|
||||
rgb_r = float(tempParsedMessage[1])
|
||||
rgb_g = float(tempParsedMessage[2])
|
||||
rgb_b = float(tempParsedMessage[3])
|
||||
xy_result = LightModule.rgb_to_xy(rgb_r, rgb_g, rgb_b)
|
||||
print("got XY")
|
||||
LightModule.bridge_.set_group(16, "xy", xy_result)
|
||||
print("sent color")
|
||||
else:
|
||||
if "stream" in tempParsedMessage:
|
||||
LightModule.bridge_.run_scene("Downstairs", "Stream")
|
||||
elif "normal" in tempParsedMessage:
|
||||
LightModule.bridge_.run_scene("Downstairs", "Bright")
|
||||
elif "haxor" in tempParsedMessage:
|
||||
LightModule.bridge_.run_scene("Downstairs", "hacker vibes")
|
||||
elif "off" in tempParsedMessage:
|
||||
LightModule.bridge_.set_group("Downstairs", "on", False)
|
||||
elif "on" in tempParsedMessage:
|
||||
LightModule.bridge_.set_group("Downstairs", "on", True)
|
||||
elif "ravemode" in tempParsedMessage:
|
||||
LightModule.raveMode()
|
||||
else:
|
||||
print("\nColor Command!")
|
||||
xy_result = LightModule.color_string_parser(tempParsedMessage)
|
||||
print("got XY")
|
||||
LightModule.bridge_.set_group(16, "xy", xy_result)
|
||||
print("sent color")
|
||||
|
||||
returnMessage = "@" + user_message.user + " changed the light's color!"
|
||||
bot.return_message(returnMessage)
|
||||
57
commands/implemented/command_lights_rgb_color_twitch.py
Normal file
57
commands/implemented/command_lights_rgb_color_twitch.py
Normal file
@ -0,0 +1,57 @@
|
||||
from abc import ABCMeta
|
||||
import lights_module
|
||||
|
||||
from commands.command_base import AbstractCommand
|
||||
|
||||
import random
|
||||
|
||||
import utilities_script as utilities
|
||||
|
||||
class CommandRoll(AbstractCommand, metaclass=ABCMeta):
|
||||
"""
|
||||
this is the roll command.
|
||||
"""
|
||||
command = "!lights"
|
||||
|
||||
def __init__(self):
|
||||
super().__init__(CommandRoll.command, n_args=3, command_type=AbstractCommand.CommandType.TWITCH)
|
||||
|
||||
def do_command(self, bot, twitch_message):
|
||||
if bot.allow_rgbLightControl == True:
|
||||
LightModule = lights_module.Lights_Module()
|
||||
LightModule.main()
|
||||
print("\nRGB Command Detected!")
|
||||
|
||||
tempParsedMessage = twitch_message.text.split(" ")
|
||||
print("\nParsed Command! ", twitch_message.text)
|
||||
if (len(tempParsedMessage)) > 2:
|
||||
print("\nRGB Command!")
|
||||
rgb_r = float(tempParsedMessage[1])
|
||||
rgb_g = float(tempParsedMessage[2])
|
||||
rgb_b = float(tempParsedMessage[3])
|
||||
xy_result = LightModule.rgb_to_xy(rgb_r, rgb_g, rgb_b)
|
||||
print("got XY")
|
||||
LightModule.bridge_.set_group(16, "xy", xy_result)
|
||||
print("sent color")
|
||||
else:
|
||||
if "stream" in tempParsedMessage:
|
||||
LightModule.bridge_.run_scene("Downstairs", "Stream")
|
||||
elif "normal" in tempParsedMessage:
|
||||
LightModule.bridge_.run_scene("Downstairs", "Bright")
|
||||
elif "haxor" in tempParsedMessage:
|
||||
LightModule.bridge_.run_scene("Downstairs", "hacker vibes")
|
||||
elif "off" in tempParsedMessage:
|
||||
LightModule.bridge_.set_group("Downstairs", "on", False)
|
||||
elif "on" in tempParsedMessage:
|
||||
LightModule.bridge_.set_group("Downstairs", "on", True)
|
||||
elif "ravemode" in tempParsedMessage:
|
||||
LightModule.raveMode()
|
||||
else:
|
||||
print("\nColor Command!")
|
||||
xy_result = LightModule.color_string_parser(tempParsedMessage)
|
||||
print("got XY")
|
||||
LightModule.bridge_.set_group(16, "xy", xy_result)
|
||||
print("sent color")
|
||||
|
||||
returnMessage = "@" + twitch_message.sender + " changed the light's color!"
|
||||
bot.send_message(returnMessage)
|
||||
@ -1,66 +0,0 @@
|
||||
from abc import ABCMeta
|
||||
|
||||
from commands.command_base import AbstractCommand
|
||||
|
||||
import random
|
||||
|
||||
class CommandRoll(AbstractCommand, metaclass=ABCMeta):
|
||||
"""
|
||||
this is the roll command.
|
||||
"""
|
||||
command = "!roll"
|
||||
|
||||
def __init__(self):
|
||||
super().__init__(CommandRoll.command, n_args=1, command_type=AbstractCommand.CommandType.TWITCH)
|
||||
|
||||
def do_command(self, bot, twitch_message):
|
||||
print("!roll Detected")
|
||||
#twitch_message.chat.send("test acknowledged")
|
||||
|
||||
diceRoll: str = ""
|
||||
bot.send_message("Rolling Dice...")
|
||||
print("Rolling Dice...")
|
||||
|
||||
temp_preParsedMessage = twitch_message.text.split("+")
|
||||
|
||||
tempParsedMessage = temp_preParsedMessage[0].split(" ")
|
||||
temp_dice_stmt: str = tempParsedMessage[1]
|
||||
parsedMessage = temp_dice_stmt.lower().split("d")
|
||||
|
||||
loopBool: bool = False
|
||||
if parsedMessage[0] != "":
|
||||
loopBool = True
|
||||
if loopBool == True:
|
||||
if int(parsedMessage[0]) == 1:
|
||||
loopBool = False
|
||||
|
||||
# If roll is in xdx+x format
|
||||
if loopBool == True:
|
||||
rolls: list = []
|
||||
for x in range(int(parsedMessage[0])):
|
||||
rolls.append(random.randint(1, int(parsedMessage[1])))
|
||||
|
||||
rollTotal = 0
|
||||
for roll in rolls:
|
||||
rollTotal = rollTotal + roll
|
||||
diceRoll = diceRoll + str(roll) + ", "
|
||||
diceRoll = diceRoll[:-2] # This removes the last two characters in the string
|
||||
|
||||
if len(temp_preParsedMessage) == 2:
|
||||
diceRoll = diceRoll + " + " + temp_preParsedMessage[1] + " = " + str(
|
||||
rollTotal + int(temp_preParsedMessage[1]))
|
||||
else:
|
||||
diceRoll = diceRoll + " = " + str(rollTotal)
|
||||
# If roll is in dx+x format
|
||||
if loopBool == False:
|
||||
roll: int = random.randint(1, int(parsedMessage[1]))
|
||||
|
||||
if len(temp_preParsedMessage) == 2:
|
||||
diceRoll = str(roll) + " + " + temp_preParsedMessage[1] + " = " + str(
|
||||
roll + int(temp_preParsedMessage[1]))
|
||||
else:
|
||||
diceRoll = str(roll)
|
||||
|
||||
diceRoll = "@" + twitch_message.sender + " rolled: " + diceRoll
|
||||
print(diceRoll)
|
||||
bot.send_message(diceRoll)
|
||||
@ -28,6 +28,73 @@ class CommandRoll(AbstractCommand, metaclass=ABCMeta):
|
||||
#await discord_message.channel.send("Rolling Dice...")
|
||||
print("Rolling Dice...")
|
||||
|
||||
if ("f") in discord_message.content.lower():
|
||||
diceRoll = await self.roll(2, discord_message)
|
||||
else:
|
||||
diceRoll = await self.roll(1, discord_message)
|
||||
|
||||
#========================
|
||||
#Old Code Below
|
||||
#========================
|
||||
|
||||
# temp_preParsedMessage = discord_message.content.split("+")
|
||||
|
||||
# tempParsedMessage = temp_preParsedMessage[0].split(" ")
|
||||
# temp_dice_stmt: str = tempParsedMessage[1]
|
||||
# parsedMessage = temp_dice_stmt.lower().split("d")
|
||||
|
||||
# loopBool: bool = False
|
||||
# if parsedMessage[0] != "":
|
||||
# loopBool = True
|
||||
# if loopBool == True:
|
||||
# if int(parsedMessage[0]) == 1:
|
||||
# loopBool = False
|
||||
|
||||
# # If roll is in xdx+x format
|
||||
# if loopBool == True:
|
||||
# rolls: list = []
|
||||
# for x in range(int(parsedMessage[0])):
|
||||
# rolls.append(random.randint(1, int(parsedMessage[1])))
|
||||
|
||||
# rollTotal = 0
|
||||
# for roll in rolls:
|
||||
# rollTotal = rollTotal + roll
|
||||
# diceRoll = diceRoll + str(roll) + ", "
|
||||
# diceRoll = diceRoll[:-2] # This removes the last two characters in the string
|
||||
|
||||
# if len(temp_preParsedMessage) == 2:
|
||||
# diceRoll = diceRoll + " + " + temp_preParsedMessage[1] + " = " + str(
|
||||
# rollTotal + int(temp_preParsedMessage[1]))
|
||||
# else:
|
||||
# diceRoll = diceRoll + " = " + str(rollTotal)
|
||||
# # If roll is in dx+x format
|
||||
# if loopBool == False:
|
||||
# roll: int = random.randint(1, int(parsedMessage[1]))
|
||||
|
||||
# if len(temp_preParsedMessage) == 2:
|
||||
# diceRoll = str(roll) + " + " + temp_preParsedMessage[1] + " = " + str(
|
||||
# roll + int(temp_preParsedMessage[1]))
|
||||
# else:
|
||||
# diceRoll = str(roll)
|
||||
|
||||
# diceRoll = discord_message.author.mention + " rolled: " + diceRoll
|
||||
# print(diceRoll)
|
||||
|
||||
#========================
|
||||
#Old Code Above
|
||||
#========================
|
||||
|
||||
|
||||
|
||||
await bot.send_message(discord_message, diceRoll)
|
||||
#await discord_message.channel.send(diceRoll)
|
||||
|
||||
async def roll(self, roll_type, discord_message: discord.Message):
|
||||
diceRoll = ""
|
||||
switch = {
|
||||
1: "Standard",
|
||||
2: "Fate Dice"
|
||||
}
|
||||
temp_preParsedMessage = discord_message.content.split("+")
|
||||
|
||||
tempParsedMessage = temp_preParsedMessage[0].split(" ")
|
||||
@ -41,34 +108,68 @@ class CommandRoll(AbstractCommand, metaclass=ABCMeta):
|
||||
if int(parsedMessage[0]) == 1:
|
||||
loopBool = False
|
||||
|
||||
# If roll is in xdx+x format
|
||||
if loopBool == True:
|
||||
rolls: list = []
|
||||
for x in range(int(parsedMessage[0])):
|
||||
rolls.append(random.randint(1, int(parsedMessage[1])))
|
||||
if roll_type == 1:
|
||||
# If roll is in xdx+x format
|
||||
if loopBool == True:
|
||||
rolls: list = []
|
||||
for x in range(int(parsedMessage[0])):
|
||||
rolls.append(random.randint(1, int(parsedMessage[1]))) # This is the roller
|
||||
|
||||
rollTotal = 0
|
||||
for roll in rolls:
|
||||
rollTotal = rollTotal + roll
|
||||
diceRoll = diceRoll + str(roll) + ", "
|
||||
diceRoll = diceRoll[:-2] # This removes the last two characters in the string
|
||||
rollTotal = 0
|
||||
for roll in rolls:
|
||||
rollTotal = rollTotal + roll
|
||||
diceRoll = diceRoll + str(roll) + ", "
|
||||
diceRoll = diceRoll[:-2] # This removes the last two characters in the string
|
||||
|
||||
if len(temp_preParsedMessage) == 2:
|
||||
diceRoll = diceRoll + " + " + temp_preParsedMessage[1] + " = " + str(
|
||||
rollTotal + int(temp_preParsedMessage[1]))
|
||||
else:
|
||||
diceRoll = diceRoll + " = " + str(rollTotal)
|
||||
# If roll is in dx+x format
|
||||
if loopBool == False:
|
||||
roll: int = random.randint(1, int(parsedMessage[1]))
|
||||
if len(temp_preParsedMessage) == 2:
|
||||
diceRoll = diceRoll + " + " + temp_preParsedMessage[1] + " = " + str(
|
||||
rollTotal + int(temp_preParsedMessage[1]))
|
||||
else:
|
||||
diceRoll = diceRoll + " = " + str(rollTotal)
|
||||
# If roll is in dx+x format
|
||||
if loopBool == False:
|
||||
roll: int = random.randint(1, int(parsedMessage[1])) # This is the roller
|
||||
|
||||
if len(temp_preParsedMessage) == 2:
|
||||
diceRoll = str(roll) + " + " + temp_preParsedMessage[1] + " = " + str(
|
||||
roll + int(temp_preParsedMessage[1]))
|
||||
else:
|
||||
diceRoll = str(roll)
|
||||
if len(temp_preParsedMessage) == 2:
|
||||
diceRoll = str(roll) + " + " + temp_preParsedMessage[1] + " = " + str(
|
||||
roll + int(temp_preParsedMessage[1]))
|
||||
else:
|
||||
diceRoll = str(roll)
|
||||
|
||||
diceRoll = discord_message.author.mention + " rolled: " + diceRoll
|
||||
print(diceRoll)
|
||||
await bot.send_message(discord_message, diceRoll)
|
||||
#await discord_message.channel.send(diceRoll)
|
||||
diceRoll = discord_message.author.mention + " rolled: " + diceRoll
|
||||
print(diceRoll)
|
||||
|
||||
if roll_type == 2:
|
||||
print("fate Rolling....")
|
||||
# !roll 4df
|
||||
# If roll is in xdx+x format
|
||||
if loopBool == True:
|
||||
rolls: list = []
|
||||
for x in range(int(parsedMessage[0])):
|
||||
rolls.append(random.randint(-1, 1)) # This is the roller
|
||||
|
||||
rollTotal = 0
|
||||
for roll in rolls:
|
||||
rollTotal = rollTotal + roll
|
||||
diceRoll = diceRoll + str(roll) + ", "
|
||||
diceRoll = diceRoll[:-2] # This removes the last two characters in the string
|
||||
|
||||
if len(temp_preParsedMessage) == 2:
|
||||
diceRoll = diceRoll + " + " + temp_preParsedMessage[1] + " = " + str(
|
||||
rollTotal + int(temp_preParsedMessage[1]))
|
||||
else:
|
||||
diceRoll = diceRoll + " = " + str(rollTotal)
|
||||
# If roll is in dx+x format
|
||||
if loopBool == False:
|
||||
roll: int = random.randint(-1, 1) # This is the roller
|
||||
|
||||
if len(temp_preParsedMessage) == 2:
|
||||
diceRoll = str(roll) + " + " + temp_preParsedMessage[1] + " = " + str(
|
||||
roll + int(temp_preParsedMessage[1]))
|
||||
else:
|
||||
diceRoll = str(roll)
|
||||
|
||||
diceRoll = discord_message.author.mention + " fate rolled: " + diceRoll
|
||||
print(diceRoll)
|
||||
|
||||
return diceRoll
|
||||
|
||||
168
commands/implemented/command_roll_twitch.py
Normal file
168
commands/implemented/command_roll_twitch.py
Normal file
@ -0,0 +1,168 @@
|
||||
from abc import ABCMeta
|
||||
|
||||
from commands.command_base import AbstractCommand
|
||||
|
||||
import random
|
||||
|
||||
class CommandRoll(AbstractCommand, metaclass=ABCMeta):
|
||||
"""
|
||||
this is the roll command.
|
||||
"""
|
||||
command = "!roll"
|
||||
|
||||
def __init__(self):
|
||||
super().__init__(CommandRoll.command, n_args=1, command_type=AbstractCommand.CommandType.TWITCH)
|
||||
|
||||
def do_command(self, bot, twitch_message):
|
||||
print("!roll Detected")
|
||||
#twitch_message.chat.send("test acknowledged")
|
||||
|
||||
diceRoll: str = ""
|
||||
bot.send_message("Rolling Dice...")
|
||||
print("Rolling Dice...")
|
||||
|
||||
if ("f") in twitch_message.text.lower():
|
||||
diceRoll = self.roll(2, twitch_message)
|
||||
else:
|
||||
diceRoll = self.roll(1, twitch_message)
|
||||
|
||||
#========================
|
||||
#Old Code Below
|
||||
#========================
|
||||
|
||||
# temp_preParsedMessage = twitch_message.text.split("+")
|
||||
|
||||
# tempParsedMessage = temp_preParsedMessage[0].split(" ")
|
||||
# temp_dice_stmt: str = tempParsedMessage[1]
|
||||
# parsedMessage = temp_dice_stmt.lower().split("d")
|
||||
|
||||
# loopBool: bool = False
|
||||
# if parsedMessage[0] != "":
|
||||
# loopBool = True
|
||||
# if loopBool == True:
|
||||
# if int(parsedMessage[0]) == 1:
|
||||
# loopBool = False
|
||||
|
||||
# # If roll is in xdx+x format
|
||||
# if loopBool == True:
|
||||
# rolls: list = []
|
||||
# for x in range(int(parsedMessage[0])):
|
||||
# rolls.append(random.randint(1, int(parsedMessage[1])))
|
||||
|
||||
# rollTotal = 0
|
||||
# for roll in rolls:
|
||||
# rollTotal = rollTotal + roll
|
||||
# diceRoll = diceRoll + str(roll) + ", "
|
||||
# diceRoll = diceRoll[:-2] # This removes the last two characters in the string
|
||||
|
||||
# if len(temp_preParsedMessage) == 2:
|
||||
# diceRoll = diceRoll + " + " + temp_preParsedMessage[1] + " = " + str(
|
||||
# rollTotal + int(temp_preParsedMessage[1]))
|
||||
# else:
|
||||
# diceRoll = diceRoll + " = " + str(rollTotal)
|
||||
# # If roll is in dx+x format
|
||||
# if loopBool == False:
|
||||
# roll: int = random.randint(1, int(parsedMessage[1]))
|
||||
|
||||
# if len(temp_preParsedMessage) == 2:
|
||||
# diceRoll = str(roll) + " + " + temp_preParsedMessage[1] + " = " + str(
|
||||
# roll + int(temp_preParsedMessage[1]))
|
||||
# else:
|
||||
# diceRoll = str(roll)
|
||||
|
||||
# diceRoll = "@" + twitch_message.sender + " rolled: " + diceRoll
|
||||
# print(diceRoll)
|
||||
|
||||
|
||||
#========================
|
||||
#Old Code Above
|
||||
#========================
|
||||
|
||||
bot.send_message(diceRoll)
|
||||
|
||||
|
||||
def roll(self, roll_type, twitch_message):
|
||||
diceRoll = ""
|
||||
switch = {
|
||||
1: "Standard",
|
||||
2: "Fate Dice"
|
||||
}
|
||||
temp_preParsedMessage = twitch_message.text.split("+")
|
||||
|
||||
tempParsedMessage = temp_preParsedMessage[0].split(" ")
|
||||
temp_dice_stmt: str = tempParsedMessage[1]
|
||||
parsedMessage = temp_dice_stmt.lower().split("d")
|
||||
|
||||
loopBool: bool = False
|
||||
if parsedMessage[0] != "":
|
||||
loopBool = True
|
||||
if loopBool == True:
|
||||
if int(parsedMessage[0]) == 1:
|
||||
loopBool = False
|
||||
|
||||
if roll_type == 1:
|
||||
# If roll is in xdx+x format
|
||||
if loopBool == True:
|
||||
rolls: list = []
|
||||
for x in range(int(parsedMessage[0])):
|
||||
rolls.append(random.randint(1, int(parsedMessage[1]))) # This is the roller
|
||||
|
||||
rollTotal = 0
|
||||
for roll in rolls:
|
||||
rollTotal = rollTotal + roll
|
||||
diceRoll = diceRoll + str(roll) + ", "
|
||||
diceRoll = diceRoll[:-2] # This removes the last two characters in the string
|
||||
|
||||
if len(temp_preParsedMessage) == 2:
|
||||
diceRoll = diceRoll + " + " + temp_preParsedMessage[1] + " = " + str(
|
||||
rollTotal + int(temp_preParsedMessage[1]))
|
||||
else:
|
||||
diceRoll = diceRoll + " = " + str(rollTotal)
|
||||
# If roll is in dx+x format
|
||||
if loopBool == False:
|
||||
roll: int = random.randint(1, int(parsedMessage[1])) # This is the roller
|
||||
|
||||
if len(temp_preParsedMessage) == 2:
|
||||
diceRoll = str(roll) + " + " + temp_preParsedMessage[1] + " = " + str(
|
||||
roll + int(temp_preParsedMessage[1]))
|
||||
else:
|
||||
diceRoll = str(roll)
|
||||
|
||||
diceRoll = "@" + twitch_message.sender + " rolled: " + diceRoll
|
||||
print(diceRoll)
|
||||
|
||||
if roll_type == 2:
|
||||
|
||||
print("fate Rolling....")
|
||||
# !roll 4df
|
||||
# If roll is in xdx+x format
|
||||
if loopBool == True:
|
||||
rolls: list = []
|
||||
for x in range(int(parsedMessage[0])):
|
||||
rolls.append(random.randint(-1, 1)) # This is the roller
|
||||
|
||||
rollTotal = 0
|
||||
for roll in rolls:
|
||||
rollTotal = rollTotal + roll
|
||||
diceRoll = diceRoll + str(roll) + ", "
|
||||
diceRoll = diceRoll[:-2] # This removes the last two characters in the string
|
||||
|
||||
if len(temp_preParsedMessage) == 2:
|
||||
diceRoll = diceRoll + " + " + temp_preParsedMessage[1] + " = " + str(
|
||||
rollTotal + int(temp_preParsedMessage[1]))
|
||||
else:
|
||||
diceRoll = diceRoll + " = " + str(rollTotal)
|
||||
# If roll is in dx+x format
|
||||
if loopBool == False:
|
||||
roll: int = random.randint(-1, 1) # This is the roller
|
||||
|
||||
if len(temp_preParsedMessage) == 2:
|
||||
diceRoll = str(roll) + " + " + temp_preParsedMessage[1] + " = " + str(
|
||||
roll + int(temp_preParsedMessage[1]))
|
||||
else:
|
||||
diceRoll = str(roll)
|
||||
|
||||
diceRoll = "@" + twitch_message.sender + " fate rolled: " + diceRoll
|
||||
print(diceRoll)
|
||||
|
||||
return diceRoll
|
||||
27
config.py
27
config.py
@ -11,7 +11,7 @@ test_module: bool = False
|
||||
autoJoin_TwitchChannels = ["thecuriousnerd"]
|
||||
whitelisted_TwitchPowerUsers = ["thecuriousnerd"]
|
||||
|
||||
|
||||
#Twitch Module Configs
|
||||
block_TwitchChannelsMessaging = [""] # Blocks the ability to send messages to twitch channels
|
||||
blockAll_TwitchChatChannelsMessaging = False # Blocks the ability to send messages to twitch channels
|
||||
|
||||
@ -23,7 +23,9 @@ forceAll_TwitchChatChannelsTTS = False # forceAll supersedes the blockAll bool a
|
||||
|
||||
blockAll_TTS_URL_Twitch = True
|
||||
|
||||
autoEnabled_Twitch_rgbLightControl = False
|
||||
|
||||
#Discord Module Configs
|
||||
block_DiscordChannelsMessaging = [""] # Blocks the ability to send messages to Discord channels
|
||||
blockAll_DiscordChannelsMessaging = False # Blocks the ability to send messages to Discord channels
|
||||
blockAll_DiscordPrivateMessaging = False # Private Messaging not yet implemented
|
||||
@ -37,18 +39,17 @@ forceAll_DiscordChatChannelsTTS = False # forceAll supersedes the blockAll bool
|
||||
|
||||
blockAll_TTS_URL_Discord = True
|
||||
|
||||
autoEnabled_Discord_rgbLightControl = False
|
||||
|
||||
#Chyron Module Configs
|
||||
chyronListSpaceCount = 25
|
||||
|
||||
#General Configs
|
||||
skip_splashScreen = False
|
||||
skip_splashScreenClear = False
|
||||
skip_splashScreenSleep = False
|
||||
|
||||
|
||||
class Speaker(Enum):
|
||||
GOOGLE_TEXT_TO_SPEECH = 1
|
||||
STREAMLABS_API = 2
|
||||
|
||||
currentSpeaker = Speaker.GOOGLE_TEXT_TO_SPEECH
|
||||
|
||||
botList = ("Nightbot", "StreamElements", "Moobot", "Praxis Bot", "praxis_bot", "MEE6 +", "Nerdy", "Rythm", "Groovy")
|
||||
|
||||
class FileNameStrategy(Enum):
|
||||
TIME_BASED = 1
|
||||
@ -64,6 +65,13 @@ class DBStrategy(Enum):
|
||||
dbStrategy = DBStrategy.SQLite
|
||||
|
||||
|
||||
#TTS Configs
|
||||
class Speaker(Enum):
|
||||
GOOGLE_TEXT_TO_SPEECH = 1
|
||||
STREAMLABS_API = 2
|
||||
|
||||
currentSpeaker = Speaker.GOOGLE_TEXT_TO_SPEECH
|
||||
|
||||
class PollyVoices(Enum):
|
||||
Aditi = "Aditi"
|
||||
Amy = "Amy"
|
||||
@ -129,8 +137,7 @@ class PollyVoices(Enum):
|
||||
PollyVoice = PollyVoices.Justin
|
||||
|
||||
|
||||
botList = ("Nightbot", "StreamElements", "Moobot", "Praxis Bot", "praxis_bot", "MEE6 +", "Nerdy", "Rythm", "Groovy")
|
||||
|
||||
#Misc Configs
|
||||
slurList = badwords.slurList
|
||||
|
||||
praxisVersion_Alpha = "A.0 "
|
||||
|
||||
200
lights_module.py
Normal file
200
lights_module.py
Normal file
@ -0,0 +1,200 @@
|
||||
from time import sleep
|
||||
import phue
|
||||
from phue import Bridge
|
||||
|
||||
import random
|
||||
import utilities_script as utilities
|
||||
|
||||
import credentials
|
||||
import config
|
||||
|
||||
class Lights_Module():
|
||||
def __init__(self):
|
||||
super().__init__()
|
||||
self.bridge_:Bridge = Bridge('192.168.191.146')
|
||||
|
||||
def main(self):
|
||||
print("Starting up Lights_Modules....")
|
||||
self.bridge_.connect()
|
||||
|
||||
self.bridge_.get_api()
|
||||
|
||||
light_list = self.bridge_.lights
|
||||
group_list:list = []
|
||||
groups = self.bridge_.get_group()
|
||||
groupCount = 0
|
||||
|
||||
print("\n -Listing Lights...")
|
||||
for l in light_list:
|
||||
pass
|
||||
#print(l.name)
|
||||
print("\n -Counting Groups...")
|
||||
for g in groups:
|
||||
#print(g)
|
||||
groupCount = int(g)
|
||||
|
||||
|
||||
for gc in range(groupCount):
|
||||
try:
|
||||
#print("group n:" + str(gc))
|
||||
group = self.bridge_.get_group(gc ,'name')
|
||||
#print(group)
|
||||
group_list.append(group)
|
||||
#print(" --done adding")
|
||||
except:
|
||||
pass
|
||||
#print(" --adding failed")
|
||||
|
||||
#self.bridge_.set_group(18, "bri", 254) #This is max Brightness
|
||||
#self.bridge_.set_group(18, "on", True) #This is will turn ON
|
||||
#xy_result = self.rgb_to_xy(0,0,1) #This will take an rgb value and make it xy
|
||||
#self.bridge_.set_group(16, "xy", xy_result) #This will make the lights in the group turn blue
|
||||
|
||||
# The Following will make a rave
|
||||
#for rave in range(10):
|
||||
#rgb_r = random.random()
|
||||
#rgb_g = random.random()
|
||||
#rgb_b = random.random()
|
||||
#xy_result = self.rgb_to_xy(rgb_r, rgb_g, rgb_b) #This will take an rgb value and make it xy
|
||||
#self.bridge_.set_group(16, "xy", xy_result)
|
||||
#sleep(0.1)
|
||||
|
||||
#for stuffz in self.bridge_.scenes:
|
||||
#print(stuffz)
|
||||
|
||||
# This will set the group Downstairs to the Stream scene
|
||||
#self.bridge_.run_scene("Downstairs", "Stream")
|
||||
|
||||
print("\n Setup Complete")
|
||||
|
||||
def setLight():
|
||||
pass
|
||||
|
||||
def setLights():
|
||||
pass
|
||||
|
||||
def setGroup():
|
||||
pass
|
||||
|
||||
def setGroups():
|
||||
pass
|
||||
|
||||
def raveMode(self):
|
||||
for rave in range(30):
|
||||
rgb_r = random.random()
|
||||
rgb_g = random.random()
|
||||
rgb_b = random.random()
|
||||
xy_result = self.rgb_to_xy(rgb_r, rgb_g, rgb_b) #This will take an rgb value and make it xy
|
||||
self.bridge_.set_group(16, "xy", xy_result)
|
||||
sleep(0.3)
|
||||
self.bridge_.run_scene("Downstairs", "Stream")
|
||||
|
||||
def rgb_to_xy(self, red, green, blue):
|
||||
""" conversion of RGB colors to CIE1931 XY colors
|
||||
Formulas implemented from: https://gist.github.com/popcorn245/30afa0f98eea1c2fd34d
|
||||
Args:
|
||||
red (float): a number between 0.0 and 1.0 representing red in the RGB space
|
||||
green (float): a number between 0.0 and 1.0 representing green in the RGB space
|
||||
blue (float): a number between 0.0 and 1.0 representing blue in the RGB space
|
||||
Returns:
|
||||
xy (list): x and y
|
||||
"""
|
||||
# gamma correction
|
||||
red = pow((red + 0.055) / (1.0 + 0.055), 2.4) if red > 0.04045 else (red / 12.92)
|
||||
green = pow((green + 0.055) / (1.0 + 0.055), 2.4) if green > 0.04045 else (green / 12.92)
|
||||
blue = pow((blue + 0.055) / (1.0 + 0.055), 2.4) if blue > 0.04045 else (blue / 12.92)
|
||||
|
||||
# convert rgb to xyz
|
||||
x = red * 0.649926 + green * 0.103455 + blue * 0.197109
|
||||
y = red * 0.234327 + green * 0.743075 + blue * 0.022598
|
||||
z = green * 0.053077 + blue * 1.035763
|
||||
|
||||
# convert xyz to xy
|
||||
x = x / (x + y + z)
|
||||
y = y / (x + y + z)
|
||||
|
||||
# TODO check color gamut if known
|
||||
return [x, y]
|
||||
|
||||
def color_string_parser(self, message):
|
||||
maxDigits = 4
|
||||
print("trying to find color")
|
||||
xy_color = [0, 0]
|
||||
for text in message:
|
||||
#print("testing word")
|
||||
if "red" in text.lower():
|
||||
xy_color = self.rgb_to_xy(1,0,0)
|
||||
print("found: red")
|
||||
if "blue" in text.lower():
|
||||
print("found: blue")
|
||||
xy_color = self.rgb_to_xy(0,0,1)
|
||||
if "green" in text.lower():
|
||||
print("found: green")
|
||||
xy_color = self.rgb_to_xy(0,1,0)
|
||||
|
||||
if "yellow" in text.lower():
|
||||
print("found: yellow")
|
||||
xy_color = self.rgb_to_xy(
|
||||
0.7,
|
||||
0.64,
|
||||
0)
|
||||
|
||||
|
||||
if "cyan" in text.lower():
|
||||
print("found: cyan")
|
||||
xy_color = self.rgb_to_xy(0,1,1)
|
||||
if "aquamarine" in text.lower():
|
||||
print("found: aquamarine")
|
||||
xy_color = self.rgb_to_xy(
|
||||
round(utilities.rescale_value(111,0,254),maxDigits),
|
||||
round(utilities.rescale_value(218,0,254),maxDigits),
|
||||
round(utilities.rescale_value(146,0,254),maxDigits))
|
||||
if "turquoise" in text.lower():
|
||||
print("found: turquoise")
|
||||
xy_color = self.rgb_to_xy(
|
||||
round(utilities.rescale_value(172,0,254),maxDigits),
|
||||
round(utilities.rescale_value(233,0,254),maxDigits),
|
||||
round(utilities.rescale_value(232,0,254),maxDigits))
|
||||
|
||||
if "orange" in text.lower():
|
||||
print("found: orange")
|
||||
xy_color = self.rgb_to_xy(
|
||||
1,
|
||||
round(utilities.rescale_value(126,0,254),maxDigits),
|
||||
0)
|
||||
|
||||
|
||||
if "magenta" in text.lower():
|
||||
print("found: magenta")
|
||||
xy_color = self.rgb_to_xy(
|
||||
1,
|
||||
0,
|
||||
1)
|
||||
|
||||
if "purple" in text.lower():
|
||||
print("found: purple")
|
||||
xy_color = self.rgb_to_xy(
|
||||
round(utilities.rescale_value(159,0,254),maxDigits),
|
||||
round(utilities.rescale_value(32,0,254),maxDigits),
|
||||
round(utilities.rescale_value(239,0,254),maxDigits))
|
||||
|
||||
if "violet" in text.lower():
|
||||
print("found: violet")
|
||||
xy_color = self.rgb_to_xy(
|
||||
round(utilities.rescale_value(237,0,254),maxDigits),
|
||||
round(utilities.rescale_value(129,0,254),maxDigits),
|
||||
round(utilities.rescale_value(237,0,254),maxDigits))
|
||||
|
||||
return xy_color
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
testModule = Lights_Module()
|
||||
|
||||
credentials_manager = credentials.Credentials_Module()
|
||||
credentials_manager.load_credentials()
|
||||
#testModule.dbCredential = credentials_manager.find_DB_Credential(config.credentialsNickname)
|
||||
#testModule.discordCredential = credentials_manager.find_Discord_Credential(config.credentialsNickname)
|
||||
|
||||
testModule.main()
|
||||
testModule.raveMode()
|
||||
@ -8,4 +8,5 @@ gTTS
|
||||
playsound
|
||||
discord.py
|
||||
psutil
|
||||
art
|
||||
art
|
||||
phue
|
||||
@ -39,6 +39,8 @@ class Twitch_Module():
|
||||
self.cooldownModule:Cooldown_Module = Cooldown_Module()
|
||||
self.cooldownModule.setupCooldown("twitchChat", 20, 32)
|
||||
|
||||
self.allow_rgbLightControl = config.autoEnabled_Twitch_rgbLightControl
|
||||
|
||||
def join_channel(self, credential: credentials.Twitch_Credential, channel_name:str):
|
||||
channel_name = "#" + channel_name
|
||||
print("Connecting to Channel: " + channel_name + "...")
|
||||
|
||||
96
user_module.py
Normal file
96
user_module.py
Normal file
@ -0,0 +1,96 @@
|
||||
import config as config
|
||||
import db
|
||||
import tts
|
||||
|
||||
import credentials
|
||||
|
||||
import commands.loader as command_loader
|
||||
from commands.command_base import AbstractCommand
|
||||
|
||||
from cooldowns import Cooldown_Module
|
||||
|
||||
class User_Module():
|
||||
def __init__(self):
|
||||
super().__init__()
|
||||
self.dbCredential: credentials.DB_Credential
|
||||
self.commands = command_loader.load_commands_new(AbstractCommand.CommandType.Praxis)
|
||||
self.MessageLog:list = []
|
||||
|
||||
def main(self):
|
||||
print("\nWaiting on User input...")
|
||||
inputLoop = True
|
||||
while inputLoop:
|
||||
keyboardInput = input()
|
||||
message = UserMessage()
|
||||
message.makeMessage(message=keyboardInput)
|
||||
|
||||
if "exit" in keyboardInput:
|
||||
print("Quitting User Module Interface...")
|
||||
inputLoop = False
|
||||
break
|
||||
|
||||
self.parseInput(message)
|
||||
|
||||
def parseInput(self, message):
|
||||
if self.isCommand(message) == True:
|
||||
self.runCommand(message)
|
||||
else:
|
||||
pass
|
||||
|
||||
def isCommand(self, message):
|
||||
isCommand = True
|
||||
#MAKE THIS
|
||||
return isCommand
|
||||
|
||||
def runCommand(self, message):
|
||||
self.eval_commands(message)
|
||||
|
||||
def eval_commands(self, message):
|
||||
# containsURL: bool = self.contains_url(message)
|
||||
try:
|
||||
#first_space_idx = message.text.index(' ')
|
||||
|
||||
# This fixes a error where if you send a command without arguments it fails because
|
||||
# it cant find the substring.
|
||||
if message.message.find(" ") != -1:
|
||||
first_space_idx = message.message.index(' ')
|
||||
else:
|
||||
first_space_idx = -1
|
||||
|
||||
command_text = ' '
|
||||
if first_space_idx > -1:
|
||||
command_text = message.message[0:first_space_idx]
|
||||
else:
|
||||
command_text = message.message
|
||||
|
||||
command = self.commands[command_text]
|
||||
if command is not None and command.command_type is AbstractCommand.CommandType.Praxis:
|
||||
command.do_command(self, message)
|
||||
except Exception as e:
|
||||
# Undo the following for debug stuff
|
||||
#print(e)
|
||||
pass # we don't care
|
||||
|
||||
def return_message(self, returnedMessage):
|
||||
print(returnedMessage)
|
||||
|
||||
def tts(self, message):
|
||||
tts.tts(message)
|
||||
|
||||
class UserMessage():
|
||||
def __init__(self):
|
||||
super().__init__()
|
||||
self.user = "User"
|
||||
self.message = ""
|
||||
|
||||
def makeMessage(self, user = "User", message = ""):
|
||||
self.user = user
|
||||
self.message = message
|
||||
|
||||
if __name__ == "__main__":
|
||||
testModule = User_Module()
|
||||
|
||||
credentials_manager = credentials.Credentials_Module()
|
||||
credentials_manager.load_credentials()
|
||||
testModule.dbCredential = credentials_manager.find_DB_Credential(config.credentialsNickname)
|
||||
testModule.main()
|
||||
@ -13,14 +13,34 @@ clearScreen = lambda: os.system('cls' if os.name == 'nt' else 'clear')
|
||||
|
||||
urlMatcher = re.compile("(https?:(/{1,3}|[a-z0-9%])|[a-z0-9.-]+[.](com|net|org|edu|gov|mil|aero|asia|biz|cat|coop|info|int|jobs|mobi|museum|name|post|pro|tel|travel|xxx|ac|ad|ae|af|ag|ai|al|am|an|ao|aq|ar|as|at|au|aw|ax|az|ba|bb|bd|be|bf|bg|bh|bi|bj|bm|bn|bo|br|bs|bt|bv|bw|by|bz|ca|cc|cd|cf|cg|ch|ci|ck|cl|cm|cn|co|cr|cs|cu|cv|cx|cy|cz|dd|de|dj|dk|dm|do|dz|ec|ee|eg|eh|er|es|et|eu|fi|fj|fk|fm|fo|fr|ga|gb|gd|ge|gf|gg|gh|gi|gl|gm|gn|gp|gq|gr|gs|gt|gu|gw|gy|hk|hm|hn|hr|ht|hu|id|ie|il|im|in|io|iq|ir|is|it|je|jm|jo|jp|ke|kg|kh|ki|km|kn|kp|kr|kw|ky|kz|la|lb|lc|li|lk|lr|ls|lt|lu|lv|ly|ma|mc|md|me|mg|mh|mk|ml|mm|mn|mo|mp|mq|mr|ms|mt|mu|mv|mw|mx|my|mz|na|nc|ne|nf|ng|ni|nl|no|np|nr|nu|nz|om|pa|pe|pf|pg|ph|pk|pl|pm|pn|pr|ps|pt|pw|py|qa|re|ro|rs|ru|rw|sa|sb|sc|sd|se|sg|sh|si|sj|Ja|sk|sl|sm|sn|so|sr|ss|st|su|sv|sx|sy|sz|tc|td|tf|tg|th|tj|tk|tl|tm|tn|to|tp|tr|tt|tv|tw|tz|ua|ug|uk|us|uy|uz|va|vc|ve|vg|vi|vn|vu|wf|ws|ye|yt|yu|za|zm|zw))")
|
||||
|
||||
def contains_url(self, input: str):
|
||||
def contains_url(input: str):
|
||||
containsURL = re.search(urlMatcher, input.lower()) is not None
|
||||
return containsURL
|
||||
|
||||
def get_args(text: str) -> list:
|
||||
return text.split(" ")
|
||||
|
||||
def contains_slur(self, input: str):
|
||||
def does_contain_OnlyNumbers(text):
|
||||
isJustNumbers = False
|
||||
print("checking numbers")
|
||||
try:
|
||||
for x in range(10):
|
||||
if str(x) in str(text):
|
||||
isJustNumbers = True
|
||||
else:
|
||||
isJustNumbers = False
|
||||
except:
|
||||
pass
|
||||
|
||||
return isJustNumbers
|
||||
|
||||
def rescale_value(value, min, max):
|
||||
print("trying Rescale")
|
||||
returnValue = (value - min) / (max - min)
|
||||
print("got ", returnValue)
|
||||
return returnValue
|
||||
|
||||
def contains_slur(input: str):
|
||||
containsSlur: bool = False
|
||||
parsedMessage = input.split(" ")
|
||||
for word in parsedMessage:
|
||||
|
||||
Loading…
Reference in New Issue
Block a user