def joinedRoom(s): readBuffer = "" loading = True while loading: readBuffer = s.recv(1024).decode("utf-8") if ("End of /NAMES list" in readBuffer): loading = False # send a message in chat to indicate that the bot has successfully joined sendMsg(s, "HeyGuys")
def joinRoom(socket): readbuffer = "" Loading = True while Loading: readbuffer = readbuffer + socket.recv(1024) temp = string.split(readbuffer, "\n") readbuffer = temp.pop() for line in temp: Loading = loadingComplete(line) sendMsg(socket, "BRBot has joined chat")
readbuffer = "" sololastUsed = datetime(2018, 1, 1, 00, 00, 00) duolastUsed = datetime(2018, 1, 1, 00, 00, 00) squadlastUsed = datetime(2018, 1, 1, 00, 00, 00) sock.send("CAP REQ :twitch.tv/tags\r\n") sock.send("CAP REQ :twitch.tv/commands\r\n") peeTimer = datetime.now() dadGreeting = True while Running: readbuffer = readbuffer + sock.recv(1024) temp = string.split(readbuffer, "\n") readbuffer = temp.pop() peeCheck = datetime.now() - (peeTimer + timedelta(seconds=3600)) if peeCheck > timedelta(seconds=0): sendMsg(sock, "@cookeeeemonster it's time for a pee break") peeTimer = datetime.now() for line in temp: if "PING :tmi.twitch.tv" in line: sock.send("PONG :tmi.twitch.tv\r\n") print "Connection Refreshed %s" % datetime.now() elif ":tmi.twitch.tv CAP * ACK :twitch.tv/tags" in line: message = "" elif ":tmi.twitch.tv CAP * ACK :twitch.tv/commands" in line: message = "" else: user = getUser(line) message = getMsg(line) user_level = getUserLevel(line) if message.startswith("!addwin"):
def callWins(socket): solowinsRead = open(soloWins, "r") duolistRead = open(duoList, "r") squadlistRead = open(squadList, "r") soloWins_str = solowinsRead.readline() if soloWins_str.isdigit() == False: soloWins_int = 0 else: soloWins_int = int(soloWins_str) solowinsRead.close() duowinsRead = open(duoWins, "r") duoWins_str = duowinsRead.readline() if duoWins_str.isdigit() == False: duoWins_int = 0 else: duoWins_int = int(duoWins_str) duowinsRead.close() squadwinsRead = open(squadWins, "r") squadWins_str = squadwinsRead.readline() if squadWins_str.isdigit() == False: squadWins_int = 0 else: squadWins_int = int(squadWins_str) squadwinsRead.close() totalWins_int = soloWins_int + duoWins_int + squadWins_int sololistRead = open(soloList, "r") solowinData = [] for count, z in enumerate(sololistRead.readlines()): solowinData.append(z) if count > 14: break sololistRead.close() duowinData = [] for count, z in enumerate(duolistRead.readlines()): duowinData.append(z) if count > 14: break duolistRead.close() squadwinData = [] for count, z in enumerate(squadlistRead.readlines()): squadwinData.append(z) if count > 14: break squadlistRead.close() solowinData = [string.strip("\n") for string in solowinData] solowinData = ', '.join(solowinData) duowinData = [string.strip("\n") for string in duowinData] duowinData = ', '.join(duowinData) squadwinData = [string.strip("\n") for string in squadwinData] squadwinData = ', '.join(squadwinData) if totalWins_int == 0: sendMsg(socket, "No wins today") elif soloWins_int != 0 and duoWins_int == 0 and squadWins_int == 0: sendMsg( socket, "%i Wins (%i Solo: [%s])" % (totalWins_int, soloWins_int, solowinData)) elif soloWins_int == 0 and duoWins_int != 0 and squadWins_int == 0: sendMsg( socket, "%i Wins (%i Duo: [%s])" % (totalWins_int, duoWins_int, duowinData)) elif soloWins_int == 0 and duoWins_int == 0 and squadWins_int != 0: sendMsg( socket, "%i Wins (%i Squad: [%s])" % (totalWins_int, squadWins_int, squadwinData)) elif soloWins_int != 0 and duoWins_int != 0 and squadWins_int == 0: sendMsg( socket, "%i Wins (%i Solo: [%s]; %i Duo: [%s])" % (totalWins_int, soloWins_int, solowinData, duoWins_int, duowinData)) elif soloWins_int != 0 and duoWins_int == 0 and squadWins_int != 0: sendMsg( socket, "%i Wins (%i Solo: [%s]; %i Squad: [%s])" % (totalWins_int, soloWins_int, solowinData, squadWins_int, squadwinData)) elif soloWins_int == 0 and duoWins_int != 0 and squadWins_int != 0: sendMsg( socket, "%i Wins (%i Duo: [%s]; %i Squad: [%s])" % (totalWins_int, duoWins_int, duowinData, squadWins_int, squadwinData)) else: sendMsg( socket, "%i Wins (%i Solo: [%s]; %i Duo: [%s]; %s Squad: [%s])" % (totalWins_int, soloWins_int, solowinData, duoWins_int, duowinData, squadWins_int, squadwinData))
def sendHi(chatArray): for n in range (0, len(chatArray)): chatArray[n] = "" sendMsg(openSocket(), "HeyGuys") return chatArray