Allow filtering chat ids

This commit is contained in:
2022-12-30 00:51:00 +00:00
parent 5d109f8b23
commit f38deaa271
2 changed files with 11 additions and 1 deletions

View File

@@ -17,7 +17,16 @@ class GenericmessageCommand extends SystemCommand
public function execute(): ServerResponse
{
global $allowed_chat_ids;
$message = $this->getMessage();
$chat_id = $message->getChat()->getId();
if(count($allowed_chat_ids) > 0 && !in_array($chat_id, $allowed_chat_ids)) {
return Request::sendMessage([
'chat_id' => $chat_id,
'text' => "Chat ID $chat_id not allowed",
]);
}
$text = $message->getText(true);
if ($message->getMediaGroupId() || empty($text)) {
@@ -33,7 +42,7 @@ class GenericmessageCommand extends SystemCommand
$tail = $matches[3] ?? '';
return Request::sendMessage([
'chat_id' => $message->getChat()->getId(),
'chat_id' => $chat_id,
'reply_to_message_id' => $message->getMessageId(),
'text' => "https://fxtwitter.com/$author/status/$tweetId$tail",
'disable_notification' => true,