LizardBot r70 - Code Review

From LizardWiki, FastLizard4's wiki and website
Jump to: navigation, search
Repository:LizardBot
Revision:r69‎ | r70 (on ViewVC)‎ | r74 >
Date:10:22, 20 August 2010
Author:FastLizard4
Status:<code-status-verified> (Comments)
Tags:
Comment:
*Fixes a couple of bugs in the bit.ly system regarding identifying bit.ly URLs as aggregate URLs
*Adds the option to the reminder system that allows bot operators to enable reminders on join in addition to reminders on privmsg
Modified paths:

Diff [purge]

Index: lizardbot.php
@@ -56,7 +56,7 @@
5757 |_____||_______| |________||_| |_| |_| \__\ |____/
5858
5959 PHP-LizardBot: IRC bot developed by FastLizard4 (who else?) and the LizardBot Development Team
60 -Version 7.1.0.0b (major.minor.build.revision) BETA
 60+Version 7.1.1.0b (major.minor.build.revision) BETA
6161 Licensed under the Creative Commons GNU General Public License 2.0 (GPL)
6262 For licensing details, contact me or read this page:
6363 http://creativecommons.org/licenses/GPL/2.0/
@@ -92,7 +92,7 @@
9393 <?php
9494 //Check for updates
9595 echo "{$c_yellow}Checking for updates...\r\n";
96 -$version = "7.1.0.0b";
 96+$version = "7.1.1.0b";
9797 $upfp = @fopen('http://lizardwiki.dyndns.org/w/index.php?title=LizardBot/Latest&action=raw', 'r');
9898 $data = @fgets($upfp);
9999 @fclose($upfp);
@@ -1317,7 +1317,7 @@
13181318 if($d[3] == "{$setTrigger}update" && hasPriv('*')) {
13191319 $cmdcount++;
13201320 echo "Checking for updates...\r\n";
1321 - $version = "7.1.0.0b";
 1321+ $version = "7.1.1.0b";
13221322 $upfp = @fopen('http://lizardwiki.dyndns.org/w/index.php?title=LizardBot/Latest&action=raw', 'r');
13231323 $data = @fgets($upfp);
13241324 @fclose($upfp);
@@ -1742,7 +1742,7 @@
17431743 // CURLOPT_PROTOCOLS => CURLPROTO_HTTP,
17441744 CURLOPT_TIMEOUT => 30 , // 30 seconds is the maximum amount of time we want to wait for this to work
17451745 CURLOPT_RETURNTRANSFER => TRUE , // I would like my data back, kthx
1746 - CURLOPT_USERAGENT => "PHP-LizardBot/7.1.0.0b (compatible; +http://lizardwiki.dyndns.org/wiki/LizardBot)" //Set our useragent
 1746+ CURLOPT_USERAGENT => "PHP-LizardBot/7.1.1.0b (compatible; +http://lizardwiki.dyndns.org/wiki/LizardBot)" //Set our useragent
17471747 ));
17481748 if(!$apiPipeSetoptSuccess) { // Uhoh, it looks like that, for some reason, configuration of the pipe failed.
17491749 $data = "For some reason, curl_setopt_array() configuration failed. Perhaps you're running an obsolete version of PHP-cURL? Or perhaps your version of PHP is outdated?";
@@ -1813,7 +1813,11 @@
18141814 if($apiPipeOut['data']['clicks'][0]['error']) {
18151815 $data = "The API returned an error for your short URL. Here it is: {$apiPipeOut['data']['clicks'][0]['error']}.";
18161816 } else {
1817 - $data = "For the short URL {$apiPipeOut['data']['clicks'][0]['short_url']}, the number of user clicks (for {$setBitlyLogin}'s URL) is {$apiPipeOut['data']['clicks'][0]['user_clicks']} and the number of global clicks is {$apiPipeOut['data']['clicks'][0]['global_clicks']}.";
 1817+ if($apiPipeOut['data']['clicks'][0]['global_clicks'] == $apiPipeOut['data']['clicks'][0]['user_clicks'] && $apiPipeOut['data']['clicks'][0]['user_clicks'] != 0) {
 1818+ $data = "For the short URL {$apiPipeOut['data']['clicks'][0]['short_url']}, which is an \"aggregate\" or \"global\" bit.ly URL, there have been {$apiPipeOut['data']['clicks'][0]['global_clicks']} clicks.";
 1819+ } else {
 1820+ $data = "For the short URL {$apiPipeOut['data']['clicks'][0]['short_url']}, the number of clicks is {$apiPipeOut['data']['clicks'][0]['user_clicks']} and the number of global clicks on the aggregate (global) bit.ly URL is {$apiPipeOut['data']['clicks'][0]['global_clicks']}.";
 1821+ }
18181822 }
18191823 }
18201824 }
@@ -1879,7 +1883,11 @@
18801884 if($apiPipeOut['data']['info'][0]['error']) {
18811885 $data = "The API returned an error for your short URL. Here it is: {$apiPipeOut['data']['info'][0]['error']}.";
18821886 } else {
1883 - $data = "For the short URL {$apiPipeOut['data']['info'][0]['short_url']}, the page title is: \"{$apiPipeOut['data']['info'][0]['title']}\" and the bit.ly URL was created by the bit.ly user \"{$apiPipeOut['data']['info'][0]['created_by']}\".";
 1887+ if($apiPipeOut['data']['info'][0]['created_by'] == "bitly") {
 1888+ $data = "For the short URL {$apiPipeOut['data']['info'][0]['short_url']}, the page title is: \"{$apiPipeOut['data']['info'][0]['title']}\". The bit.ly URL is an aggregate URL.";
 1889+ } else {
 1890+ $data = "For the short URL {$apiPipeOut['data']['info'][0]['short_url']}, the page title is: \"{$apiPipeOut['data']['info'][0]['title']}\" and the bit.ly URL was created by the bit.ly user \"{$apiPipeOut['data']['info'][0]['created_by']}\".";
 1891+ }
18841892 }
18851893 }
18861894 }
@@ -2014,7 +2022,12 @@
20152023 }
20162024 mysqli_free_result($result);
20172025 }
2018 - $data .= "OK, I'll tell them the next time I see them talk in a channel I'm in.";
 2026+ if($setRemindOnJoin) {
 2027+ $orJoin = "or join ";
 2028+ } else {
 2029+ unset($orJoin);
 2030+ }
 2031+ $data .= "OK, I'll tell them the next time I see them talk in {$orJoin}a channel I'm in.";
