Skip to content

Commit

Permalink
Merge branch 'APIv6.8' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
ale183 committed Sep 2, 2023
2 parents f9c2f42 + bd12a1e commit 7325905
Show file tree
Hide file tree
Showing 9 changed files with 64 additions and 6 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 1.0.0-b6

- Updated to bot API 6.8

## 1.0.0-b5

- Updated to bot API 6.7
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Dart Telegram Bot is a [Dart](https://dart.dev) wrapper for [Telegram](https://t
bot [API](https://core.telegram.org/bots/api). \
It is compatible with Native, Flutter and JS.

[![Bot API Version](https://img.shields.io/badge/Bot%20API-6.7-blue.svg?style=flat-square)](https://core.telegram.org/bots/api)
[![Bot API Version](https://img.shields.io/badge/Bot%20API-6.8-blue.svg?style=flat-square)](https://core.telegram.org/bots/api)
[![Dart Version](https://img.shields.io/badge/Dart-2.12.0-blue.svg?style=flat-square)](https://dart.dev)

Using Dart Telegram Bot is straightforward, here's an example echo bot:
Expand Down
6 changes: 6 additions & 0 deletions lib/src/entities/internal/tgapi_methods.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1406,6 +1406,12 @@ mixin TGAPIMethods {
});
}

Future<bool> unpinAllGeneralForumTopicMessages(ChatID chatId) {
return _client.apiCall(_token, 'unpinAllGeneralForumTopicMessages', {
'chat_id': chatId,
});
}

/// Use this method to send answers to callback queries sent from
/// inline keyboards.
///
Expand Down
9 changes: 9 additions & 0 deletions lib/src/entities/telegram/chat.dart
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,12 @@ class Chat {
/// Returned only in getChat.
String? emojiStatusCustomEmojiId;

/// Optional.
/// Expiration date of the emoji status of the other party in a
/// private chat, if any.
/// Returned only in getChat.
int? emojiStatusExpirationDate;

/// Optional.
/// Bio of the other party in a private chat. Returned only in getChat.
String? bio;
Expand Down Expand Up @@ -165,6 +171,7 @@ class Chat {
this.photo,
this.activeUsernames,
this.emojiStatusCustomEmojiId,
this.emojiStatusExpirationDate,
this.bio,
this.hasPrivateForwards,
this.hasRestrictedVoiceAndVideoMessages,
Expand Down Expand Up @@ -198,6 +205,7 @@ class Chat {
photo: callIfNotNull(ChatPhoto.fromJson, json['photo']),
activeUsernames: List.from(json['active_usernames'] ?? []),
emojiStatusCustomEmojiId: json['emoji_status_custom_emoji_id'],
emojiStatusExpirationDate: json['emoji_status_expiration_date'],
bio: json['bio'],
hasPrivateForwards: json['has_private_forwards'],
hasRestrictedVoiceAndVideoMessages:
Expand Down Expand Up @@ -236,6 +244,7 @@ class Chat {
'photo': photo,
'active_usernames': activeUsernames,
'emoji_status_custom_emoji_id': emojiStatusCustomEmojiId,
'emoji_status_expiration_date': emojiStatusExpirationDate,
'bio': bio,
'has_private_forwards': hasPrivateForwards,
'has_restricted_voice_and_video_messages':
Expand Down
7 changes: 7 additions & 0 deletions lib/src/entities/telegram/message.dart
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,10 @@ class Message {
/// Message is a sticker, information about the sticker
Sticker? sticker;

/// Optional.
/// Message is a forwarded story
Story? story;

/// Optional.
/// Message is a video, information about the video
Video? video;
Expand Down Expand Up @@ -362,6 +366,7 @@ class Message {
this.document,
this.photo,
this.sticker,
this.story,
this.video,
this.videoNote,
this.voice,
Expand Down Expand Up @@ -443,6 +448,7 @@ class Message {
document: callIfNotNull(Document.fromJson, json['document']),
photo: callIfNotNull(PhotoSize.listFromJsonArray, json['photo']),
sticker: callIfNotNull(Sticker.fromJson, json['sticker']),
story: callIfNotNull(Story.fromJson, json['story']),
video: callIfNotNull(Video.fromJson, json['video']),
videoNote: callIfNotNull(VideoNote.fromJson, json['video_note']),
voice: callIfNotNull(Voice.fromJson, json['voice']),
Expand Down Expand Up @@ -584,6 +590,7 @@ class Message {
'document': document,
'photo': photo,
'sticker': sticker,
'story': story,
'video': video,
'video_note': videoNote,
'voice': voice,
Expand Down
18 changes: 14 additions & 4 deletions lib/src/entities/telegram/poll_answer.dart
Original file line number Diff line number Diff line change
@@ -1,14 +1,21 @@
import 'dart:convert';

import 'package:dart_telegram_bot/src/entities/internal/helpers/util.dart';

import '../../../telegram_entities.dart';

/// This object represents an answer of a user in a non-anonymous poll.
class PollAnswer {
/// Unique poll identifier
String pollId;

/// The user, who changed the answer to the poll
User user;
/// Optional.
/// The chat that changed the answer to the poll, if the voter is anonymous
Chat? voterChat;

/// Optional.
/// The user that changed the answer to the poll, if the voter isn't anonymous
User? user;

/// 0-based identifiers of answer options, chosen by the user.
/// May be empty if the user retracted their vote.
Expand All @@ -17,15 +24,17 @@ class PollAnswer {
/// Basic constructor
PollAnswer({
required this.pollId,
required this.user,
this.voterChat,
this.user,
required this.optionIds,
});

/// Creates a object from a json
static PollAnswer fromJson(Map<String, dynamic> json) {
return PollAnswer(
pollId: json['poll_id']!,
user: json['user']!,
voterChat: callIfNotNull(Chat.fromJson, json['voter_chat']),
user: callIfNotNull(User.fromJson, json['user']),
optionIds: json['option_ids']!,
);
}
Expand All @@ -34,6 +43,7 @@ class PollAnswer {
Map toJson() {
return {
'poll_id': pollId,
'voter_chat': voterChat,
'user': user,
'option_ids': optionIds,
}..removeWhere((_, v) => v == null);
Expand Down
21 changes: 21 additions & 0 deletions lib/src/entities/telegram/story.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import 'dart:convert';

/// This object represents a message about a forwarded story in the chat
/// Currently holds no information.
class Story {
/// Basic constructor
Story();

/// Creates a object from a json
static Story fromJson(Map<String, dynamic> json) {
return Story();
}

/// Creates a json from the object
Map toJson() {
return {};
}

@override
String toString() => json.encode(this);
}
1 change: 1 addition & 0 deletions lib/telegram_entities.dart
Original file line number Diff line number Diff line change
Expand Up @@ -136,3 +136,4 @@ export 'src/entities/telegram/input_sticker.dart';
export 'src/entities/telegram/inline_query_results_button.dart';
export 'src/entities/telegram/switch_inline_query_chosen_chat.dart';
export 'src/entities/telegram/bot_name.dart';
export 'src/entities/telegram/story.dart';
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: dart_telegram_bot
description: A Telegram Bot API wrapper made to make fast Telegram bots with as less code as possible.
version: 1.0.0-b5
version: 1.0.0-b6
homepage: https://github.com/KaikyuDev/dart-telegram-bot

environment:
Expand Down

0 comments on commit 7325905

Please sign in to comment.