mirror of
https://github.com/oddluck/limnoria-plugins.git
synced 2025-05-03 08:51:16 -05:00
Jeopardy: minor cleanup, fixes.
This commit is contained in:
parent
7d6a37a043
commit
d18f906b2f
@ -195,8 +195,6 @@ class Jeopardy(callbacks.Plugin):
|
|||||||
data.extend(requests.get("(0}/api/clues?&category={1}&offset=400".format(jserviceUrl, category), timeout=5).json())
|
data.extend(requests.get("(0}/api/clues?&category={1}&offset=400".format(jserviceUrl, category), timeout=5).json())
|
||||||
if cluecount > 500:
|
if cluecount > 500:
|
||||||
data.extend(requests.get("{0}/api/clues?&category={1}&offset=500".format(jserviceUrl, category), timeout=5).json())
|
data.extend(requests.get("{0}/api/clues?&category={1}&offset=500".format(jserviceUrl, category), timeout=5).json())
|
||||||
if self.registryValue('randomize', channel):
|
|
||||||
random.shuffle(data)
|
|
||||||
j = 0
|
j = 0
|
||||||
for item in data:
|
for item in data:
|
||||||
if n > self.num or k > len(self.categories):
|
if n > self.num or k > len(self.categories):
|
||||||
@ -229,7 +227,7 @@ class Jeopardy(callbacks.Plugin):
|
|||||||
except Exception:
|
except Exception:
|
||||||
continue
|
continue
|
||||||
del data
|
del data
|
||||||
if self.shuffled or self.registryValue('randomize', channel) and self.questionfile != 'jservice.io':
|
if self.shuffled or self.registryValue('randomize', channel):
|
||||||
random.shuffle(self.questions)
|
random.shuffle(self.questions)
|
||||||
else:
|
else:
|
||||||
self.questions = self.questions[::-1]
|
self.questions = self.questions[::-1]
|
||||||
@ -239,7 +237,7 @@ class Jeopardy(callbacks.Plugin):
|
|||||||
def newquestion(self, channel):
|
def newquestion(self, channel):
|
||||||
inactiveShutoff = self.registryValue('inactiveShutoff', channel)
|
inactiveShutoff = self.registryValue('inactiveShutoff', channel)
|
||||||
if self.num == 0:
|
if self.num == 0:
|
||||||
self.stop(channel)
|
stopped[channel] = True
|
||||||
elif self.unanswered > inactiveShutoff and inactiveShutoff > 0:
|
elif self.unanswered > inactiveShutoff and inactiveShutoff > 0:
|
||||||
self.reply(channel, 'Seems like no one\'s playing any more.')
|
self.reply(channel, 'Seems like no one\'s playing any more.')
|
||||||
stopped[channel] = True
|
stopped[channel] = True
|
||||||
@ -393,8 +391,8 @@ class Jeopardy(callbacks.Plugin):
|
|||||||
channel = msg.args[0]
|
channel = msg.args[0]
|
||||||
correct = False
|
correct = False
|
||||||
for ans in self.a:
|
for ans in self.a:
|
||||||
ans = re.sub('\s+', ' ', ans.strip().lower())
|
ans = " ".join(ans.strip()).lower()
|
||||||
guess = re.sub('\s+', ' ', msg.args[1].strip().lower())
|
guess = " ".join(msg.args[1]).strip().lower()
|
||||||
if guess == ans:
|
if guess == ans:
|
||||||
correct = True
|
correct = True
|
||||||
elif not correct and len (ans) > 2:
|
elif not correct and len (ans) > 2:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user