def check_song_request_file(): sr_settings = jsonifySettings.readSpecificSetting('settings.json', 'autoPlaySR') requests_present = check_requests_for_auto_play() if sr_settings == 1 and requests_present is False: autoPlayStatus['bg'] = 'yellow' elif sr_settings == 1 and requests_present is True: autoPlayStatus['bg'] = 'green' elif sr_settings == 0 and requests_present is True: autoPlayStatus['bg'] = 'red' window.after(1000, check_song_request_file)
def speak(text): maxChars = jsonifySettings.readSpecificSetting('settings.json', 'ttsMaxChars') for line in text: if not line.startswith("!"): txt = text[:int(maxChars)] tts = gTTS(text=txt, lang="en", slow=False) filename = "voice.mp3" tts.save(filename) playsound.playsound(filename) os.remove("voice.mp3") break
def Main(): global now_time, song_in_queue sched = threading.Thread(target=scheduler.scheduler, args=()) sched.start() while True: time.sleep(.25) try: tmp = look_for_request() if jsonifySettings.readSpecificSetting( 'settings.json', 'autoPlaySR') and tmp != song_in_queue: song_in_queue = tmp casePlayRequests() except PermissionError as e: print(e) if space_pressed and ctrl_pressed: print('Pressed!') voiceData = record_audio() respond(voiceData)
def defaultChatMessage(): if jsonifySettings.readSpecificSetting('settings.json', 'chatMessageTimer') != 0: sendMessage(irc," Welcome to the Stream. Type !commands to see chat commands, use one to get my attention.") timer.secondTimerChatMessage(4)
def main(): global soundBlocker try: commands, commandList = listDir(jsonifySettings.readSpecificSetting('settings.json', 'soundFolderLocation')) except Exception as e: print(e) print('Sounds folder not set') t = dt.datetime.now() while True: delta = dt.datetime.now()-t if delta.seconds >= jsonifySettings.readSpecificSetting('settings.json', 'sliderFileIndicatorSoundsCoolDown') and soundBlocker == True: t = dt.datetime.now() soundBlocker = False print(soundBlocker) print(dt.datetime.now()) try: readbuffer = irc.recv(1024).decode() except Exception as e: readbuffer = "" print('bufferEmpty') print(e) for line in readbuffer.split("\r\n"): if line == "": continue # handle if the input is a twitch ping elif "PING" in line and Console(line): msgg = "PONG tmi.twitch.tv\r\n".encode() irc.send(msgg) print(msgg) continue else: user = getUser(line) message = getMessage(line) print(user + " : " + message) if message.lower()[0:4] == '!ftoc': sendMessage(irc, 'ftoc') if message.lower() == '!discord': sendMessage(irc, discord_link) if 'https' in message and '!sr' not in message: speak(user + " sent a link") if message[:3] == '!sr': print('song request recieved') speak(user + ' sent a song request') saveToSongRequests(user, message) if message[0] != "!" and 'http' not in message: if jsonifySettings.readSpecificSetting('settings.json', 'ttsSetting'): try: speak(message) except Exception as e: print(e) messageLower = message.lstrip().lower() print(soundBlocker) print(delta.seconds) if delta.seconds <= jsonifySettings.readSpecificSetting('settings.json', 'sliderFileIndicatorSoundsCoolDown') and soundBlocker == True: sendMessage(irc," Sounds are on cooldown :).") if delta.seconds >= jsonifySettings.readSpecificSetting('settings.json', 'sliderFileIndicatorSoundsCoolDown') and soundBlocker == False: if messageLower[0] == '!' and messageLower == '!commands': print(commandList) sendMessage(irc, str(commandList)) if messageLower[0] == '!' and messageLower != '!commands' and messageLower[0:3] != "!sr": for thing in commands: print(messageLower[1:]) if messageLower[1:] in thing: print('found sound commands...') print('sound setting at message if statement' + str(soundBlocker)) if jsonifySettings.readSpecificSetting('settings.json', 'soundSetting') == 1: try: t = dt.datetime.now() soundBlocker = True sound = soundPath + messageLower[1:]+'.mp3' playsound.playsound(soundPath + messageLower[1:]+'.mp3', block = False) except Exception as e: print(e) break if jsonifySettings.readSpecificSetting('settings.json', 'chatRunning') == 0: print('chatRunning setting is 0') exit()
# read white list users def read_white_list(): try: white_list = pickle.load(open('whiteList.p', 'rb')) return white_list except: print('No white list!') def add_user_to_white_list(user_to_add): wl_users = read_white_list() wl_users.append(user_to_add) pickle.dump(wl_users, open("whiteList.p", "wb")) discord_link = r'https://discord.gg/zar9q45' soundPath = jsonifySettings.readSpecificSetting('settings.json', 'soundFolderLocation') soundBlocker = False SERVER = "irc.twitch.tv" PORT = 6667 PASS = jsonifySettings.readSpecificSetting('settings.json', 'oAuth') BOT = "TwitchBot" CHANNEL = jsonifySettings.readSpecificSetting('settings.json', 'twitchUser') OWNER = jsonifySettings.readSpecificSetting('settings.json', 'twitchUser') irc = socket.socket() irc.connect((SERVER, PORT)) irc.send(( f'PASS {PASS}\n' f'NICK {BOT}\n' f'JOIN #{CHANNEL}\n').encode())
from selenium.webdriver.chrome.options import Options from selenium.common.exceptions import NoSuchElementException import json import re import urllib import urllib.request from time import sleep import songRequests import jsonifySettings import difflib from pynput.keyboard import Key, Listener from pynput.keyboard import Controller, KeyCode import time import timer apiKey = jsonifySettings.readSpecificSetting('settings.json', 'ytApiKey') playRequests = False r = sr.Recognizer() killYoutube = False commands = ['play youtube', 'play requests', 'set botname'] botname = 'baxter' now_time = None yt_video_seconds = None path_to_extension = r'C:\Users\rpski\Desktop\4.10.0_0' chrome_options = Options() chrome_options.add_argument('load-extension=' + path_to_extension) chrome_options.add_argument("chrome://flags/#enable-media-session-service") # chrome_options.add_argument("--headless") driver = webdriver.Chrome(options=chrome_options)
import re import urllib import urllib.request import jsonifySettings import difflib from pynput.keyboard import Key, Listener from pynput.keyboard import Controller, KeyCode import time import scheduler import threading song_in_queue = None ctrl_pressed = False space_pressed = False listen = False apiKey = jsonifySettings.readSpecificSetting('settings.json', 'ytApiKey') playRequests = False r = sr.Recognizer() r.energy_threshold = 1000 killYoutube = False commands = ['play youtube', 'play requests', 'set botname'] botname = 'baxter' now_time = None yt_video_seconds = None song_id = None path_to_extension = r'C:\Users\rpski\Desktop\4.10.0_0' chrome_options = Options() chrome_options.add_argument('load-extension=' + path_to_extension) chrome_options.add_argument("chrome://flags/#enable-media-session-service") # If launched from GUI, baxterRunning will == True