<?php declare(strict_types=1);
-require 'common.php';
-
-use function Common\{
- getTelegram,
- getMessagesFromInbox,
- getInbox,
- splitBill,
- getMessageSender,
- getMessageSenderDisplayName,
- canChatWith
-};
+require_once('common.php');
+
use Telegram\Bot\Actions;
use Telegram\Bot\Commands\Command;
+if(!canChatWith(getTelegram()->getWebhookUpdates())) {
+ getTelegram()->sendMessage([
+ 'chat_id' => getTelegram()->getWebhookUpdates()->get('message')->get('from')->get('id'),
+ 'text' => "Sorry, Dad says I can't talk to you."
+ ]);
+ exit(0);
+}
getTelegram()->addCommand(
new class extends Command {
protected $description = 'List my bills';
public function handle($arguments) {
- if (!canChatWith($this->getUpdate())) {
- $this->replyWithMessage(['text' => "Sorry, Dad says I can't talk to you."]);
- return;
- }
-
$this->replyWithMessage(['text' => 'Fetching ' . getMessageSenderDisplayName($this->getUpdate()) . "'s unpaid bills. Just a sec ..."]);
$this->replyWithChatAction(['action' => Actions::TYPING]);
$this->replyWithMessage([
protected $description = 'Mark a bill as paid';
public function handle($arguments) {
- if (!canChatWith($this->getUpdate())) {
- $this->replyWithMessage(['text' => "Sorry, Dad says I can't talk to you."]);
- return;
- }
-
if (!$arguments) {
$this->replyWithMessage(['text' => "I need the bill id. The /mybills command lists all your bills with the ids in brackets. Here, I'll show you..."]);
$this->triggerCommand('mybills');