Skip to content

Commit

Permalink
uptime error changed
Browse files Browse the repository at this point in the history
removed generating tweet
ctt is fater
nextbreak is the right number
!elf answers right amount of elves
  • Loading branch information
Ridgure committed Jan 16, 2019
1 parent 748404c commit 28e2a8d
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 12 deletions.
51 changes: 40 additions & 11 deletions bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -359,14 +359,14 @@ def subscribeAgeAll():


def uptime():
url = "https://api.twitch.tv/helix/streams?user_id=" + User_ID_riboture #from the config file
url = "https://api.twitch.tv/helix/streams?user_id=" + User_ID_ridgure #from the config file
params = {"Client-ID": "" + ClientID + "", "Authorization": "oauth:" + FollowerToken}
response = requests.get(url, headers=params)
streamData = response.json()
if response.status_code == 429:
print "Too many uptime requests"
if streamData['data'] == []:
print "stream is not live"
message("Twitch has not realized stream is live")
StreamStart = streamData['data'][0]

m = re.search('T(.+?):', StreamStart['started_at'])
Expand Down Expand Up @@ -473,6 +473,7 @@ def message(msg):

# Get new follower list and format it to compare with unfollowers
followers()

test = []
for i in range(len(followerList)):
test.insert(0, followerList[i]['from_name'].encode('ascii', 'ignore'))
Expand Down Expand Up @@ -855,7 +856,6 @@ def message(msg):
pass
if "!ctt" in text.lower().split()[0] or "!tweet" in text.lower().split()[0]:
try:
message("Generating tweet")
subscriber = False
for i1 in range(len(subscriberLines)):
if username.lower().rstrip() == subscriberLines[i1][0].lower().rstrip() and int(
Expand All @@ -875,10 +875,39 @@ def message(msg):
if int(followerLines[i1][2]) == 1:
follower = True
tweet = "My bat " + followerLines[i1][3] + " and I are watching @Ridgure doing " + channelInfo()['status'].encode('ascii', 'ignore') + " come join us at Twitch.tv/Ridgure #ModdedMinecraft #SevTech"
if follower == False:
tweet = "I am watching @Ridgure doing " + channelInfo()['status'].encode('ascii','ignore') + " come join me at Twitch.tv/Ridgure #Asylumcraft #ModdedMinecraft #SevTech"
if follower == False:
tweet = "I am watching @Ridgure doing " + channelInfo()['status'].encode('ascii','ignore') + " come join me at Twitch.tv/Ridgure #Asylumcraft #ModdedMinecraft #SevTech"
message("/w " + username + " " + tweet)
message(username + " has been whispered a suggested tweet. You are welcome to write your own tweet as well")
message(username + " has been whispered a suggested tweet. You are welcome to write your own tweet as well. If you would like your suggested tweet in chat do !cttchat")
except IndexError:
pass
except Exception, e:
print str(e)
pass
if "!cttchat" in text.lower().split()[0] or "!tweet" in text.lower().split()[0]:
try:
subscriber = False
for i1 in range(len(subscriberLines)):
if username.lower().rstrip() == subscriberLines[i1][0].lower().rstrip() and int(
subscriberLines[i1][1]) > 0:
if not subscriberLines[i1][0] == "Username":
subscriber = True
if int(subscriberLines[i1][6]) == 1:
tweet = "My elf " + subscriberLines[i1][8] + " and I are watching @Ridgure doing " + channelInfo()['status'].encode('ascii', 'ignore') + " come join us at Twitch.tv/Ridgure #ModdedMinecraft #SevTech"
if int(subscriberLines[i1][6]) > 1:
maxElf = (int(subscriberLines[i1][6]) * 2) + 7
tweet = "My elves " + ", ".join(subscriberLines[i1][8:maxElf:2]) + " and I are watching @Ridgure doing " + channelInfo()['status'].encode('ascii', 'ignore') + " come join us at Twitch.tv/Ridgure #ModdedMinecraft #SevTech"
if subscriber == False:
follower = False
for i1 in range(len(followerLines)):
if not followerLines[i1][0] == "Username":
if username.lower().rstrip() == followerLines[i1][0].lower().rstrip():
if int(followerLines[i1][2]) == 1:
follower = True
tweet = "My bat " + followerLines[i1][3] + " and I are watching @Ridgure doing " + channelInfo()['status'].encode('ascii', 'ignore') + " come join us at Twitch.tv/Ridgure #ModdedMinecraft #SevTech"
if follower == False:
tweet = "I am watching @Ridgure doing " + channelInfo()['status'].encode('ascii','ignore') + " come join me at Twitch.tv/Ridgure #Asylumcraft #ModdedMinecraft #SevTech"
message(tweet)
except IndexError:
pass
except Exception, e:
Expand All @@ -892,13 +921,13 @@ def message(msg):
if "!nextbreak" in text.lower().split()[0]:
try:
if uptime().hour % 2 == 0:
message("Next break is in 1 hour and " + str(60 - uptime().minute) + " minutes")
message("Next break is in 1 hour and " + str(50 - uptime().minute) + " minutes")
pass
else:
if uptime().minute >= 50:
message("Breaktime should be right now. If there is no break being taken something is severely wrong")
else:
message("Next break is in " + str(60 - uptime().minute) + " minutes")
message("Next break is in " + str(50 - uptime().minute) + " minutes")
except IndexError:
pass
if "!social" in text.lower().split()[0]:
Expand Down Expand Up @@ -1040,7 +1069,7 @@ def message(msg):
if int(elfInfo[6]) > 2:
maxElf = (int(elfInfo[6]) * 2) + 6
elves = elfInfo[8:maxElf:2]
message("Your bat morphed into 6 elves. Their names are " + ", ".join(elves) + " and " +
message("Your bat morphed into " + elfInfo[6] + " elves. Their names are " + ", ".join(elves) + " and " +
elfInfo[maxElf] + " " + elfInfo[7])
except IndexError, e:
print str(e)
Expand Down Expand Up @@ -1274,7 +1303,7 @@ def message(msg):
if (len(text.lower().split()[2].encode("ascii"))) <= 15:
for i1 in range(len(subscriberLines)):
if subscriberLines[i1][0].rstrip().lower() == username.rstrip().lower():
for i2 in [8, 10, 12, 14, 16, 18]:
for i2 in range(len(subscriberLines[i1][0:]))[8::2]:
if text.lower().split()[1] == subscriberLines[i1][i2].lower():
csvfile = open('subscriberData.csv', "rb")
subscriberDataReader = csv.reader(csvfile, delimiter=",")
Expand Down Expand Up @@ -1338,7 +1367,7 @@ def message(msg):
owner = False
for i1 in range(len(subscriberLines)):
if subscriberLines[i1][0].rstrip().lower() == username.rstrip().lower():
for i2 in [8, 10, 12, 14, 16, 18]:
for i2 in range(len(subscriberLines[i1][0:]))[9::2]:
if text.lower().split()[1] == subscriberLines[i1][i2].lower():
genderIndex = (int(i2) + 1)
if text.split()[
Expand Down
2 changes: 1 addition & 1 deletion names.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
"Fenris", "Filvendor", "Fingolfin", "Finrod", "Folduin", "Gael", "Gaemon", "Gil-galad", "Glynkas",
"Haemir", "Hagduin", "Haladavar", "Halafarin", "Haryk", "Hastos", "Hatharal", "Herbalar", "Horith",
"Hubyr", "Iarmenor", "Iefyr", "Ievos", "Ilbryn", "Iliven", "Ilthuryn", "Inarie", "Inchel", "Inialos",
"Injros", "Intevar", "Iolas", "assin", "Jhaan", "Jhaartael", "Jhaeros", "Kelkalyn", "Kevan", "Klaern",
"Injros", "Intevar", "Iolas", "Jassin", "Jhaan", "Jhaartael", "Jhaeros", "Kelkalyn", "Kevan", "Klaern",
"Kolvar", "Kuornos", "Kuskyn", "Kymil", "Kyrenic", "Kyrtaar", "lrune", "Maiele", "Mithrandir",
"Molonym", "Molostroi", "Montagor", "Morgan", "Morthil", "Myrddin", "Myriil", "Myrin", "Mythanthar",
"Naertho", "Naeryndam", "Napraeleon", "Narbeth", "Nardual", "Nelaeryn", "Neldor", "Nerilamin",
Expand Down

0 comments on commit 28e2a8d

Please sign in to comment.