Skip to content

Commit

Permalink
Fix in start commnad
Browse files Browse the repository at this point in the history
  • Loading branch information
kozi committed Oct 24, 2016
1 parent 840f781 commit 11cbe66
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 4 deletions.
4 changes: 4 additions & 0 deletions contao/languages/de/default.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@
$GLOBALS['TL_LANG']['simpletipp']['point_details'] = 'Richtig: %s, Differenz: %s, Tendenz: %s';


// TODO Telegram messages
$GLOBALS['TL_LANG']['simpletipp']['telegram'] = [];





7 changes: 4 additions & 3 deletions src/Simpletipp/Modules/SimpletippTelegram.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,18 +61,19 @@ protected function compile()
$text = ($message !== null) ? strtolower($message->getText()) : null;
$chat_id = ($message !== null) ? $message->getChat()->getId() : null;
$chatMember = ($chat_id !== null) ? MemberModel::findOneBy('telegram_chat_id', $chat_id) : null;

if (is_string($text) && strpos($text, "/start") === 0) {
// Handle start command
$command = new StartCommand($telegram, $this, $message);
$command->handle();
$command = new StartCommand($telegram, $this, $message, $chatMember);
$command->handleCommand();
exit;
}
elseif ($chatMember === null) {
$telegram->sendMessage(['text' => 'Chat not registered.', 'chat_id' => $chat_id]);
exit;
}

// Handle all other commands
switch ($text) {
case "/hilfe":
case "hilfe":
Expand Down
1 change: 1 addition & 0 deletions src/Simpletipp/Telegram/StartCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ protected function handle() {
if($this->chatMember !== null) {
$tmpl = 'Chat already registered for %s (%s).';
$this->sendText(sprintf($tmpl, $this->chatMember->firstname.' '.$this->chatMember->lastname, $this->chatMember->username));
$this->sendText(HelpCommand::helpMessage());
return true;
}

Expand Down
2 changes: 1 addition & 1 deletion src/Simpletipp/Telegram/TelegramCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public function __construct($telegram, $module, $message, $chatMember = null)

$fnPrefix = "TELEGRAM-".preg_replace('/[^a-zA-Z0-9-_.]/', '', $telegram->getAccessToken());

if ($this->chatMember->id !== null) {
if ($this->chatMember !== null && $this->chatMember->id !== null) {
$this->filenameTippStack = TL_ROOT."/system/tmp/".$fnPrefix.$this->chatMember->id.".spc";
}
if ($message !== null) {
Expand Down

0 comments on commit 11cbe66

Please sign in to comment.