Skip to content

Commit ce3cceb

Browse files
authored
Merge pull request #1722 from mtalaeii/no_forward_action
Add NoForward servie message
2 parents 08d0822 + c407e36 commit ce3cceb

3 files changed

Lines changed: 100 additions & 0 deletions

File tree

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
<?php declare(strict_types=1);
2+
3+
/**
4+
* This file is part of MadelineProto.
5+
* MadelineProto is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
6+
* MadelineProto is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
7+
* See the GNU Affero General Public License for more details.
8+
* You should have received a copy of the GNU General Public License along with MadelineProto.
9+
* If not, see <http://www.gnu.org/licenses/>.
10+
*
11+
* @author Mahdi <mahdi.talaee1379@gmail.com>
12+
* @copyright 2016-2025 Mahdi <mahdi.talaee1379@gmail.com>
13+
* @license https://opensource.org/licenses/AGPL-3.0 AGPLv3
14+
* @link https://docs.madelineproto.xyz MadelineProto documentation
15+
*/
16+
17+
namespace danog\MadelineProto\EventHandler\Message\Service;
18+
19+
use danog\MadelineProto\EventHandler\Message\ServiceMessage;
20+
use danog\MadelineProto\MTProto;
21+
22+
/**
23+
* Emitted only in private chats if the other side requested to disable content protection ».
24+
*/
25+
class DialogNoForwardRequest extends ServiceMessage
26+
{
27+
public function __construct(
28+
MTProto $API,
29+
array $rawMessage,
30+
array $info,
31+
32+
/** @var bool If set, this request was accepted or rejected by the other user and thus cannot be used anymore. */
33+
public readonly bool $expired,
34+
35+
/** @var bool Previous protection status. */
36+
public readonly bool $prev,
37+
38+
/** @var bool New requested protection status. */
39+
public readonly bool $new
40+
) {
41+
parent::__construct($API, $rawMessage, $info);
42+
}
43+
}
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
<?php declare(strict_types=1);
2+
3+
/**
4+
* This file is part of MadelineProto.
5+
* MadelineProto is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
6+
* MadelineProto is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
7+
* See the GNU Affero General Public License for more details.
8+
* You should have received a copy of the GNU General Public License along with MadelineProto.
9+
* If not, see <http://www.gnu.org/licenses/>.
10+
*
11+
* @author Mahdi <mahdi.talaee1379@gmail.com>
12+
* @copyright 2016-2025 Mahdi <mahdi.talaee1379@gmail.com>
13+
* @license https://opensource.org/licenses/AGPL-3.0 AGPLv3
14+
* @link https://docs.madelineproto.xyz MadelineProto documentation
15+
*/
16+
17+
namespace danog\MadelineProto\EventHandler\Message\Service;
18+
19+
use danog\MadelineProto\EventHandler\Message\ServiceMessage;
20+
use danog\MadelineProto\MTProto;
21+
22+
/**
23+
* Emitted only in private chats when enabling or disabling content protection ».
24+
*/
25+
class DialogNoForwardToggle extends ServiceMessage
26+
{
27+
public function __construct(
28+
MTProto $API,
29+
array $rawMessage,
30+
array $info,
31+
32+
/** @var bool Previous protection status (if true, the chat was protected). May be equal to new_value when replying to requests */
33+
public readonly bool $prev,
34+
35+
/** @var bool New protection status. */
36+
public readonly bool $new
37+
) {
38+
parent::__construct($API, $rawMessage, $info);
39+
}
40+
}

src/MTProtoTools/UpdateHandler.php

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,8 @@
7575
use danog\MadelineProto\EventHandler\Message\Service\DialogMemberLeft;
7676
use danog\MadelineProto\EventHandler\Message\Service\DialogMembersJoined;
7777
use danog\MadelineProto\EventHandler\Message\Service\DialogMessagePinned;
78+
use danog\MadelineProto\EventHandler\Message\Service\DialogNoForwardRequest;
79+
use danog\MadelineProto\EventHandler\Message\Service\DialogNoForwardToggle;
7880
use danog\MadelineProto\EventHandler\Message\Service\DialogPaymentSent;
7981
use danog\MadelineProto\EventHandler\Message\Service\DialogPaymentSentMe;
8082
use danog\MadelineProto\EventHandler\Message\Service\DialogPeerRequested;
@@ -809,6 +811,21 @@ public function wrapMessage(array $message, bool $scheduled = false): ?AbstractM
809811
new Wallpaper($this, $message['action']['wallpaper']),
810812
true
811813
),
814+
'messageActionNoForwardsRequest' => new DialogNoForwardRequest(
815+
$this,
816+
$message,
817+
$info,
818+
$message['action']['expired'],
819+
$message['action']['prev_value'],
820+
$message['action']['new_value'],
821+
),
822+
'messageActionNoForwardsToggle' => new DialogNoForwardToggle(
823+
$this,
824+
$message,
825+
$info,
826+
$message['action']['prev_value'],
827+
$message['action']['new_value'],
828+
),
812829
default => null
813830
};
814831
}

0 commit comments

Comments
 (0)