Skip to content

Commit

Permalink
v1.1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
HeySreelal committed Sep 8, 2024
1 parent c5de094 commit 6e7a13c
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 15 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# 1.1.0

- Updated Transformer definition

# 1.0.1

- Adds support for `answerInlineQuery`, `editMessageMedia`, and `sendMediaGroup`
Expand Down
24 changes: 12 additions & 12 deletions lib/src/parse_mode_setter_base.dart
Original file line number Diff line number Diff line change
Expand Up @@ -128,9 +128,9 @@ class ParseModeSetter implements Transformer {
@override
Future<Map<String, dynamic>> transform(
APICaller call,
APIMethod method,
Payload payload,
) {
APIMethod method, [
Payload? payload,
]) {
if (!allowedMethods.contains(method)) {
return call(method, payload);
}
Expand All @@ -143,10 +143,10 @@ class ParseModeSetter implements Transformer {

if (isSendPoll) {
if (setExplanationParseMode) {
payload["explanation_parse_mode"] = parseMode.value;
payload?["explanation_parse_mode"] = parseMode.value;
}
if (setQuestionParseMode) {
payload["question_parse_mode"] = parseMode.value;
payload?["question_parse_mode"] = parseMode.value;
}
} else if (method == APIMethod.answerInlineQuery) {
const supported = [
Expand All @@ -159,7 +159,7 @@ class ParseModeSetter implements Transformer {
"document",
];

final List<dynamic> results = payload['results'];
final List<dynamic> results = payload?['results'];
for (int i = 0; i < results.length; i++) {
if (supported.contains(results[i]['type'])) {
results[i][kParseMode] = parseMode.value;
Expand All @@ -168,21 +168,21 @@ class ParseModeSetter implements Transformer {
results[i]['input_message_content'][kParseMode] = parseMode.value;
}
}
payload['results'] = results;
payload?['results'] = results;
} else if (method == APIMethod.editMessageMedia) {
if (payload["media"]["caption"] != null) {
payload["media"][kParseMode] = parseMode.value;
if (payload?["media"]["caption"] != null) {
payload?["media"][kParseMode] = parseMode.value;
}
} else if (method == APIMethod.sendMediaGroup) {
final List<dynamic> media = payload["media"];
final List<dynamic> media = payload?["media"];
for (int i = 0; i < media.length; i++) {
if (media[i]["caption"] != null) {
media[i][kParseMode] = parseMode.value;
}
}
payload["media"] = media;
payload?["media"] = media;
} else {
payload[kParseMode] = parseMode.value;
payload?[kParseMode] = parseMode.value;
}

return call(method, payload);
Expand Down
6 changes: 3 additions & 3 deletions pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: parse_mode_setter
description: A plugin for Televerse. Let's you set parse mode all methods in one line.
version: 1.0.1
version: 1.1.0
repository: https://github.com/xooniverse/ParseModeSetter
issue_tracker: https://github.com/xooniverse/ParseModeSetter/issues
funding:
Expand All @@ -12,10 +12,10 @@ topics:
- telegram

environment:
sdk: ^3.4.4
sdk: ">=3.0.0 <4.0.0"

dependencies:
televerse: ^1.19.5
televerse: ^1.26.0

dev_dependencies:
lints: ^3.0.0
Expand Down

0 comments on commit 6e7a13c

Please sign in to comment.