20192032 }
20202033 unset($result);
20212034 mysqli_close($mysql);
@@ -2023,7 +2036,7 @@
20242037 echo "-!- PRIVMSG $c :" . $e . $data . "\r\n";
20252038 }
20262039 //Code to allow retrieval of reminders, ignoring PMs to the bot
2027 - if($d[1] == "PRIVMSG" && $d[2] != $nick) {
 2040+ if(($d[1] == "PRIVMSG" || ($d[1] == "JOIN" && $setRemindOnJoin)) && $d[2] != $nick) {
20282041 $success = false;
20292042 $t = explode('!', $d[0]);
20302043 $userNick = $t[0];
Index: lizardbot.conf.php
@@ -107,6 +107,8 @@
108108
109109 $setEnableReminders: Whether or not to enable the @remind command. Boolean, TRUE by default. REQUIRES MYSQL
110110 TO BE ENABLED!
 111+ $setRemindOnJoin: If this boolean variable is set to TRUE, the bot will also deliver reminders to people when
 112+ it sees them join a channel the bot is in, not just when they talk in one. FALSE by default.
111113
112114 $setEnableBitly: Set this boolean variable to TRUE if you want to enable support for bit.ly URL shortening and
113115 other functions. WARNING: YOU MUST HAVE THE CURL EXTENSION INSTALLED FOR THIS TO WORK!
@@ -286,6 +288,7 @@
287289 $setEnableAllTriggerHelp = TRUE;
288290
289291 $setEnableReminders = TRUE;
 292+ $setRemindOnJoin = FALSE;
290293
291294 $setEnableBitly = FALSE;
292295 $setBitlyAPISleep = 30;

Comments

#Comment by FastLizard4 (Talk | contribs)   10:24, 20 August 2010

Fixes two bit.ly bugs introduced in r69.

Status & tagging log

  • 10:24, 20 August 2010 FastLizard4 (Talk | contribs) changed the status of r70 [removed: new added: <code-status-verified>]