]> git.mxchange.org Git - quix0rs-gnu-social.git/commitdiff
Merge branch 'master' into devel
authorEvan Prodromou <git@evanprodromou.name>
Tue, 6 Jan 2009 22:09:39 +0000 (17:09 -0500)
committerEvan Prodromou <git@evanprodromou.name>
Tue, 6 Jan 2009 22:09:39 +0000 (17:09 -0500)
Conflicts:

classes/CommandInterpreter.php
lib/twitter.php
lib/util.php

1  2 
classes/CommandInterpreter.php

index f409ed07f02ad27e87eb3b1bc4afad0fedf4fb29,eae315cb6b9215af2963d198ff69ebaa8608ad18..0679f5462dd4c0b03f7cfdb5b0ddc57a105ffeec
@@@ -21,177 -21,176 +21,178 @@@ if (!defined('LACONICA')) { exit(1); 
  
  require_once(INSTALLDIR.'/classes/Command.php');
  
 -class CommandInterpreter {
 -      
 -      function handle_command($user, $text) {
 -              # XXX: localise
 +class CommandInterpreter
 +{
-     
 -              $text = preg_replace('/\s+/', ' ', trim($text));
 -              list($cmd, $arg) = explode(' ', $text, 2);
 +    function handle_command($user, $text)
 +    {
 +        # XXX: localise
  
 -              # We try to support all the same commands as Twitter, see
 -              # http://getsatisfaction.com/twitter/topics/what_are_the_twitter_commands
 -              # There are a few compatibility commands from earlier versions of 
 -              # Laconica
 -              
 -              switch(strtolower($cmd)) {
 -               case 'help':
 -                      if ($arg) {
 -                              return NULL;
 -                      }
 -                      return new HelpCommand($user);
 -               case 'on':
 -                      if ($arg) {
 -                              list($other, $extra) = explode(' ', $arg, 2);
 -                              if ($extra) {
 -                                      return NULL;
 -                              } else {
 -                                      return new OnCommand($user, $other);
 -                              }
 -                      } else {
 -                              return new OnCommand($user);
 -                      }
 -               case 'off':
 -                      if ($arg) {
 -                              list($other, $extra) = explode(' ', $arg, 2);
 -                              if ($extra) {
 -                                      return NULL;
 -                              } else {
 -                                      return new OffCommand($user, $other);
 -                              }
 -                      } else {
 -                              return new OffCommand($user);
 -                      }
 -               case 'stop':
 -               case 'quit':
 -                      if ($arg) {
 -                              return NULL;
 -                      } else {
 -                              return new OffCommand($user);
 -                      }
 -               case 'follow':
 -               case 'sub':
 -                      if (!$arg) {
 -                              return NULL;
 -                      }
 -                      list($other, $extra) = explode(' ', $arg, 2);
 -                      if ($extra) {
 -                              return NULL;
 -                      } else {
 -                              return new SubCommand($user, $other);
 -                      }
 -               case 'leave':
 -               case 'unsub':
 -                      if (!$arg) {
 -                              return NULL;
 -                      }
 -                      list($other, $extra) = explode(' ', $arg, 2);
 -                      if ($extra) {
 -                              return NULL;
 -                      } else {
 -                              return new UnsubCommand($user, $other);
 -                      }
 -               case 'get':
 -               case 'last':
 -                      if (!$arg) {
 -                              return NULL;
 -                      }
 -                      list($other, $extra) = explode(' ', $arg, 2);
 -                      if ($extra) {
 -                              return NULL;
 -                      } else {
 -                              return new GetCommand($user, $other);
 -                      }
 -               case 'd':
 -               case 'dm':
 -                      if (!$arg) {
 -                              return NULL;
 -                      }
 -                      list($other, $extra) = explode(' ', $arg, 2);
 -                      if (!$extra) {
 -                              return NULL;
 -                      } else {
 -                              return new MessageCommand($user, $other, $extra);
 -                      }
 -               case 'whois':
 -                      if (!$arg) {
 -                              return NULL;
 -                      }
 -                      list($other, $extra) = explode(' ', $arg, 2);
 -                      if ($extra) {
 -                              return NULL;
 -                      } else {
 -                              return new WhoisCommand($user, $other);
 -                      }
 -               case 'fav':
 -                      if (!$arg) {
 -                              return NULL;
 -                      }
 -                      list($other, $extra) = explode(' ', $arg, 2);
 -                      if ($extra) {
 -                              return NULL;
 -                      } else {
 -                              return new FavCommand($user, $other);
 -                      }
 -               case 'nudge':
 -                      if (!$arg) {
 -                              return NULL;
 -                      }
 -                      list($other, $extra) = explode(' ', $arg, 2);
 -                      if ($extra) {
 -                              return NULL;
 -                      } else {
 -                              return new NudgeCommand($user, $other);
 -                      }
 -               case 'stats':
 -                      if ($arg) {
 -                              return NULL;
 -                      }
 -                      return new StatsCommand($user);
 -               case 'invite':
 -                      if (!$arg) {
 -                              return NULL;
 -                      }
 -                      list($other, $extra) = explode(' ', $arg, 2);
 -                      if ($extra) {
 -                              return NULL;
 -                      } else {
 -                              return new InviteCommand($user, $other);
 -                      }
 -               case 'track':
 -                      if (!$arg) {
 -                              return NULL;
 -                      }
 -                      list($word, $extra) = explode(' ', $arg, 2);
 -                      if ($extra) {
 -                              return NULL;
 -                      } else if ($word == 'off') {
 -                              return new TrackOffCommand($user);
 -                      } else {
 -                              return new TrackCommand($user, $word);
 -                      }
 -               case 'untrack':
 -                      if (!$arg) {
 -                              return NULL;
 -                      }
 -                      list($word, $extra) = explode(' ', $arg, 2);
 -                      if ($extra) {
 -                              return NULL;
 -                      } else if ($word == 'all') {
 -                              return new TrackOffCommand($user);
 -                      } else {
 -                              return new UntrackCommand($user, $word);
 -                      }
 -               case 'tracks':
 -               case 'tracking':
 -                      if ($arg) {
 -                              return NULL;
 -                      }
 -                      return new TrackingCommand($user);
 -               default:
 -                      return false;
 -              }
 -      }
 +        $text = preg_replace('/\s+/', ' ', trim($text));
 +        list($cmd, $arg) = explode(' ', $text, 2);
 +
 +        # We try to support all the same commands as Twitter, see
 +        # http://getsatisfaction.com/twitter/topics/what_are_the_twitter_commands
-         # There are a few compatibility commands from earlier versions of 
++        # There are a few compatibility commands from earlier versions of
 +        # Laconica
-         
++
 +        switch(strtolower($cmd)) {
 +         case 'help':
 +            if ($arg) {
 +                return null;
 +            }
 +            return new HelpCommand($user);
 +         case 'on':
 +            if ($arg) {
 +                list($other, $extra) = explode(' ', $arg, 2);
 +                if ($extra) {
 +                    return null;
 +                } else {
 +                    return new OnCommand($user, $other);
 +                }
 +            } else {
 +                return new OnCommand($user);
 +            }
 +         case 'off':
 +            if ($arg) {
 +                list($other, $extra) = explode(' ', $arg, 2);
 +                if ($extra) {
 +                    return null;
 +                } else {
 +                    return new OffCommand($user, $other);
 +                }
 +            } else {
 +                return new OffCommand($user);
 +            }
 +         case 'stop':
 +         case 'quit':
 +            if ($arg) {
 +                return null;
 +            } else {
 +                return new OffCommand($user);
 +            }
 +         case 'follow':
 +         case 'sub':
 +            if (!$arg) {
 +                return null;
 +            }
 +            list($other, $extra) = explode(' ', $arg, 2);
 +            if ($extra) {
 +                return null;
 +            } else {
 +                return new SubCommand($user, $other);
 +            }
 +         case 'leave':
 +         case 'unsub':
 +            if (!$arg) {
 +                return null;
 +            }
 +            list($other, $extra) = explode(' ', $arg, 2);
 +            if ($extra) {
 +                return null;
 +            } else {
 +                return new UnsubCommand($user, $other);
 +            }
 +         case 'get':
 +         case 'last':
 +            if (!$arg) {
 +                return null;
 +            }
 +            list($other, $extra) = explode(' ', $arg, 2);
 +            if ($extra) {
 +                return null;
 +            } else {
 +                return new GetCommand($user, $other);
 +            }
 +         case 'd':
++         case 'dm':
 +            if (!$arg) {
 +                return null;
 +            }
 +            list($other, $extra) = explode(' ', $arg, 2);
 +            if (!$extra) {
 +                return null;
 +            } else {
 +                return new MessageCommand($user, $other, $extra);
 +            }
 +         case 'whois':
 +            if (!$arg) {
 +                return null;
 +            }
 +            list($other, $extra) = explode(' ', $arg, 2);
 +            if ($extra) {
 +                return null;
 +            } else {
 +                return new WhoisCommand($user, $other);
 +            }
 +         case 'fav':
 +            if (!$arg) {
 +                return null;
 +            }
 +            list($other, $extra) = explode(' ', $arg, 2);
 +            if ($extra) {
 +                return null;
 +            } else {
 +                return new FavCommand($user, $other);
 +            }
 +         case 'nudge':
 +            if (!$arg) {
 +                return null;
 +            }
 +            list($other, $extra) = explode(' ', $arg, 2);
 +            if ($extra) {
 +                return null;
 +            } else {
 +                return new NudgeCommand($user, $other);
 +            }
 +         case 'stats':
 +            if ($arg) {
 +                return null;
 +            }
 +            return new StatsCommand($user);
 +         case 'invite':
 +            if (!$arg) {
 +                return null;
 +            }
 +            list($other, $extra) = explode(' ', $arg, 2);
 +            if ($extra) {
 +                return null;
 +            } else {
 +                return new InviteCommand($user, $other);
 +            }
 +         case 'track':
 +            if (!$arg) {
 +                return null;
 +            }
 +            list($word, $extra) = explode(' ', $arg, 2);
 +            if ($extra) {
 +                return null;
 +            } else if ($word == 'off') {
 +                return new TrackOffCommand($user);
 +            } else {
 +                return new TrackCommand($user, $word);
 +            }
 +         case 'untrack':
 +            if (!$arg) {
 +                return null;
 +            }
 +            list($word, $extra) = explode(' ', $arg, 2);
 +            if ($extra) {
 +                return null;
 +            } else if ($word == 'all') {
 +                return new TrackOffCommand($user);
 +            } else {
 +                return new UntrackCommand($user, $word);
 +            }
 +         case 'tracks':
 +         case 'tracking':
 +            if ($arg) {
 +                return null;
 +            }
 +            return new TrackingCommand($user);
 +         default:
 +            return false;
 +        }
 +    }
  }