Merge pull request 'Docker' (#24) from docker into master
Reviewed-on: #24
This commit is contained in:
commit
426b36c9d0
10
Dockerfile
Normal file
10
Dockerfile
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
FROM python:3.8-buster
|
||||||
|
|
||||||
|
WORKDIR /Praxis
|
||||||
|
|
||||||
|
COPY requirements.txt requirements.txt
|
||||||
|
RUN pip3 install -r requirements.txt
|
||||||
|
|
||||||
|
COPY . .
|
||||||
|
|
||||||
|
CMD [ "python3", "main.py"] #Uncomment to start with the Docker Container
|
||||||
12
README.md
12
README.md
@ -2,6 +2,18 @@ A chatbot to help with live stream production and effects.
|
|||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
|
# Docker:
|
||||||
|
|
||||||
|
## Docker Info:
|
||||||
|
|
||||||
|
Currently to build the container run the following command.
|
||||||
|
|
||||||
|
`docker create -p 2501:2501 -e ISDOCKER=cat --name praxis praxis`
|
||||||
|
|
||||||
|
To start the bot with **User_Module** activated use this.
|
||||||
|
|
||||||
|
`docker exec -ti praxis python3 main.py`
|
||||||
|
|
||||||
# Credentials:
|
# Credentials:
|
||||||
|
|
||||||
## Credentials Setup:
|
## Credentials Setup:
|
||||||
|
|||||||
@ -30,8 +30,8 @@ block_DiscordChannelsMessaging = [""] # Blocks the ability to send messages to D
|
|||||||
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
|
||||||
|
|
||||||
selected_DiscordTTSChannels = ["431129571308339210"]
|
|
||||||
autoEnabled_DiscordChannelsTTS = False
|
autoEnabled_DiscordChannelsTTS = False
|
||||||
|
selected_DiscordTTSChannels = ["431129571308339210"]
|
||||||
block_DiscordChannelsTTS = [""] # block supersedes the tts_enabled bool
|
block_DiscordChannelsTTS = [""] # block supersedes the tts_enabled bool
|
||||||
blockAll_DiscordChannelsTTS = False # blockAll supersedes the force bool and force list and tts_enabled bool
|
blockAll_DiscordChannelsTTS = False # blockAll supersedes the force bool and force list and tts_enabled bool
|
||||||
force_DiscordChannelsTTS = [""] # force supersedes the block list
|
force_DiscordChannelsTTS = [""] # force supersedes the block list
|
||||||
|
|||||||
@ -138,7 +138,13 @@ class Discord_Module(discord.Client):
|
|||||||
#print("isBlocked: " + str(isBlocked))
|
#print("isBlocked: " + str(isBlocked))
|
||||||
#print("isForced: " + str(isForced))
|
#print("isForced: " + str(isForced))
|
||||||
if (not await self.contains_slur(message)) and (await self.isTTS_URL_Enabled(message)):
|
if (not await self.contains_slur(message)) and (await self.isTTS_URL_Enabled(message)):
|
||||||
if self.tts_enabled and not isBlocked and not config.blockAll_DiscordChannelsTTS or isForced or config.forceAll_DiscordChatChannelsTTS:
|
print(message.channel.id, message.channel.id, message.channel.id)
|
||||||
|
isMessageChannelInList = False
|
||||||
|
for TTS_C_id in config.selected_DiscordTTSChannels:
|
||||||
|
print(TTS_C_id)
|
||||||
|
if int(TTS_C_id) == int(message.channel.id):
|
||||||
|
isMessageChannelInList = True
|
||||||
|
if self.tts_enabled and (isMessageChannelInList) and not isBlocked and not config.blockAll_DiscordChannelsTTS or isForced or config.forceAll_DiscordChatChannelsTTS:
|
||||||
if not message.content.startswith('!'):
|
if not message.content.startswith('!'):
|
||||||
text_to_say: str = "%s says, %s" % (message.author.display_name, message.content)
|
text_to_say: str = "%s says, %s" % (message.author.display_name, message.content)
|
||||||
channel_text = "%s user msg" % message.channel
|
channel_text = "%s user msg" % message.channel
|
||||||
|
|||||||
16
main.py
16
main.py
@ -36,8 +36,9 @@ def twitch_module_init(dbCert, twitchCert):
|
|||||||
twitchModule_.tts_enabled = config.autoEnabled_TwitchChannelsTTS
|
twitchModule_.tts_enabled = config.autoEnabled_TwitchChannelsTTS
|
||||||
twitchModule_.whitelisted_users = config.whitelisted_TwitchPowerUsers
|
twitchModule_.whitelisted_users = config.whitelisted_TwitchPowerUsers
|
||||||
|
|
||||||
|
print("[TWITCH Module]>", "Loading Channels...")
|
||||||
for twitchChannel in config.autoJoin_TwitchChannels:
|
for twitchChannel in config.autoJoin_TwitchChannels:
|
||||||
print("joining channel function")
|
print("joining twitch channel:", twitchChannel)
|
||||||
twitchModule_.join_channel(None, twitchChannel)
|
twitchModule_.join_channel(None, twitchChannel)
|
||||||
|
|
||||||
def discord_module_init(dbCert, discordCert):
|
def discord_module_init(dbCert, discordCert):
|
||||||
@ -63,6 +64,8 @@ def user_module_init(dbCert, Empty):
|
|||||||
userModule_.main()
|
userModule_.main()
|
||||||
|
|
||||||
def thread_main():
|
def thread_main():
|
||||||
|
if utility.isRunningInDocker() == True:
|
||||||
|
print("<[DOCKER Detected]>")
|
||||||
if not config.skip_splashScreen:
|
if not config.skip_splashScreen:
|
||||||
utility.splashScreen()
|
utility.splashScreen()
|
||||||
global credentials_manager
|
global credentials_manager
|
||||||
@ -100,16 +103,19 @@ def thread_main():
|
|||||||
thread_.start()
|
thread_.start()
|
||||||
|
|
||||||
if config.user_module == True:
|
if config.user_module == True:
|
||||||
thread_ = threading.Thread(target=user_module_init, args=(dbCert, None))
|
if utility.isRunningInDocker() == False:
|
||||||
threads.append(thread_)
|
config.user_module = False
|
||||||
thread_.start()
|
thread_ = threading.Thread(target=user_module_init, args=(dbCert, None))
|
||||||
|
threads.append(thread_)
|
||||||
|
thread_.start()
|
||||||
|
|
||||||
print("---Post Thread Creation Test---")
|
print("---Post Thread Creation Test---")
|
||||||
for t in threads:
|
for t in threads:
|
||||||
t.join()
|
t.join()
|
||||||
|
|
||||||
print("---Point of no return---")
|
print("---Point of no return---")
|
||||||
input()
|
if utility.isRunningInDocker() == False:
|
||||||
|
input()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
7
tts.py
7
tts.py
@ -6,13 +6,18 @@ import requests
|
|||||||
from gtts import gTTS
|
from gtts import gTTS
|
||||||
from playsound import playsound
|
from playsound import playsound
|
||||||
|
|
||||||
|
import utilities_script as utility
|
||||||
import config
|
import config
|
||||||
|
|
||||||
streamLabsUrl = "https://streamlabs.com/polly/speak"
|
streamLabsUrl = "https://streamlabs.com/polly/speak"
|
||||||
|
|
||||||
def tts(inputText: str, *args):
|
def tts(inputText: str, *args):
|
||||||
outpath = create_speech_file(inputText)
|
outpath = create_speech_file(inputText)
|
||||||
playsound(outpath)
|
if utility.isRunningInDocker() == True:
|
||||||
|
print("Docker Detected, skipping playsound()")
|
||||||
|
else:
|
||||||
|
print("Playing Sound...")
|
||||||
|
playsound(outpath)
|
||||||
|
|
||||||
|
|
||||||
def create_speech_gtts(input_text: str):
|
def create_speech_gtts(input_text: str):
|
||||||
|
|||||||
@ -9,6 +9,8 @@ from commands.command_base import AbstractCommand
|
|||||||
|
|
||||||
from cooldowns import Cooldown_Module
|
from cooldowns import Cooldown_Module
|
||||||
|
|
||||||
|
import utilities_script as utility
|
||||||
|
|
||||||
class User_Module():
|
class User_Module():
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
super().__init__()
|
super().__init__()
|
||||||
@ -19,6 +21,9 @@ class User_Module():
|
|||||||
def main(self):
|
def main(self):
|
||||||
print("\nWaiting on User input...\n")
|
print("\nWaiting on User input...\n")
|
||||||
inputLoop = True
|
inputLoop = True
|
||||||
|
if utility.isRunningInDocker() == True:
|
||||||
|
inputLoop = False
|
||||||
|
print("\nNo User's Input Allowed")
|
||||||
while inputLoop:
|
while inputLoop:
|
||||||
keyboardInput = input()
|
keyboardInput = input()
|
||||||
message = UserMessage()
|
message = UserMessage()
|
||||||
|
|||||||
@ -14,11 +14,11 @@ 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(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 does_contain_OnlyNumbers(text):
|
def does_contain_OnlyNumbers(text):
|
||||||
isJustNumbers = False
|
isJustNumbers = False
|
||||||
@ -51,60 +51,66 @@ def get_dir(selected_dir):
|
|||||||
return 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(" ")
|
||||||
for word in parsedMessage:
|
for word in parsedMessage:
|
||||||
for slur in config.slurList:
|
for slur in config.slurList:
|
||||||
if word.lower() == slur:
|
if word.lower() == slur:
|
||||||
containsSlur = True
|
containsSlur = True
|
||||||
break
|
|
||||||
if containsSlur:
|
|
||||||
break
|
break
|
||||||
|
|
||||||
if containsSlur:
|
if containsSlur:
|
||||||
print("<{ slur detected! }> ")
|
break
|
||||||
return containsSlur
|
|
||||||
|
if containsSlur:
|
||||||
|
print("<{ slur detected! }> ")
|
||||||
|
return containsSlur
|
||||||
|
|
||||||
|
def isRunningInDocker():
|
||||||
|
isD = os.getenv('ISDOCKER')
|
||||||
|
if isD is None:
|
||||||
|
return False
|
||||||
|
return isD == "cat"
|
||||||
|
|
||||||
def hard_shutdown():
|
def hard_shutdown():
|
||||||
current_system_pid = os.getpid()
|
current_system_pid = os.getpid()
|
||||||
|
|
||||||
ThisSystem = psutil.Process(current_system_pid)
|
ThisSystem = psutil.Process(current_system_pid)
|
||||||
ThisSystem.terminate()
|
ThisSystem.terminate()
|
||||||
|
|
||||||
def restart_self():
|
def restart_self():
|
||||||
|
|
||||||
#current_system_pid = os.getpid()
|
#current_system_pid = os.getpid()
|
||||||
#os.startfile("python C:/praxis/main.py")
|
#os.startfile("python C:/praxis/main.py")
|
||||||
#subprocess.run("python C:/praxis/main.py")
|
#subprocess.run("python C:/praxis/main.py")
|
||||||
#subprocess.call("python main.py", shell=True)
|
#subprocess.call("python main.py", shell=True)
|
||||||
if platform.system() == 'Windows':
|
if platform.system() == 'Windows':
|
||||||
os.system('start cmd /k python main.py')
|
os.system('start cmd /k python main.py')
|
||||||
hard_shutdown()
|
hard_shutdown()
|
||||||
if platform.system() == 'Linux':
|
if platform.system() == 'Linux':
|
||||||
os.system('xfce4-terminal -e "python main.py"')
|
os.system('xfce4-terminal -e "python main.py"')
|
||||||
hard_shutdown()
|
hard_shutdown()
|
||||||
|
|
||||||
#os.system('python twitch_script.py')
|
#os.system('python twitch_script.py')
|
||||||
#os.system('python discord_script.py')
|
#os.system('python discord_script.py')
|
||||||
|
|
||||||
def restart_target():
|
def restart_target():
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def launch_target(inputScript: str):
|
def launch_target(inputScript: str):
|
||||||
cmd = "start cmd /k python " + inputScript
|
cmd = "start cmd /k python " + inputScript
|
||||||
os.system(cmd)
|
os.system(cmd)
|
||||||
|
|
||||||
def splashScreen():
|
def splashScreen():
|
||||||
if not config.skip_splashScreenClear:
|
if not config.skip_splashScreenClear:
|
||||||
clearScreen()
|
clearScreen()
|
||||||
art.tprint("----------",font="slant")
|
art.tprint("----------",font="slant")
|
||||||
art.tprint("Praxis Bot",font="graffiti")
|
art.tprint("Praxis Bot",font="graffiti")
|
||||||
art.tprint("----------",font="slant")
|
art.tprint("----------",font="slant")
|
||||||
print("-Maintained by Alex Orid, TheCuriousNerd.com\nFor help visit discord.gg/thecuriousnerd")
|
print("-Maintained by Alex Orid, TheCuriousNerd.com\nFor help visit discord.gg/thecuriousnerd")
|
||||||
print("ver: " + config.praxisVersion_Alpha + config.praxisVersion_Delta + config.praxisVersion_Omega)
|
print("ver: " + config.praxisVersion_Alpha + config.praxisVersion_Delta + config.praxisVersion_Omega)
|
||||||
print("\n\n\n")
|
print("\n\n\n")
|
||||||
if not config.skip_splashScreenSleep:
|
if not config.skip_splashScreenSleep:
|
||||||
time.sleep(3)
|
time.sleep(3)
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
splashScreen()
|
splashScreen()
|
||||||
Loading…
Reference in New Issue
Block a user