Compare commits
33 Commits
fd5f179df3
...
0fe7da334a
| Author | SHA1 | Date | |
|---|---|---|---|
| 0fe7da334a | |||
| ee38f6288a | |||
|
|
932eb56f97 | ||
|
|
79a4977b38 | ||
|
|
0ae1cd880d | ||
|
|
15abdc16f3 | ||
|
|
dadf75364e | ||
|
|
1519e87859 | ||
| c798dc0ee3 | |||
|
|
ecffe6083b | ||
|
|
aea69fb4bf | ||
| aeceb837b9 | |||
|
|
a535aafb1e | ||
| 103b18ac9e | |||
| 8512e9a59b | |||
| 0b697fa58c | |||
|
|
505860fe59 | ||
|
|
84b36622b3 | ||
|
|
5ab2abc242 | ||
|
|
fb9d58a231 | ||
|
|
1b317282c5 | ||
|
|
7f1c991672 | ||
|
|
435ef15211 | ||
|
|
b519a50702 | ||
|
|
8f60e00a6d | ||
|
|
0e4d2455bb | ||
|
|
93c0e182ed | ||
|
|
114b19373e | ||
|
|
e4f185678b | ||
|
|
1c4d5d5b01 | ||
|
|
381882eda9 | ||
|
|
fee939331f | ||
|
|
533d69787f |
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):
|
class CommandType(Enum):
|
||||||
NONE = auto()
|
NONE = auto()
|
||||||
|
Praxis = auto()
|
||||||
TWITCH = auto()
|
TWITCH = auto()
|
||||||
DISCORD = 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...")
|
#await discord_message.channel.send("Rolling Dice...")
|
||||||
print("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("+")
|
temp_preParsedMessage = discord_message.content.split("+")
|
||||||
|
|
||||||
tempParsedMessage = temp_preParsedMessage[0].split(" ")
|
tempParsedMessage = temp_preParsedMessage[0].split(" ")
|
||||||
@ -41,11 +108,12 @@ class CommandRoll(AbstractCommand, metaclass=ABCMeta):
|
|||||||
if int(parsedMessage[0]) == 1:
|
if int(parsedMessage[0]) == 1:
|
||||||
loopBool = False
|
loopBool = False
|
||||||
|
|
||||||
|
if roll_type == 1:
|
||||||
# If roll is in xdx+x format
|
# If roll is in xdx+x format
|
||||||
if loopBool == True:
|
if loopBool == True:
|
||||||
rolls: list = []
|
rolls: list = []
|
||||||
for x in range(int(parsedMessage[0])):
|
for x in range(int(parsedMessage[0])):
|
||||||
rolls.append(random.randint(1, int(parsedMessage[1])))
|
rolls.append(random.randint(1, int(parsedMessage[1]))) # This is the roller
|
||||||
|
|
||||||
rollTotal = 0
|
rollTotal = 0
|
||||||
for roll in rolls:
|
for roll in rolls:
|
||||||
@ -60,7 +128,7 @@ class CommandRoll(AbstractCommand, metaclass=ABCMeta):
|
|||||||
diceRoll = diceRoll + " = " + str(rollTotal)
|
diceRoll = diceRoll + " = " + str(rollTotal)
|
||||||
# If roll is in dx+x format
|
# If roll is in dx+x format
|
||||||
if loopBool == False:
|
if loopBool == False:
|
||||||
roll: int = random.randint(1, int(parsedMessage[1]))
|
roll: int = random.randint(1, int(parsedMessage[1])) # This is the roller
|
||||||
|
|
||||||
if len(temp_preParsedMessage) == 2:
|
if len(temp_preParsedMessage) == 2:
|
||||||
diceRoll = str(roll) + " + " + temp_preParsedMessage[1] + " = " + str(
|
diceRoll = str(roll) + " + " + temp_preParsedMessage[1] + " = " + str(
|
||||||
@ -70,5 +138,38 @@ class CommandRoll(AbstractCommand, metaclass=ABCMeta):
|
|||||||
|
|
||||||
diceRoll = discord_message.author.mention + " rolled: " + diceRoll
|
diceRoll = discord_message.author.mention + " rolled: " + diceRoll
|
||||||
print(diceRoll)
|
print(diceRoll)
|
||||||
await bot.send_message(discord_message, diceRoll)
|
|
||||||
#await discord_message.channel.send(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"]
|
autoJoin_TwitchChannels = ["thecuriousnerd"]
|
||||||
whitelisted_TwitchPowerUsers = ["thecuriousnerd"]
|
whitelisted_TwitchPowerUsers = ["thecuriousnerd"]
|
||||||
|
|
||||||
|
#Twitch Module Configs
|
||||||
block_TwitchChannelsMessaging = [""] # Blocks the ability to send messages to twitch channels
|
block_TwitchChannelsMessaging = [""] # Blocks the ability to send messages to twitch channels
|
||||||
blockAll_TwitchChatChannelsMessaging = False # 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
|
blockAll_TTS_URL_Twitch = True
|
||||||
|
|
||||||
|
autoEnabled_Twitch_rgbLightControl = False
|
||||||
|
|
||||||
|
#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
|
||||||
blockAll_DiscordChannelsMessaging = False # 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
|
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
|
blockAll_TTS_URL_Discord = True
|
||||||
|
|
||||||
|
autoEnabled_Discord_rgbLightControl = False
|
||||||
|
|
||||||
|
#Chyron Module Configs
|
||||||
|
chyronListSpaceCount = 25
|
||||||
|
|
||||||
|
#General Configs
|
||||||
skip_splashScreen = False
|
skip_splashScreen = False
|
||||||
skip_splashScreenClear = False
|
skip_splashScreenClear = False
|
||||||
skip_splashScreenSleep = False
|
skip_splashScreenSleep = False
|
||||||
|
|
||||||
|
botList = ("Nightbot", "StreamElements", "Moobot", "Praxis Bot", "praxis_bot", "MEE6 +", "Nerdy", "Rythm", "Groovy")
|
||||||
class Speaker(Enum):
|
|
||||||
GOOGLE_TEXT_TO_SPEECH = 1
|
|
||||||
STREAMLABS_API = 2
|
|
||||||
|
|
||||||
currentSpeaker = Speaker.GOOGLE_TEXT_TO_SPEECH
|
|
||||||
|
|
||||||
|
|
||||||
class FileNameStrategy(Enum):
|
class FileNameStrategy(Enum):
|
||||||
TIME_BASED = 1
|
TIME_BASED = 1
|
||||||
@ -64,6 +65,13 @@ class DBStrategy(Enum):
|
|||||||
dbStrategy = DBStrategy.SQLite
|
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):
|
class PollyVoices(Enum):
|
||||||
Aditi = "Aditi"
|
Aditi = "Aditi"
|
||||||
Amy = "Amy"
|
Amy = "Amy"
|
||||||
@ -129,8 +137,7 @@ class PollyVoices(Enum):
|
|||||||
PollyVoice = PollyVoices.Justin
|
PollyVoice = PollyVoices.Justin
|
||||||
|
|
||||||
|
|
||||||
botList = ("Nightbot", "StreamElements", "Moobot", "Praxis Bot", "praxis_bot", "MEE6 +", "Nerdy", "Rythm", "Groovy")
|
#Misc Configs
|
||||||
|
|
||||||
slurList = badwords.slurList
|
slurList = badwords.slurList
|
||||||
|
|
||||||
praxisVersion_Alpha = "A.0 "
|
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()
|
||||||
@ -9,3 +9,4 @@ playsound
|
|||||||
discord.py
|
discord.py
|
||||||
psutil
|
psutil
|
||||||
art
|
art
|
||||||
|
phue
|
||||||
@ -39,6 +39,8 @@ class Twitch_Module():
|
|||||||
self.cooldownModule:Cooldown_Module = Cooldown_Module()
|
self.cooldownModule:Cooldown_Module = Cooldown_Module()
|
||||||
self.cooldownModule.setupCooldown("twitchChat", 20, 32)
|
self.cooldownModule.setupCooldown("twitchChat", 20, 32)
|
||||||
|
|
||||||
|
self.allow_rgbLightControl = config.autoEnabled_Twitch_rgbLightControl
|
||||||
|
|
||||||
def join_channel(self, credential: credentials.Twitch_Credential, channel_name:str):
|
def join_channel(self, credential: credentials.Twitch_Credential, channel_name:str):
|
||||||
channel_name = "#" + channel_name
|
channel_name = "#" + channel_name
|
||||||
print("Connecting to Channel: " + 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))")
|
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
|
containsURL = re.search(urlMatcher, input.lower()) is not None
|
||||||
return containsURL
|
return containsURL
|
||||||
|
|
||||||
def get_args(text: str) -> list:
|
def get_args(text: str) -> list:
|
||||||
return text.split(" ")
|
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
|
containsSlur: bool = False
|
||||||
parsedMessage = input.split(" ")
|
parsedMessage = input.split(" ")
|
||||||
for word in parsedMessage:
|
for word in parsedMessage:
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user