Closed abc0707 closed 9 years ago
are you using 0.11?
Hello MBoretto, I tried composer install require... then I got that problem then I tried composer updatte .... problem solved :)
Thanks
yeah... seem like 0.1.1 has problem (composer install), when i tried 0.0.7 (clone from git), it works just fine. I still receive: PHP Fatal error: Call to a member function isEnabled() on a non-object in after using 0.1.1
Issue is not related to nginx and still persists in 0.12
confirmed... I tried with apache, still have this problem On Aug 8, 2015 11:10 PM, "Doranku" notifications@github.com wrote:
Issue is not related to nginx and still persists in 0.12
— Reply to this email directly or view it on GitHub https://github.com/akalongman/php-telegram-bot/issues/19#issuecomment-128993790 .
The problem there is a non object in the getCommandsLists ('leftchatparticipant' => false)
To prevent this from having a working bot, the symptom can be avoided with following patch.
--- a/src/Commands/HelpCommand.php
+++ b/src/Commands/HelpCommand.php
@@ -37,6 +37,10 @@ class HelpCommand extends Command
$msg = 'GeoBot v. ' . $this->telegram->getVersion() . "\n\n";
$msg .= 'Commands List:' . "\n";
foreach ($commands as $command) {
+ if(!is_object($command))
+ {
+ continue;
+ }
if (!$command->isEnabled()) {
continue;
}
Or by removing src/Commands/LeftChatParticipantCommand.php. But the real solve is having the getCommandsList method in Telegram check whether the getCommandClass returned a Command object.
I've pull a commit that fix the help command. Just wait the merge or get the code from my repository. On 8 Aug 2015 20:45, "Doranku" notifications@github.com wrote:
The problem there is a non object in the getCommandsLists ('leftchatparticipant' => false)
To prevent this from having a working bot, the symptom can be avoided with following patch.
--- a/src/Commands/HelpCommand.php +++ b/src/Commands/HelpCommand.php @@ -37,6 +37,10 @@ class HelpCommand extends Command $msg = 'GeoBot v. ' . $this->telegram->getVersion() . "\n\n"; $msg .= 'Commands List:' . "\n"; foreach ($commands as $command) {
- if(!is_object($command))
- {
- continue;
- } if (!$command->isEnabled()) { continue; }
Or by removing src/Commands/LeftChatParticipantCommand.php. But the real solve is having the getCommandsList method in Telegram check whether the getCommandClass returned a Command object.
— Reply to this email directly or view it on GitHub https://github.com/akalongman/php-telegram-bot/issues/19#issuecomment-129033798 .
That is a "lazy way" patch :) I meant fix the source of the problem:
--- a/src/Telegram.php
+++ b/src/Telegram.php
@@ -193,6 +193,10 @@ class Telegram
if (substr($name, -11, 11) === 'Command.php') {
$name = strtolower(str_replace('Command.php', '', $name));
$commands[$name] = $this->getCommandClass($name);
+ if(!($commands[$name] instanceof \Longman\TelegramBot\Command))
+ {
+ unset($commands[$name]);
+ }
}
}
@@ -209,7 +213,11 @@ class Telegram
$name = $fileInfo->getFilename();
if (substr($name, -11, 11) === 'Command.php') {
$name = strtolower(str_replace('Command.php', '', $name));
$commands[$name] = $this->getCommandClass($name);
+ if(!($commands[$name] instanceof \Longman\TelegramBot\Command))
+ {
+ unset($commands[$name]);
+ }
}
}
}
Commits has been merged
Hello, after install and setup properly I got this error:
FastCGI sent in stderr: "PHP message: PHP Fatal error: Call to a member function isEnabled() on a non-object in /var/www/vendor/longman/telegram-bot/src/Commands/HelpCommand.php
could you please help me this that?