Skip to content

Commit

Permalink
🤖 Merge #247: Bot API 7.3
Browse files Browse the repository at this point in the history
  • Loading branch information
HeySreelal authored May 6, 2024
2 parents 9068501 + fc9aa7e commit 7bb90e3
Show file tree
Hide file tree
Showing 32 changed files with 864 additions and 312 deletions.
20 changes: 0 additions & 20 deletions .vscode/launch.json

This file was deleted.

6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
# 1.16.0

- 🤖 Bot API 7.3 (May 6, 2024)
- Added `Keyboard.remove` method to remove Keyboard.
- Refactors and improvements

# 1.15.14

- Removed unnecessary print in the callback setter.
Expand Down
14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

[![Pub Version](https://img.shields.io/pub/v/televerse?color=blue&logo=blue)](https://pub.dev/packages/televerse)
![GitHub](https://img.shields.io/github/license/HeySreelal/televerse?color=green)
![](https://shields.io/badge/Latest-Bot%20API%207.2-blue)
![](https://shields.io/badge/Latest-Bot%20API%207.3-blue)

<a href="https://telegram.me/TeleverseDart">
<img src="https://img.shields.io/badge/Telegram%2F@TeleverseDart-2CA5E0?style=for-the-badge&logo=telegram&logoColor=white"/>
Expand All @@ -13,15 +13,15 @@

---

🤖 `Bot API version: Bot API 7.2 (March 31, 2024)`
🤖 `Bot API version: Bot API 7.3 (May 6, 2024)`

Televerse is a powerful, easy-to-use, and highly customizable Telegram bot framework built with Dart programming language. It provides a complete and well-structured API that enables developers to create and deploy complex Telegram bots with ease. Televerse provides a total of 0 dynamic types on its public interface, making it easy for developers to write strictly typed code.

## 🔥 Latest Update: Inline Query Result Builder
## 🔥 Bot API 7.3 (May 6, 2024)

Televerse now includes the powerful `InlineQueryResultBuilder`! This feature simplifies the creation of inline query results with efficiency and simplicity in mind. Utilize methods like `InlineQueryResultBuilder.article`, `InlineQueryResultBuilder.audio`, `InlineQueryResultBuilder.contact`, and more to effortlessly generate various types of inline query results. Upgrade now and streamline your bot development process with Televerse.
In a nutshell, the updates include, InlineKeyboardMarkup support for business messages, infinite editability for live locations. Support for new poll features and to chat background changes service messages.

Check out [the example](https://github.com/xooniverse/TeleverseExamples/blob/main/lib/inline_queries_bot.dart) and [changelog](./CHANGELOG.md) for more details! 🚀
Checkout [changelog](https://core.telegram.org/bots/api-changelog#may-6-2024) for more details! 🚀

<hr>

Expand Down Expand Up @@ -198,15 +198,15 @@ Televerse offers a wide array of listener methods to cater to your bot's needs,
| Method | Description |
| --- | --- |
| `bot.command` | For listening commands |
| `bot.hears` | For listening to specified Regular Expression; |
| `bot.hears` | For listening to specified Regular Expression |
| `bot.inlineQuery` | For listening to inline query with specified query text |
| `bot.text` | For listening to message with specified text |
| `bot.callbackQuery` | For listening to specified callback data |
| `bot.onDocument` | For listening to messages that contain a document |
| `bot.onPhoto` | For listening to photo messages |
| `bot.chatType` | This method can be used to listen to messages/updates coming from a specific type of chat such as Super Group or Channel or Private Chat |
| `bot.entity` | Sets up handler method for messages that contains specified entity type |
| `bot.myChatMember` | Listens to change in Bot's chat member status - such as bot is added to a channel or kicked from a group etc. }
| `bot.myChatMember` | Listens to change in Bot's chat member status - such as bot is added to a channel or kicked from a group etc.
- And much much more :)


Expand Down
21 changes: 0 additions & 21 deletions analysis_options.yaml
Original file line number Diff line number Diff line change
@@ -1,20 +1,5 @@
# This file configures the static analysis results for your project (errors,
# warnings, and lints).
#
# This enables the 'recommended' set of lints from `package:lints`.
# This set helps identify many issues that may lead to problems when running
# or consuming Dart code, and enforces writing Dart using a single, idiomatic
# style and format.
#
# If you want a smaller set of lints you can change this to specify
# 'package:lints/core.yaml'. These are just the most critical lints
# (the recommended set includes the core lints).
# The core lints are also what is used by pub.dev for scoring packages.

include: package:lints/recommended.yaml

# Uncomment the following section to specify additional rules.

linter:
rules:
- camel_case_types
Expand All @@ -29,9 +14,3 @@ linter:
analyzer:
errors:
invalid_annotation_target: ignore

# For more information about the core and recommended set of lints, see
# https://dart.dev/go/core-lints

# For additional information about configuring this file, see
# https://dart.dev/guides/language/analysis-options
28 changes: 28 additions & 0 deletions lib/src/telegram/models/abstracts/background_fill.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
part of '../models.dart';

/// This object describes the way a background is filled based on the selected colors.
abstract class BackgroundFill {
/// Type of the background fill.
BackgroundFillType get type;

/// Creates a new [BackgroundFill] object.
/// This method decides which [BackgroundFill] subclass to use based on the [type] field.
factory BackgroundFill.fromJson(Map<String, dynamic> json) {
switch (json['type']) {
case 'solid':
return BackgroundFillSolid.fromJson(json);
case 'gradient':
return BackgroundFillGradient.fromJson(json);
case 'freeform_gradient':
return BackgroundFillFreeformGradient.fromJson(json);
default:
throw ArgumentError('Invalid background fill type');
}
}

/// Creates a new [BackgroundFill] object from JSON.
const BackgroundFill();

/// Converts a [BackgroundFill] to a [Map] for JSON encoding.
Map<String, dynamic> toJson();
}
30 changes: 30 additions & 0 deletions lib/src/telegram/models/abstracts/background_type_fill.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
part of '../models.dart';

/// This object describes the type of a background.
abstract class BackgroundType {
/// Type of the background.
BackgroundTypeType get type;

/// Creates a new [BackgroundType] object.
/// This method decides which [BackgroundType] subclass to use based on the [type] field.
static BackgroundType create(Map<String, dynamic> json) {
switch (json['type']) {
case 'fill':
return BackgroundTypeFill.fromJson(json);
case 'wallpaper':
return BackgroundTypeWallpaper.fromJson(json);
case 'pattern':
return BackgroundTypePattern.fromJson(json);
case 'chat_theme':
return BackgroundTypeChatTheme.fromJson(json);
default:
throw ArgumentError('Invalid background type');
}
}

/// Creates a new [BackgroundType] object from JSON.
const BackgroundType();

/// Converts a [BackgroundType] to a [Map] for JSON encoding.
Map<String, dynamic> toJson();
}
31 changes: 31 additions & 0 deletions lib/src/telegram/models/background_fill_freeform_gradient.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
part of 'models.dart';

/// Represents a background fill where the background is a freeform gradient that rotates after every message in the chat.
class BackgroundFillFreeformGradient extends BackgroundFill {
@override
BackgroundFillType get type => BackgroundFillType.freeformGradient;

/// A list of the 3 or 4 base colors that are used to generate the freeform gradient in the RGB24 format.
final List<int> colors;

/// Constructs a [BackgroundFillFreeformGradient] object.
const BackgroundFillFreeformGradient({
required this.colors,
});

/// Creates a [BackgroundFillFreeformGradient] object from JSON.
factory BackgroundFillFreeformGradient.fromJson(Map<String, dynamic> json) {
return BackgroundFillFreeformGradient(
colors: List<int>.from(json['colors']),
);
}

/// Converts a [BackgroundFillFreeformGradient] object to JSON.
@override
Map<String, dynamic> toJson() {
return {
'type': type.value,
'colors': colors,
};
}
}
43 changes: 43 additions & 0 deletions lib/src/telegram/models/background_fill_gradient.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
part of 'models.dart';

/// Represents a background fill where the background is a gradient fill.
class BackgroundFillGradient extends BackgroundFill {
@override
BackgroundFillType get type => BackgroundFillType.gradient;

/// Top color of the gradient in the RGB24 format.
final int topColor;

/// Bottom color of the gradient in the RGB24 format.
final int bottomColor;

/// Clockwise rotation angle of the background fill in degrees; 0-359.
final int rotationAngle;

/// Constructs a [BackgroundFillGradient] object.
const BackgroundFillGradient({
required this.topColor,
required this.bottomColor,
required this.rotationAngle,
});

/// Creates a [BackgroundFillGradient] object from JSON.
factory BackgroundFillGradient.fromJson(Map<String, dynamic> json) {
return BackgroundFillGradient(
topColor: json['top_color'],
bottomColor: json['bottom_color'],
rotationAngle: json['rotation_angle'],
);
}

/// Converts a [BackgroundFillGradient] object to JSON.
@override
Map<String, dynamic> toJson() {
return {
'type': type.value,
'top_color': topColor,
'bottom_color': bottomColor,
'rotation_angle': rotationAngle,
};
}
}
31 changes: 31 additions & 0 deletions lib/src/telegram/models/background_fill_solid.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
part of 'models.dart';

/// Represents a background fill where the background is filled using the selected color.
class BackgroundFillSolid extends BackgroundFill {
@override
BackgroundFillType get type => BackgroundFillType.solid;

/// The color of the background fill in the RGB24 format.
final int color;

/// Constructs a [BackgroundFillSolid] object.
const BackgroundFillSolid({
required this.color,
});

/// Creates a [BackgroundFillSolid] object from JSON.
factory BackgroundFillSolid.fromJson(Map<String, dynamic> json) {
return BackgroundFillSolid(
color: json['color'],
);
}

/// Converts a [BackgroundFillSolid] object to JSON.
@override
Map<String, dynamic> toJson() {
return {
'type': type.value,
'color': color,
};
}
}
31 changes: 31 additions & 0 deletions lib/src/telegram/models/background_type_chat_theme.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
part of 'models.dart';

/// Represents a background type where the background is taken directly from a built-in chat theme.
class BackgroundTypeChatTheme extends BackgroundType {
@override
BackgroundTypeType get type => BackgroundTypeType.chatTheme;

/// Name of the chat theme, which is usually an emoji.
final String themeName;

/// Constructs a [BackgroundTypeChatTheme] object.
const BackgroundTypeChatTheme({
required this.themeName,
});

/// Creates a [BackgroundTypeChatTheme] object from JSON.
factory BackgroundTypeChatTheme.fromJson(Map<String, dynamic> json) {
return BackgroundTypeChatTheme(
themeName: json['theme_name'],
);
}

/// Converts a [BackgroundTypeChatTheme] object to JSON.
@override
Map<String, dynamic> toJson() {
return {
'type': type.value,
'theme_name': themeName,
};
}
}
37 changes: 37 additions & 0 deletions lib/src/telegram/models/background_type_fill.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
part of 'models.dart';

/// Represents a background type where the background is automatically filled based on selected colors.
class BackgroundTypeFill extends BackgroundType {
@override
BackgroundTypeType get type => BackgroundTypeType.fill;

/// The background fill.
final BackgroundFill fill;

/// Dimming of the background in dark themes, as a percentage; 0-100.
final int darkThemeDimming;

/// Constructs a [BackgroundTypeFill] object.
const BackgroundTypeFill({
required this.fill,
required this.darkThemeDimming,
});

/// Creates a [BackgroundTypeFill] object from JSON.
factory BackgroundTypeFill.fromJson(Map<String, dynamic> json) {
return BackgroundTypeFill(
fill: BackgroundFill.fromJson(json['fill']),
darkThemeDimming: json['dark_theme_dimming'],
);
}

/// Converts a [BackgroundTypeFill] object to JSON.
@override
Map<String, dynamic> toJson() {
return {
'type': type.value,
'fill': fill.toJson(),
'dark_theme_dimming': darkThemeDimming,
};
}
}
Loading

0 comments on commit 7bb90e3

Please sign in to comment.