Assembla home | Assembla project page
 

Changeset 197

Show
Ignore:
Timestamp:
03/30/08 16:20:43 (8 months ago)
Author:
Slynderdale
Message:

Some various bug fixes, fixed Dice and Eval from returning empty messages to the channel, Fixed a bug in Sed with a temp fix and fixed a bug in Seen that caused it to return the last line the person said even if it was the line where they used seen/heard/search

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/Phergie/Plugin/Dice.php

    r195 r197  
    125125                        $total = 0; 
    126126                        for($d = 0; $d < $dice; $d++) { 
    127                                 $total += mt_rand(1, $sides) + ($operator ? $bonus : ($bonus * -1)); 
     127                                $total += intval(mt_rand(1, $sides) + ($operator ? $bonus : ($bonus * -1))); 
    128128                        } 
    129129                        $output[] = $total; 
     
    145145        $target = $this->event->getNick(); 
    146146 
    147         $this->doPrivmsg($source, $target . ': ' . $this->processDice($message)); 
     147        if ($result =  $this->processDice($message)) { 
     148            $this->doPrivmsg($source, $target . ': ' . $result); 
     149        } 
    148150    } 
    149151 
     
    158160        $target = $this->event->getNick(); 
    159161 
    160         $this->doPrivmsg($source, $target . ': ' . $this->processDice($message)); 
     162        if ($result =  $this->processDice($message)) { 
     163            $this->doPrivmsg($source, $target . ': ' . $result); 
     164        } 
    161165    } 
    162166 
     
    173177        list($ctcp, $message) = explode(' ', $ctcp.' ', 2); 
    174178 
    175         if ($ctcp == 'DICE' || $ctcp == 'ROLL') { 
    176             $this->doCtcpReply($source, $ctcp, $this->processDice($message)); 
     179        if (($ctcp == 'DICE' || $ctcp == 'ROLL') and $result =  $this->processDice($message)) { 
     180            $this->doCtcpReply($source, $ctcp, $result); 
    177181        } 
    178182    } 
  • trunk/Phergie/Plugin/Eval.php

    r194 r197  
    2929                // Check to see if the admin is a hostmask admin only and not an op 
    3030                if ($this->fromAdmin(false)) { 
     31                        $code = trim($code); 
     32            if (empty($code)) { 
     33                return; 
     34            } 
    3135 
    32                         $code = trim($code); 
    3336                        // Check to see if the -r arg is set, if so, run the code as is, else prepend return 
    3437                        if (substr(strtolower($code), 0, 2) == '-r') { 
     
    7881                if ($this->fromAdmin(false)) { 
    7982                        $code = trim($code); 
     83            if (empty($code)) { 
     84                return; 
     85            } 
    8086 
    8187                        $console = false; 
     
    8793 
    8894                        if (!empty($code)) { 
    89                                 $this->doPrivmsg($this->event->getSource(), trim(exec($code, $output))); 
     95                            $exec = exec($code, $output); 
     96                            if (!empty($exec)) { 
     97                                    $this->doPrivmsg($this->event->getSource(), trim($exec)); 
     98                                    unset($exec); 
     99                                } 
    90100                                if (!empty($output)) { 
    91101                                        if ($console) { 
  • trunk/Phergie/Plugin/Sed.php

    r194 r197  
    9090                $regex = '{^(?:([^\s:]+)\s*:?\s+)?%?s(\d*)/(.*?)(?<!\\\)/(.*?)(?:(?<!\\\)/([gimsx]*)(\d*)([gimsx]*))?$}ix'; 
    9191                if (preg_match($regex, $message, $matches)) { 
    92                         list ($match, $user, $line, $pattern, $replacement, $flags1, $limit, $flags2) = $matches; 
     92                        list ($match, $user, $line, $pattern, $replacement, $flags1, $limit, $flags2) = array_pad($matches, 8, NULL); 
     93                        // Temp fix for very similar but invalid Sed statements 
     94                        if (strpos($replacement, '/') !== false and preg_match('{(?<!\\\)/}', $replacement, $m)) { 
     95                            return; 
     96                        } 
    9397                        $replacement = str_replace('\/', '/', $replacement); 
    9498                        $flags  = str_replace('g', '', strtolower($flags1 . $flags2)); 
  • trunk/Phergie/Plugin/Seen.php

    r194 r197  
    7777                OR LOWER(message) LIKE LOWER(:phrase) 
    7878                ORDER BY tstamp DESC 
    79                 LIMIT :limit 
     79                LIMIT 1,:limit 
    8080            '); 
    8181 
     
    8686                AND LOWER(chan) = LOWER(:chan) 
    8787                ORDER BY tstamp DESC 
    88                 LIMIT 1 
     88                LIMIT 1,1 
    8989            '); 
    9090 
     
    9696                AND LOWER(chan) = LOWER(:chan) 
    9797                ORDER BY tstamp DESC 
    98                 LIMIT 1 
     98                LIMIT 1,1 
    9999            '); 
    100100