Chyron-Module Command #21
@ -1,4 +1,6 @@
|
||||
import config
|
||||
import utilities_script as utilities
|
||||
import os
|
||||
|
||||
class Chyron_Module():
|
||||
def __init__(self):
|
||||
@ -6,6 +8,36 @@ class Chyron_Module():
|
||||
self.chyron_computedString = ""
|
||||
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):
|
||||
newString = ""
|
||||
for c in self.chyron_items:
|
||||
@ -14,6 +46,7 @@ class Chyron_Module():
|
||||
for x in range(config.chyronListSpaceCount):
|
||||
newString = newString + " "
|
||||
self.chyron_computedString = newString
|
||||
return newString
|
||||
|
||||
def addItem(self, name, title, content):
|
||||
newItem:ChyronItem = ChyronItem()
|
||||
@ -25,6 +58,17 @@ class Chyron_Module():
|
||||
if c.itemName == name:
|
||||
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():
|
||||
def __init__(self):
|
||||
@ -54,31 +98,10 @@ class ChyronItem():
|
||||
|
||||
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.main()
|
||||
testModule.chyron_stringUpdater()
|
||||
|
||||
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)
|
||||
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):
|
||||
containsSlur: bool = False
|
||||
parsedMessage = input.split(" ")
|
||||
|
||||
Loading…
Reference in New Issue
Block a user