Skip to content

Commit

Permalink
Merge pull request #21 from MBoretto/master
Browse files Browse the repository at this point in the history
Help Command and new chat participant work
  • Loading branch information
akalongman committed Aug 11, 2015
2 parents 5924a7f + 4eef4d4 commit fc2a8ca
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 43 deletions.
17 changes: 10 additions & 7 deletions src/Commands/HelpCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,18 +33,21 @@ public function execute()
$text = $message->getText(true);

$commands = $this->telegram->getCommandsList();

if (empty($text)) {
$msg = 'GeoBot v. ' . $this->telegram->getVersion() . "\n\n";
$msg .= 'Commands List:' . "\n";
foreach ($commands as $command) {
if (!$command->isEnabled()) {
continue;
}
if (!$command->isPublic()) {
continue;
}
if (is_object($command)) {
if (!$command->isEnabled()) {
continue;
}
if (!$command->isPublic()) {
continue;
}

$msg .= '/' . $command->getName() . ' - ' . $command->getDescription() . "\n";
$msg .= '/' . $command->getName() . ' - ' . $command->getDescription() . "\n";
}
}

$msg .= "\n" . 'For exact command help type: /help <command>';
Expand Down
28 changes: 14 additions & 14 deletions src/Commands/KeyboardCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,38 +47,38 @@ public function execute()
$keyboards = array();

//0
$keyboard[0] = array('7','8','9');
$keyboard[1] = array('4','5','6');
$keyboard[2] = array('1','2','3');
$keyboard[3] = array(' ','0',' ');
$keyboard[] = ['7','8','9'];
$keyboard[] = ['4','5','6'];
$keyboard[] = ['1','2','3'];
$keyboard[] = [' ','0',' '];

$keyboards[] = $keyboard;
unset($keyboard);

//1
$keyboard[0] = array('7','8','9','+');
$keyboard[1] = array('4','5','6','-');
$keyboard[2] = array('1','2','3','*');
$keyboard[3] = array(' ','0',' ','/');
$keyboard[] = ['7','8','9','+'];
$keyboard[] = ['4','5','6','-'];
$keyboard[] = ['1','2','3','*'];
$keyboard[] = [' ','0',' ','/'];

$keyboards[] = $keyboard;
unset($keyboard);


//2
$keyboard[0] = array('A');
$keyboard[1] = array('B');
$keyboard[2] = array('C');
$keyboard[] = ['A'];
$keyboard[] = ['B'];
$keyboard[] = ['C'];

$keyboards[] = $keyboard;
unset($keyboard);



//3
$keyboard[0] = array('A');
$keyboard[1] = array('B');
$keyboard[2] = array('C','D');
$keyboard[] = ['A'];
$keyboard[] = ['B'];
$keyboard[] = ['C','D'];

$keyboards[] = $keyboard;
unset($keyboard);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
use Longman\TelegramBot\Command;
use Longman\TelegramBot\Entities\Update;

class LeftChatParticipantCommand extends Command
class LeftchatparticipantCommand extends Command
{
protected $name = 'left_chat_participant';
protected $description = 'Left Chat Participant';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
use Longman\TelegramBot\Command;
use Longman\TelegramBot\Entities\Update;

class NewChatParticipantCommand extends Command
class NewchatparticipantCommand extends Command
{
protected $name = 'new_chat_participant';
protected $description = 'New Chat Participant';
Expand Down
31 changes: 11 additions & 20 deletions src/Telegram.php
Original file line number Diff line number Diff line change
Expand Up @@ -189,8 +189,11 @@ public function getCommandsList()
continue;
}
$name = $fileInfo->getFilename();
$name = strtolower(str_replace('Command.php', '', $name));
$commands[$name] = $this->getCommandClass($name);

if (substr($name, -11, 11) === 'Command.php') {
$name = strtolower(str_replace('Command.php', '', $name));
$commands[$name] = $this->getCommandClass($name);
}
}

if (!empty($this->commands_dir)) {
Expand All @@ -204,12 +207,13 @@ public function getCommandsList()
continue;
}
$name = $fileInfo->getFilename();
$name = strtolower(str_replace('Command.php', '', $name));
$commands[$name] = $this->getCommandClass($name);
if (substr($name, -11, 11) === 'Command.php') {
$name = strtolower(str_replace('Command.php', '', $name));
$commands[$name] = $this->getCommandClass($name);
}
}
}
}

return $commands;
}

Expand Down Expand Up @@ -295,7 +299,6 @@ public function handle()
default:
case 'text':
// do nothing

break;

case 'command':
Expand All @@ -306,42 +309,30 @@ public function handle()

case 'new_chat_participant':
// trigger new participant
$command = 'new_chat_participant';
return $this->executeCommand($command, $update);
return $this->executeCommand('Newchatparticipant', $update);
break;

case 'left_chat_participant':
// trigger left chat participant
$command = 'left_chat_participant';
return $this->executeCommand($command, $update);
return $this->executeCommand('Leftchatparticipant', $update);
break;


case 'new_chat_title':
// trigger new_chat_title


break;


case 'delete_chat_photo':
// trigger delete_chat_photo


break;


case 'group_chat_created':
// trigger group_chat_created


break;




}

}


Expand Down

0 comments on commit fc2a8ca

Please sign in to comment.