Skip to content

Commit

Permalink
🔥 Context upgrades
Browse files Browse the repository at this point in the history
  • Loading branch information
HeySreelal committed May 31, 2024
1 parent 526494d commit 3d0480c
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 2 deletions.
49 changes: 47 additions & 2 deletions lib/src/televerse/context/context.dart
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,7 @@ class Context {
ReplyParameters? replyParameters,
ReplyMarkup? replyMarkup,
String? businessConnectionId,
String? messageEffectId,
}) async {
_verifyInfo([_chatId], APIMethod.sendMessage);
return api.sendMessage(
Expand All @@ -234,6 +235,7 @@ class Context {
replyParameters: replyParameters,
replyMarkup: replyMarkup,
businessConnectionId: businessConnectionId,
messageEffectId: messageEffectId,
);
}

Expand All @@ -258,6 +260,8 @@ class Context {
ReplyParameters? replyParameters,
ReplyMarkup? replyMarkup,
String? businessConnectionId,
String? messageEffectId,
bool? showCaptionAboveMedia,
}) async {
_verifyInfo([_chatId], APIMethod.sendPhoto);
return api.sendPhoto(
Expand All @@ -272,6 +276,8 @@ class Context {
replyParameters: replyParameters,
replyMarkup: replyMarkup,
businessConnectionId: businessConnectionId,
messageEffectId: messageEffectId,
showCaptionAboveMedia: showCaptionAboveMedia,
);
}

Expand All @@ -294,6 +300,7 @@ class Context {
ReplyParameters? replyParameters,
ReplyMarkup? replyMarkup,
String? businessConnectionId,
String? messageEffectId,
}) async {
_verifyInfo([_chatId], APIMethod.sendAudio);
return api.sendAudio(
Expand All @@ -312,6 +319,7 @@ class Context {
replyParameters: replyParameters,
replyMarkup: replyMarkup,
businessConnectionId: businessConnectionId,
messageEffectId: messageEffectId,
);
}

Expand All @@ -332,6 +340,7 @@ class Context {
ReplyParameters? replyParameters,
ReplyMarkup? replyMarkup,
String? businessConnectionId,
String? messageEffectId,
}) async {
_verifyInfo([_chatId], APIMethod.sendDocument);
return api.sendDocument(
Expand All @@ -348,6 +357,7 @@ class Context {
replyParameters: replyParameters,
replyMarkup: replyMarkup,
businessConnectionId: businessConnectionId,
messageEffectId: messageEffectId,
);
}

Expand All @@ -372,6 +382,8 @@ class Context {
ReplyParameters? replyParameters,
ReplyMarkup? replyMarkup,
String? businessConnectionId,
String? messageEffectId,
bool? showCaptionAboveMedia,
}) async {
_verifyInfo([_chatId], APIMethod.sendVideo);
return api.sendVideo(
Expand All @@ -392,6 +404,8 @@ class Context {
replyParameters: replyParameters,
replyMarkup: replyMarkup,
businessConnectionId: businessConnectionId,
messageEffectId: messageEffectId,
showCaptionAboveMedia: showCaptionAboveMedia,
);
}

Expand All @@ -410,6 +424,7 @@ class Context {
ReplyParameters? replyParameters,
ReplyMarkup? replyMarkup,
String? businessConnectionId,
String? messageEffectId,
}) async {
_verifyInfo([_chatId], APIMethod.sendVideoNote);
return api.sendVideoNote(
Expand All @@ -424,6 +439,7 @@ class Context {
replyParameters: replyParameters,
replyMarkup: replyMarkup,
businessConnectionId: businessConnectionId,
messageEffectId: messageEffectId,
);
}

Expand All @@ -443,6 +459,7 @@ class Context {
ReplyParameters? replyParameters,
ReplyMarkup? replyMarkup,
String? businessConnectionId,
String? messageEffectId,
}) async {
_verifyInfo([_chatId], APIMethod.sendVoice);
return api.sendVoice(
Expand All @@ -458,6 +475,7 @@ class Context {
replyParameters: replyParameters,
replyMarkup: replyMarkup,
businessConnectionId: businessConnectionId,
messageEffectId: messageEffectId,
);
}

Expand All @@ -472,6 +490,7 @@ class Context {
bool? protectContent,
ReplyParameters? replyParameters,
String? businessConnectionId,
String? messageEffectId,
}) async {
_verifyInfo([_chatId], APIMethod.sendMediaGroup);
return api.sendMediaGroup(
Expand All @@ -482,6 +501,7 @@ class Context {
protectContent: protectContent,
replyParameters: replyParameters,
businessConnectionId: businessConnectionId,
messageEffectId: messageEffectId,
);
}

Expand All @@ -501,6 +521,7 @@ class Context {
ReplyParameters? replyParameters,
ReplyMarkup? replyMarkup,
String? businessConnectionId,
String? messageEffectId,
}) async {
_verifyInfo([_chatId], APIMethod.sendLocation);
return api.sendLocation(
Expand All @@ -517,6 +538,7 @@ class Context {
replyParameters: replyParameters,
replyMarkup: replyMarkup,
businessConnectionId: businessConnectionId,
messageEffectId: messageEffectId,
);
}

Expand All @@ -538,6 +560,7 @@ class Context {
ReplyParameters? replyParameters,
ReplyMarkup? replyMarkup,
String? businessConnectionId,
String? messageEffectId,
}) async {
_verifyInfo([_chatId], APIMethod.sendVenue);
return api.sendVenue(
Expand All @@ -556,6 +579,7 @@ class Context {
replyParameters: replyParameters,
replyMarkup: replyMarkup,
businessConnectionId: businessConnectionId,
messageEffectId: messageEffectId,
);
}

Expand All @@ -573,6 +597,7 @@ class Context {
ReplyParameters? replyParameters,
ReplyMarkup? replyMarkup,
String? businessConnectionId,
String? messageEffectId,
}) async {
_verifyInfo([_chatId], APIMethod.sendContact);
return api.sendContact(
Expand All @@ -587,6 +612,7 @@ class Context {
replyParameters: replyParameters,
replyMarkup: replyMarkup,
businessConnectionId: businessConnectionId,
messageEffectId: messageEffectId,
);
}

Expand All @@ -612,6 +638,7 @@ class Context {
ReplyParameters? replyParameters,
ReplyMarkup? replyMarkup,
String? businessConnectionId,
String? messageEffectId,
}) async {
return api.sendPoll(
id,
Expand All @@ -633,6 +660,7 @@ class Context {
replyParameters: replyParameters,
replyMarkup: replyMarkup,
businessConnectionId: businessConnectionId,
messageEffectId: messageEffectId,
);
}

Expand All @@ -647,6 +675,7 @@ class Context {
ReplyParameters? replyParameters,
ReplyMarkup? replyMarkup,
String? businessConnectionId,
String? messageEffectId,
}) async {
_verifyInfo([_chatId], APIMethod.sendDice);
return api.sendDice(
Expand All @@ -658,6 +687,7 @@ class Context {
replyParameters: replyParameters,
replyMarkup: replyMarkup,
businessConnectionId: businessConnectionId,
messageEffectId: messageEffectId,
);
}

Expand Down Expand Up @@ -689,6 +719,7 @@ class Context {
ReplyParameters? replyParameters,
ReplyMarkup? replyMarkup,
String? businessConnectionId,
String? messageEffectId,
}) async {
_verifyInfo([_chatId], APIMethod.sendGame);
return api.sendGame(
Expand All @@ -700,6 +731,7 @@ class Context {
replyParameters: replyParameters,
replyMarkup: replyMarkup,
businessConnectionId: businessConnectionId,
messageEffectId: messageEffectId,
);
}

Expand All @@ -722,6 +754,8 @@ class Context {
ReplyParameters? replyParameters,
ReplyMarkup? replyMarkup,
String? businessConnectionId,
String? messageEffectId,
bool? showCaptionAboveMedia,
}) async {
_verifyInfo([_chatId], APIMethod.sendAnimation);
return api.sendAnimation(
Expand All @@ -741,6 +775,8 @@ class Context {
replyParameters: replyParameters,
replyMarkup: replyMarkup,
businessConnectionId: businessConnectionId,
messageEffectId: messageEffectId,
showCaptionAboveMedia: showCaptionAboveMedia,
);
}

Expand All @@ -755,6 +791,7 @@ class Context {
ReplyParameters? replyParameters,
InlineKeyboardMarkup? replyMarkup,
String? businessConnectionId,
String? messageEffectId,
}) async {
_verifyInfo([_chatId], APIMethod.sendSticker);
return api.sendSticker(
Expand All @@ -766,6 +803,7 @@ class Context {
replyParameters: replyParameters,
replyMarkup: replyMarkup,
businessConnectionId: businessConnectionId,
messageEffectId: messageEffectId,
);
}

Expand Down Expand Up @@ -1133,6 +1171,7 @@ class Context {
bool? protectContent,
ReplyMarkup? replyMarkup,
ReplyParameters? replyParameters,
bool? showCaptionAboveMedia,
}) async {
_verifyInfo([_chatId, _msgId], APIMethod.copyMessage);
return api.copyMessage(
Expand All @@ -1147,6 +1186,7 @@ class Context {
protectContent: protectContent,
replyMarkup: replyMarkup,
replyParameters: replyParameters,
showCaptionAboveMedia: showCaptionAboveMedia,
);
}

Expand Down Expand Up @@ -1681,6 +1721,7 @@ class Context {
ParseMode? parseMode,
List<MessageEntity>? captionEntities,
InlineKeyboardMarkup? replyMarkup,
bool? showCaptionAboveMedia,
}) async {
if (_isInline()) {
await api.editInlineMessageCaption(
Expand All @@ -1689,6 +1730,7 @@ class Context {
parseMode: parseMode,
captionEntities: captionEntities,
replyMarkup: replyMarkup,
showCaptionAboveMedia: showCaptionAboveMedia,
);
} else {
_verifyInfo([_chatId, _msgId], APIMethod.editMessageCaption);
Expand All @@ -1699,6 +1741,7 @@ class Context {
parseMode: parseMode,
captionEntities: captionEntities,
replyMarkup: replyMarkup,
showCaptionAboveMedia: showCaptionAboveMedia,
);
}
return true;
Expand Down Expand Up @@ -1789,7 +1832,7 @@ class Context {
required String title,
required String description,
required String payload,
required String providerToken,
String? providerToken,
required String currency,
required List<LabeledPrice> prices,
int? messageThreadId,
Expand All @@ -1812,6 +1855,7 @@ class Context {
bool? protectContent,
InlineKeyboardMarkup? replyMarkup,
ReplyParameters? replyParameters,
String? messageEffectId,
}) async {
_verifyInfo([_chatId], APIMethod.sendInvoice);
return api.sendInvoice(
Expand Down Expand Up @@ -1842,6 +1886,7 @@ class Context {
protectContent: protectContent,
replyMarkup: replyMarkup,
replyParameters: replyParameters,
messageEffectId: messageEffectId,
);
}

Expand All @@ -1850,7 +1895,7 @@ class Context {
required String title,
required String description,
required String payload,
required String providerToken,
String? providerToken,
required String currency,
required List<LabeledPrice> prices,
int? maxTipAmount = 0,
Expand Down
4 changes: 4 additions & 0 deletions lib/src/televerse/raw_api.dart
Original file line number Diff line number Diff line change
Expand Up @@ -365,6 +365,7 @@ class RawAPI {
bool? protectContent,
ReplyMarkup? replyMarkup,
ReplyParameters? replyParameters,
bool? showCaptionAboveMedia,
}) async {
Map<String, dynamic> params = {
"chat_id": chatId.id,
Expand All @@ -378,6 +379,7 @@ class RawAPI {
"protect_content": protectContent,
"reply_markup": replyMarkup?.toJson(),
"reply_parameters": replyParameters?.toJson(),
"show_caption_above_media": showCaptionAboveMedia,
};
Uri uri = _buildUri(APIMethod.copyMessage);

Expand Down Expand Up @@ -2348,13 +2350,15 @@ class RawAPI {
ParseMode? parseMode,
List<MessageEntity>? captionEntities,
InlineKeyboardMarkup? replyMarkup,
bool? showCaptionAboveMedia,
}) async {
Map<String, dynamic> params = {
"inline_message_id": inlineMessageId,
"caption": caption,
"parse_mode": parseMode?.value,
"caption_entities": captionEntities?.map((e) => e.toJson()).toList(),
"reply_markup": replyMarkup?.toJson(),
"show_caption_above_media": showCaptionAboveMedia,
};
bool response = await _httpClient.postURI(
_buildUri(APIMethod.editMessageCaption),
Expand Down

0 comments on commit 3d0480c

Please sign in to comment.