Skip to content

Commit

Permalink
More helpers on Context
Browse files Browse the repository at this point in the history
  • Loading branch information
HeySreelal committed Aug 30, 2024
1 parent 779e838 commit e2131bb
Showing 1 changed file with 66 additions and 0 deletions.
66 changes: 66 additions & 0 deletions lib/src/televerse/context/context.dart
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,72 @@ class Context {
);
}
}

/// Determine whether the update is a text message
bool hasText() => msg?.text != null;

/// Determine whether the update contains a photo
bool hasPhoto() => msg?.photo != null;

/// Determine whether the update contains a video
bool hasVideo() => msg?.video != null;

/// Determine whether the update contains a document
bool hasDocument() => msg?.document != null;

/// Determine whether the update contains a location
bool hasLocation() => msg?.location != null;

/// Determine whether the update contains a live location
bool hasLiveLocation() => msg?.location?.livePeriod != null;

/// Determine whether the update contains a GIF/Animation
bool hasAnimation() => msg?.animation != null;

/// Determine whether the update is part of media group
bool hasMediaGroup() => msg?.mediaGroupId != null;

/// Determine whether the incoming message has a message effect added to it
bool hasEffect() => msg?.hasEffect == true;

/// Determine whether the update contains a paid media
bool hasPaidMedia() => msg?.paidMedia != null;

/// Determine whether the update contains a contact
bool hasContact() => msg?.contact != null;

/// Determine whether the update is a service message
bool isServiceMessage() {
return msg?.leftChatMember != null ||
msg?.newChatTitle != null ||
msg?.newChatPhoto != null ||
msg?.deleteChatPhoto == true ||
msg?.groupChatCreated == true ||
msg?.supergroupChatCreated == true ||
msg?.channelChatCreated == true ||
msg?.messageAutoDeleteTimerChanged != null ||
msg?.successfulPayment != null ||
msg?.refundedPayment != null ||
msg?.usersShared != null ||
msg?.chatShared != null ||
msg?.writeAccessAllowed != null ||
msg?.proximityAlertTriggered != null ||
msg?.boostAdded != null ||
msg?.chatBackgroundSet != null ||
msg?.forumTopicCreated != null ||
msg?.forumTopicEdited != null ||
msg?.forumTopicClosed != null ||
msg?.forumTopicReopened != null ||
msg?.generalForumTopicHidden != null ||
msg?.generalForumTopicUnhidden != null ||
msg?.giveawayCreated != null ||
msg?.giveawayCompleted != null ||
msg?.videoChatScheduled != null ||
msg?.videoChatStarted != null ||
msg?.videoChatEnded != null ||
msg?.videoChatParticipantsInvited != null ||
msg?.webAppData != null;
}
}

/// Base handler
Expand Down

0 comments on commit e2131bb

Please sign in to comment.