Merge pull request 'Chyron-Module Command' (#21) from Chyron-Module into master
Reviewed-on: #21
This commit is contained in:
commit
af9623e61d
@ -1,4 +1,6 @@
|
|||||||
import config
|
import config
|
||||||
|
import utilities_script as utilities
|
||||||
|
import os
|
||||||
|
|
||||||
class Chyron_Module():
|
class Chyron_Module():
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
@ -6,6 +8,36 @@ class Chyron_Module():
|
|||||||
self.chyron_computedString = ""
|
self.chyron_computedString = ""
|
||||||
self.chyron_items:list = []
|
self.chyron_items:list = []
|
||||||
|
|
||||||
|
def main(self, rightNow_ = "Chill Stream"):
|
||||||
|
self.addItem(
|
||||||
|
"RightNow",
|
||||||
|
"► Now: ",
|
||||||
|
rightNow_)
|
||||||
|
self.addItem(
|
||||||
|
"WeekDays",
|
||||||
|
"► Weekdays: ",
|
||||||
|
"Daily Stream @ 12pm Noon EST")
|
||||||
|
self.addItem(
|
||||||
|
"FriSat",
|
||||||
|
"► Friday & Saturday: ",
|
||||||
|
"FFxiv (Express Delivery Raid Team) @ 7pm EST")
|
||||||
|
self.addItem(
|
||||||
|
"Commands",
|
||||||
|
"► Commands: ",
|
||||||
|
"!animal, !climateclock, !discord, !lights, !page, !roll")
|
||||||
|
self.addItem(
|
||||||
|
"Website",
|
||||||
|
"► Want to read about my various projects? visit: ",
|
||||||
|
"TheCuriousNerd.com")
|
||||||
|
self.addItem(
|
||||||
|
"Follow",
|
||||||
|
"► ",
|
||||||
|
"If you like what you see, hit that follow button to see more!")
|
||||||
|
self.addItem(
|
||||||
|
"Discord",
|
||||||
|
"► Want to join our discord? type \" !d \" in chat to get the link or visit: ",
|
||||||
|
"discord.io/thecuriousnerd")
|
||||||
|
|
||||||
def chyron_stringUpdater(self):
|
def chyron_stringUpdater(self):
|
||||||
newString = ""
|
newString = ""
|
||||||
for c in self.chyron_items:
|
for c in self.chyron_items:
|
||||||
@ -14,6 +46,7 @@ class Chyron_Module():
|
|||||||
for x in range(config.chyronListSpaceCount):
|
for x in range(config.chyronListSpaceCount):
|
||||||
newString = newString + " "
|
newString = newString + " "
|
||||||
self.chyron_computedString = newString
|
self.chyron_computedString = newString
|
||||||
|
return newString
|
||||||
|
|
||||||
def addItem(self, name, title, content):
|
def addItem(self, name, title, content):
|
||||||
newItem:ChyronItem = ChyronItem()
|
newItem:ChyronItem = ChyronItem()
|
||||||
@ -25,6 +58,17 @@ class Chyron_Module():
|
|||||||
if c.itemName == name:
|
if c.itemName == name:
|
||||||
self.chyron_items.remove(c)
|
self.chyron_items.remove(c)
|
||||||
|
|
||||||
|
def updateChyronFile(self):
|
||||||
|
dir = utilities.get_dir("stream_sources")
|
||||||
|
script_dir = os.path.dirname(__file__) #<-- absolute dir the script is in
|
||||||
|
relative_path = "stream_sources/chyron.txt"
|
||||||
|
real_file_path = os.path.join(script_dir, relative_path)
|
||||||
|
|
||||||
|
file = open(real_file_path, "wb")
|
||||||
|
chyron = self.chyron_stringUpdater().encode("utf8")
|
||||||
|
file.write(chyron)
|
||||||
|
file.close
|
||||||
|
|
||||||
|
|
||||||
class ChyronItem():
|
class ChyronItem():
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
@ -54,31 +98,10 @@ class ChyronItem():
|
|||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
testModule = Chyron_Module()
|
testModule = Chyron_Module()
|
||||||
testModule.addItem(
|
testModule.main()
|
||||||
"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()
|
testModule.chyron_stringUpdater()
|
||||||
|
|
||||||
test = testModule.chyron_computedString + "<<<|"
|
test = testModule.chyron_computedString + "<<<|"
|
||||||
print(test)
|
print(test)
|
||||||
|
|
||||||
|
testModule.updateChyronFile()
|
||||||
35
commands/implemented/command_chyron.py
Normal file
35
commands/implemented/command_chyron.py
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
from abc import ABCMeta
|
||||||
|
import chyron_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 = "chyron"
|
||||||
|
|
||||||
|
def __init__(self):
|
||||||
|
super().__init__(CommandRoll.command, n_args=5, command_type=AbstractCommand.CommandType.Praxis)
|
||||||
|
|
||||||
|
def do_command(self, bot, user_message):
|
||||||
|
tempBool = True
|
||||||
|
if tempBool == True:
|
||||||
|
tempParsedMessage = user_message.message.split(" ")
|
||||||
|
i = len(tempParsedMessage)
|
||||||
|
|
||||||
|
if i > 1:
|
||||||
|
if "update" in tempParsedMessage[1]:
|
||||||
|
chyron = chyron_module.Chyron_Module()
|
||||||
|
if i > 2:
|
||||||
|
chyron.main(tempParsedMessage[2])
|
||||||
|
else:
|
||||||
|
chyron.main()
|
||||||
|
chyron.updateChyronFile()
|
||||||
|
|
||||||
|
returnMessage = "@" + user_message.user + " updated the chyron!"
|
||||||
|
bot.return_message(returnMessage)
|
||||||
@ -40,6 +40,16 @@ def rescale_value(value, min, max):
|
|||||||
print("got ", returnValue)
|
print("got ", returnValue)
|
||||||
return returnValue
|
return returnValue
|
||||||
|
|
||||||
|
def get_dir(selected_dir):
|
||||||
|
"""
|
||||||
|
Checks for the tts directory, and will create it if it does not exist
|
||||||
|
:return: the relative file path of the tts dir
|
||||||
|
"""
|
||||||
|
dir = os.path.join(os.getcwd(), selected_dir) # this is platform-agnostic
|
||||||
|
if not os.path.exists(dir):
|
||||||
|
os.mkdir(dir)
|
||||||
|
return dir
|
||||||
|
|
||||||
def contains_slur(input: str):
|
def contains_slur(input: str):
|
||||||
containsSlur: bool = False
|
containsSlur: bool = False
|
||||||
parsedMessage = input.split(" ")
|
parsedMessage = input.split(" ")
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user