Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Some Bounded methods #1395

Merged
merged 27 commits into from
Aug 30, 2023
Merged

Add Some Bounded methods #1395

merged 27 commits into from
Aug 30, 2023

Conversation

ahjdev
Copy link
Contributor

@ahjdev ahjdev commented Aug 29, 2023

No description provided.

use ReflectionProperty;

/**
* The channel participant
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Info about a channel participant

public readonly int $date;

/** Admin [rights](https://core.telegram.org/api/rights) */
public readonly bool $adminRights; //!
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not bool :)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh some drug XD

$this->inviterId = $rawParticipant['inviter_id'] ?? null;
$this->promotedBy = $rawParticipant['promoted_by'];
$this->date = $rawParticipant['date'];
$this->rank = $rawParticipant['rank'] ?? '';
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can use ?? null and make the rank nullable

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or maybe do ?? 'admin', since that's how the GUI clients do it...

* You should have received a copy of the GNU General Public License along with MadelineProto.
* If not, see <http://www.gnu.org/licenses/>.
*
* @author Daniil Gentili <daniil@daniil.it>
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

BTW you can put yourself as author on the files you made :)

public readonly ?int $date;

/** Banned [rights](https://core.telegram.org/api/rights) */
public readonly bool $bannedRights; //!
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not bool :)

public readonly int $userId;

/** Creator admin rights */
public readonly int $adminRights; //!
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not an int :)

) {
$this->userId = $rawParticipant['user_id'];
$this->adminRights = new Rights\Admin($rawParticipant['adminRights']);
$this->rank = $rawParticipant['rank'] ?? '';
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

?? 'admin', probably

array $rawParticipant
) {
$this->left = $rawParticipant['left'];
$this->peer = $API->getId($rawParticipant['peer']);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can use getIdInternal here, it's faster

MTProto $API,
array $rawParticipant
) {
$this->peer = $API->getId($rawParticipant['peer']);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can use getIdInternal here, it's faster

/**
* A participant that left the channel/supergroup
*/
class Left extends Participant
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Btw you should make all classes either final or abstract

public readonly ?int $inviterId;

/** When did I join the channel/supergroup */
public readonly ?int $date;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not nullable

public readonly bool $sendVideos;

/** If set, does not allow a user to send round videos in a [supergroup/chat](https://core.telegram.org/api/channel) */
public readonly bool $send_roundvideos;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sendRoundVideos

@ahjdev ahjdev requested a review from danog August 30, 2023 10:41
Copy link
Owner

@danog danog left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks amazing, thank you so much!
Just a few small tweaks :)

*
* @return boolean
*/
public function disableSignatures(): bool
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we can return void in both

use danog\MadelineProto\EventHandler\Message\ServiceMessage;
use danog\MadelineProto\MTProto;

/** @internal */
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mark only the constructor as @internal, not the class pls

use ReflectionClass;
use ReflectionProperty;

/** @internal */
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need to mark this as internal

/**
* The group call has ended.
*/
final class Called extends AbstractDialogCallGroup
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we name the namespace DialogGroupCall?
Also, can we just name the class GroupCallEnded? I don't like using such non-descriptive names for the class (even if more info is included in the namespace).

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same for the other classes in the DialogGroupCall namespace

/**
* Why call ended
*/
enum PhoneCallDiscardReason
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can use src/VoIP/DiscardReason.php, instead

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah but can I add a fromString method?
Or I should handle it in DialogPhoneCall class

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sure

@ahjdev ahjdev requested a review from danog August 30, 2023 17:32
@danog danog merged commit 2976095 into danog:v8 Aug 30, 2023
@danog
Copy link
Owner

danog commented Aug 30, 2023

Thank you! <3<3<3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants