mirror of
https://github.com/oddluck/limnoria-plugins.git
synced 2025-05-06 11:33:42 -05:00
Merge pull request #16 from rootcoma/master
fixing bounds on commands, adding underlining to stats
This commit is contained in:
commit
e33eb89fc1
@ -169,39 +169,55 @@
|
||||
$result = $q->fetchAll();
|
||||
foreach($result as $res) {
|
||||
$isItalic = false;
|
||||
$brokenNew = str_split($res['question']);
|
||||
$brokenOld = str_split($res['original']);
|
||||
$splitNew = split('\*', $res['question']);
|
||||
$splitOld = split('\*', $res['original']);
|
||||
|
||||
$differenceString = '';
|
||||
for($i=0;$i<sizeof($brokenNew);$i++) {
|
||||
if(!array_key_exists($i, $brokenOld)||!array_key_exists($i, $brokenNew)) {
|
||||
if($isItalic==false){
|
||||
$isItalic = true;
|
||||
$differenceString .= '<u>';
|
||||
for($y=0;$y<sizeof($splitNew);$y++){
|
||||
if($y>0) {
|
||||
$isItalic = false;
|
||||
$differenceString .= '</u>';
|
||||
$differenceString .= '*';
|
||||
}
|
||||
$brokenNew = str_split($splitNew[$y]);
|
||||
if(!array_key_exists($y, $splitOld)){
|
||||
$splitOld[$y] = '*';
|
||||
}
|
||||
$brokenOld = str_split($splitOld[$y]);
|
||||
for($i=0;$i<sizeof($brokenNew);$i++) {
|
||||
if(!array_key_exists($i, $brokenOld)||!array_key_exists($i, $brokenNew)) {
|
||||
if($isItalic==false){
|
||||
$isItalic = true;
|
||||
$differenceString .= '<u>';
|
||||
}
|
||||
} else if($brokenNew[$i]=='*') {
|
||||
$isItalic = false;
|
||||
$differenceString .= '</u>';
|
||||
} else if($brokenNew[$i]!=$brokenOld[$i]) {
|
||||
if($isItalic==false){
|
||||
$isItalic = true;
|
||||
$differenceString .= '<u>';
|
||||
}
|
||||
} else if($brokenNew[$i]==$brokenOld[$i]&&$isItalic==true) {
|
||||
$isItalic = false;
|
||||
$differenceString .= '</u>';
|
||||
}
|
||||
} else if($brokenNew[$i]!=$brokenOld[$i]) {
|
||||
if($isItalic==false){
|
||||
$isItalic = true;
|
||||
$differenceString .= '<u>';
|
||||
}
|
||||
} else if($brokenNew[$i]==$brokenOld[$i]&&$isItalic==true) {
|
||||
$isItalic = false;
|
||||
$differenceString.=$brokenNew[$i];
|
||||
}
|
||||
}
|
||||
if($isItalic==true) {
|
||||
$differenceString .= '</u>';
|
||||
}
|
||||
$differenceString.=$brokenNew[$i];
|
||||
}
|
||||
if($isItalic==true) {
|
||||
$differenceString .= '</u>';
|
||||
}
|
||||
|
||||
echo '<tr>';
|
||||
echo '<td>' . $res['id'] . '</td>';
|
||||
echo '<td>' . $res['username'] . '</td>';
|
||||
echo '<td>' . $differenceString . '</td>';
|
||||
echo '<td>' . $res['original'] . '</td>';
|
||||
echo '<td>' . $res['question_id'] . '</td>';
|
||||
echo '</tr>';
|
||||
}
|
||||
}
|
||||
echo '<tr>';
|
||||
echo '<td>' . $res['id'] . '</td>';
|
||||
echo '<td>' . $res['username'] . '</td>';
|
||||
echo '<td>' . $differenceString . '</td>';
|
||||
echo '<td>' . $res['original'] . '</td>';
|
||||
echo '<td>' . $res['question_id'] . '</td>';
|
||||
echo '</tr>';
|
||||
}
|
||||
}
|
||||
} else {
|
||||
die($err);
|
||||
}
|
||||
|
14
plugin.py
14
plugin.py
@ -277,6 +277,9 @@ class TriviaTime(callbacks.Plugin):
|
||||
|
||||
Give a user points, last argument is optional amount of days in past to add records
|
||||
"""
|
||||
if points < 1:
|
||||
irc.error("You cannot give less than 1 point.")
|
||||
return
|
||||
day=None
|
||||
month=None
|
||||
year=None
|
||||
@ -486,7 +489,7 @@ class TriviaTime(callbacks.Plugin):
|
||||
"""
|
||||
channel = ircutils.toLower(msg.args[0])
|
||||
if not irc.isChannel(channel):
|
||||
irc.noReply()
|
||||
irc.reply('Sorry, I can start inside of a channel, try joining #trivialand. Or fork TriviaLand on github')
|
||||
return
|
||||
if channel in self.games:
|
||||
if not self.games[channel].active:
|
||||
@ -699,6 +702,9 @@ class TriviaTime(callbacks.Plugin):
|
||||
|
||||
self.removeEvent()
|
||||
sleepTime = self.registryValue('sleepTime',self.channel)
|
||||
if sleepTime < 2:
|
||||
sleepTime = 2
|
||||
log.error('sleepTime was set too low(<2 seconds). setting to 2 seconds')
|
||||
sleepTime = time.time() + sleepTime
|
||||
self.queueEvent(sleepTime, self.nextQuestion)
|
||||
|
||||
@ -738,6 +744,9 @@ class TriviaTime(callbacks.Plugin):
|
||||
# provide next question
|
||||
|
||||
sleepTime = self.registryValue('sleepTime',self.channel)
|
||||
if sleepTime < 2:
|
||||
sleepTime = 2
|
||||
log.error('sleepTime was set too low(<2 seconds). setting to 2 seconds')
|
||||
sleepTime = time.time() + sleepTime
|
||||
self.queueEvent(sleepTime, self.nextQuestion)
|
||||
else:
|
||||
@ -800,6 +809,9 @@ class TriviaTime(callbacks.Plugin):
|
||||
self.hintsCounter += 1
|
||||
self.sendMessage('Hint %s: %s' % (self.hintsCounter, hints), 1, 9)
|
||||
timeout = self.registryValue('timeout', self.channel)
|
||||
if timeout < 2:
|
||||
timout = 2
|
||||
log.error('timeout was set too low(<2 seconds). setting to 2 seconds')
|
||||
timeout += time.time()
|
||||
self.queueEvent(timeout, self.loopEvent)
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user