televerse library
Televerse provides a simple and easy way to create Telegram bots. This library exports all the Televerse related classes and methods.
Usage
The Televerse
class let's you create a new bot instance. Or you can simply call it Bot
.
import 'package:televerse/televerse.dart';
void main() {
Bot bot = Bot("<YOUR BOT TOKEN>");
}
To import all the Telegram models, you can use the telegram.dart
file.
import 'package:televerse/telegram.dart';
Happy coding!
Classes
-
AlwaysFilter<
CTX extends Context> - A filter that always matches.
-
AnimationFilter<
CTX extends Context> - Filter that matches messages with animations.
-
AnyCommandFilter<
CTX extends Context> - Filter that matches any bot command.
-
AnyMessageFilter<
CTX extends Context> - Filter that matches any message (regular or edited).
-
AnyTextFilter<
CTX extends Context> - Filter that matches any text content (text or caption).
-
AudioFilter<
CTX extends Context> - Filter that matches messages with audio.
-
Bot<
CTX extends Context> - The main Bot class for creating and managing Telegram bots.
- BotInfo
- Bot information for context
-
BotPlugin<
CTX extends Context> - Interface for bot plugins.
- BotStats
- Statistics about bot operation.
-
BotUserFilter<
CTX extends Context> - Filter that matches messages from bot users.
-
BusinessConnectionFilter<
CTX extends Context> - Filter that matches business connection updates.
-
BusinessMessageFilter<
CTX extends Context> - Filter that matches business message updates.
-
CallbackQueryFilter<
CTX extends Context> - Filter that matches callback queries.
-
CaptionMessageFilter<
CTX extends Context> - Filter that matches caption messages (messages with caption content).
-
ChannelFilter<
CTX extends Context> - Filter that matches channel posts.
- ChannelID
- This class is used to represent a channel id. It is a subclass of ID.
-
ChannelPostFilter<
CTX extends Context> - Filter that matches channel posts.
-
ChatBoostFilter<
CTX extends Context> - Filter that matches chat boost updates.
- ChatID
- This class is used to represent a chat id. It is a subclass of ID.
-
ChatJoinRequestFilter<
CTX extends Context> - Filter that matches chat join request updates.
-
ChatMemberFilter<
CTX extends Context> - Filter that matches chat member updates.
- Filter that matches messages with chat shared information.
-
ChatTypeFilter<
CTX extends Context> - Filter that matches specific chat types.
-
ChosenInlineResultFilter<
CTX extends Context> - Filter that matches chosen inline results.
-
CommandFilter<
CTX extends Context> - Filter that matches bot commands.
-
Composer<
CTX extends Context> - Base class for middleware composition.
-
ContactFilter<
CTX extends Context> - Filter that matches messages with contacts.
-
ContainsFilter<
CTX extends Context> - Filter that matches text containing a specific substring.
- Context
- The context object that is passed to all middleware and handlers.
-
DeleteChatPhotoFilter<
CTX extends Context> - Filter that matches delete chat photo service messages.
-
DeletedBusinessMessagesFilter<
CTX extends Context> - Filter that matches deleted business message updates.
-
DiceFilter<
CTX extends Context> - Filter that matches messages with dice.
- DioHttpClient
- Dio-based implementation of HttpClient.
-
DocumentFilter<
CTX extends Context> - Filter that matches messages with documents.
-
EditedBusinessMessageFilter<
CTX extends Context> - Filter that matches edited business message updates.
-
EditedChannelPostFilter<
CTX extends Context> - Filter that matches edited channel posts.
-
EditedMessageFilter<
CTX extends Context> - Filter that matches edited messages.
-
EmojiReactionFilter<
CTX extends Context> - Filter that matches specific emoji reactions.
-
EntityFilter<
CTX extends Context> - Filter that matches messages with specific entity types.
- FetcherConfig
- Configuration for update fetchers.
-
Filter<
CTX extends Context> - Base class for all filters.
-
Filters<
CTX extends Context> - Context-aware filters factory that provides properly typed filters.
-
ForumTopicClosedFilter<
CTX extends Context> - Filter that matches forum topic closed service messages.
-
ForumTopicCreatedFilter<
CTX extends Context> - Filter that matches forum topic created service messages.
-
ForumTopicEditedFilter<
CTX extends Context> - Filter that matches forum topic edited service messages.
-
ForumTopicReopenedFilter<
CTX extends Context> - Filter that matches forum topic reopened service messages.
-
ForwardedFilter<
CTX extends Context> - Filter that matches forwarded messages.
-
GameFilter<
CTX extends Context> - Filter that matches messages with games.
-
GroupChatFilter<
CTX extends Context> - Filter that matches group chats (including supergroups).
-
HashtagFilter<
CTX extends Context> - Filter that matches messages with hashtags.
- HttpClient
- Abstract HTTP client interface for making API requests.
- HttpClientFactory
- Factory class for creating HTTP client instances.
- HttpUtils
- Utilities for working with HTTP requests and responses.
-
HumanUserFilter<
CTX extends Context> - Filter that matches messages from human users (non-bots).
- ID
- This class is used to represent a chat id. It is a superclass of ChatID, ChannelID and SupergroupID.
- IDConverter
- Converts the ID to JSON
- InlineKeyboard
-
Represents an inline keyboard that appears right next to the message it
belongs to. This is a utility wrapper around
InlineKeyboardMarkup
that provides a fluent API for building inline keyboards. -
InlineMenu<
CTX extends Context> - An inline keyboard menu with callback handlers.
-
InlineQueryFilter<
CTX extends Context> - Filter that matches inline queries.
- InlineQueryResultBuilder
- A utility class to build Inline Query Results quickly and easily.
- InputFile
- This class is used to represent a file to be sent.
- InputFileConverter
- Converter for InputFile
- Keyboard
-
Represents a custom keyboard that appears below the message it belongs to.
This is a utility wrapper around
ReplyKeyboardMarkup
that provides a fluent API for building keyboards. -
KeyboardMenu<
CTX extends Context> - A reply keyboard menu with text handlers.
-
LiveLocationFilter<
CTX extends Context> - Filter that matches live location messages.
- LocalFile
- The File to be uploaded.
-
LocationFilter<
CTX extends Context> - Filter that matches messages with locations.
- LongPollingConfig
- Configuration for long polling fetcher.
- LongPollingFetcher
- Long polling fetcher implementation.
-
MediaFilter<
CTX extends Context> - Filter that matches messages with any media.
-
MentionFilter<
CTX extends Context> - Filter that matches messages with mentions.
- MessageContentGenerator
- Basically stuffs the input message content to the Inline Query Result
-
MessageFilter<
CTX extends Context> - Filter that matches messages (not edited messages).
-
MessageReactionCountFilter<
CTX extends Context> - Filter that matches message reaction count updates.
-
MessageReactionFilter<
CTX extends Context> - Filter that matches message reaction updates.
-
MiddlewareEntry<
CTX extends Context> - Entry in the middleware chain.
- MiddlewareExecutionInfo
- Information about a single middleware execution.
-
MiddlewarePlugin<
CTX extends Context> - Base class for plugins that only provide middleware.
- MiddlewareStats
- Middleware execution statistics.
- MockHttpClient
- Mock HTTP client implementation for testing purposes.
- MockRequest
- Represents a recorded HTTP request for testing purposes.
-
MyChatMemberFilter<
CTX extends Context> - Filter that matches my chat member updates.
-
NeverFilter<
CTX extends Context> - A filter that never matches.
-
NewChatPhotoFilter<
CTX extends Context> - Filter that matches new chat photo service messages.
-
NewChatTitleFilter<
CTX extends Context> - Filter that matches new chat title service messages.
-
PaidMediaFilter<
CTX extends Context> - Filter that matches messages with paid media.
-
PaidMediaPhotoFilter<
CTX extends Context> - Filter for paid media with photos.
-
PaidMediaVideoFilter<
CTX extends Context> - Filter for paid media with videos.
- Payload
- Represents a payload object used for making API calls.
-
PhotoFilter<
CTX extends Context> - Filter that matches messages with photos.
-
PinnedMessageFilter<
CTX extends Context> - Filter that matches pinned messages.
-
PollAnswerFilter<
CTX extends Context> - Filter that matches poll answer updates.
-
PollFilter<
CTX extends Context> - Filter that matches poll updates.
-
PollMessageFilter<
CTX extends Context> - Filter that matches messages with poll content.
-
PreCheckoutQueryFilter<
CTX extends Context> - Filter that matches pre-checkout queries.
-
PredicateFilter<
CTX extends Context> - A filter based on a custom predicate function.
-
PrivateChatFilter<
CTX extends Context> - Filter that matches private chats.
-
PurchasedPaidMediaFilter<
CTX extends Context> - Filter for paid media purchase updates.
- RawAPI
- Raw API class for making direct calls to the Telegram Bot API.
-
RegexFilter<
CTX extends Context> - Filter that matches text using regular expressions.
-
RemovedChatBoostFilter<
CTX extends Context> - Filter that matches removed chat boost updates.
-
ReplyFilter<
CTX extends Context> - Filter that matches reply messages.
-
ShippingQueryFilter<
CTX extends Context> - Filter that matches shipping queries.
-
StartsWithFilter<
CTX extends Context> - Filter that matches text starting with a specific prefix.
-
StickerFilter<
CTX extends Context> - Filter that matches messages with stickers.
-
SuccessfulPaymentFilter<
CTX extends Context> - Filter that matches messages with successful payment.
- SupergroupID
- This class is used to represent a supergroup id. It is a subclass of ID.
-
TeleverseMenu<
CTX extends Context> - Base class for all Televerse menus.
-
TextFilter<
CTX extends Context> - Filter that matches messages or channel posts with text.
-
TextMessageFilter<
CTX extends Context> - Filter that matches text messages (messages with text content).
- Transformer
- Abstract base class for API request transformers.
- TransformerManager
- Manages a chain of transformers for API requests.
-
TransformerPlugin<
CTX extends Context> - Base class for plugins that only provide transformers.
- UpdateFetcher
- Abstract base class for update fetchers.
-
UrlFilter<
CTX extends Context> - Filter that matches messages with URLs.
-
UserFilter<
CTX extends Context> - Filter that matches messages from specific users.
- Filter that matches messages with user shared information.
-
VenueFilter<
CTX extends Context> - Filter that matches messages with venue information.
-
VideoChatEndedFilter<
CTX extends Context> - Filter that matches video chat ended service messages.
-
VideoChatParticipantsInvitedFilter<
CTX extends Context> - Filter that matches video chat participants invited service messages.
-
VideoChatScheduledFilter<
CTX extends Context> - Filter that matches video chat scheduled service messages.
-
VideoChatStartedFilter<
CTX extends Context> - Filter that matches video chat started service messages.
-
VideoFilter<
CTX extends Context> - Filter that matches messages with videos.
-
VideoNoteFilter<
CTX extends Context> - Filter that matches messages with video notes.
-
VoiceFilter<
CTX extends Context> - Filter that matches messages with voice notes.
-
WebAppDataFilter<
CTX extends Context> - Filter that matches messages with web app data.
- WebhookConfig
- Enhanced configuration for webhook fetcher with built-in server support.
- WebhookFetcher
- Enhanced webhook fetcher with built-in HTTP server support.
- WebhookStats
- Statistics about webhook requests.
Enums
- APIMethod
- Represents the methods available in the Telegram Bot API.
- InputFileType
- This object represents the type of a file to send. Currently, the following 3 types are supported:
- TeleverseExceptionType
- Enum to classify different types of Televerse exceptions.
- UpdateType
- This object represents type of an incoming update.
Extensions
- CleanString on String
- String extension, to clean the String
- ContextAwareMethods on Context
- Extension methods for enhanced Context functionality.
- ContextEntityExtension on Context
- Entity text extraction and manipulation methods for Context
- Filename on File
- Filename extension for io.File is used to get the filename of a file.
- FromAndChatExt on Update
- Update extension to get the Chat and User from the update.
- GetChatID on Chat
-
Extension on
Chat
to create ID of the chat - GetUserChatID on User
-
Extension on
User
to create ID of the chat - IntDate on int
- IntDate extension is used to convert an integer to a DateTime object. The integer is assumed to be unix time.
- UnixTime on DateTime
- UnixTime extension is used to convert a DateTime object to unix time.
Constants
- ignore → const _Ignore
- Ignores the value
Functions
-
getRandomID(
[int len = 20]) → String - Internal method to generate a random id. Include a-z, A-Z, 0-9
-
nullFilter(
String _, dynamic value) → bool - Null filter function.
Typedefs
-
APICaller
= Future<
Map< Function(APIMethod method, [Payload? payload])String, dynamic> > - Signature for the API caller function passed to transformers.
-
ContextFactory<
CTX extends Context> = CTX Function(Update update, RawAPI api, BotInfo botInfo) - Type alias for context factory function.
-
ErrorBoundaryHandler<
CTX extends Context> = FutureOr< void> Function(BotError<CTX> error, NextFunction next) - Error boundary handler function type.
-
ErrorHandler<
CTX extends Context> = FutureOr< void> Function(BotError<CTX> error) - Error handler function type.
-
MenuHandler<
CTX extends Context> = FutureOr< void> Function(CTX ctx) - Type alias for menu handler functions.
-
Middleware<
CTX extends Context> = FutureOr< void> Function(CTX ctx, NextFunction next) - Middleware function signature.
-
MiddlewareFactory<
CTX extends Context> = Middleware< CTX> Function(CTX ctx) - Middleware factory function type.
-
MiddlewarePredicate<
CTX extends Context> = bool Function(CTX ctx) - Predicate function type for conditional middleware.
-
NextFunction
= FutureOr<
void> Function() - The next function type that continues the middleware chain.
-
PayloadFiles
= List<
Map< String, LocalFile> > - Represents a list of maps containing key-value pairs for multipart files.
-
UpdateHandler<
CTX extends Context> = FutureOr< void> Function(CTX ctx) - Type aliases for convenience.
Exceptions / Errors
-
BotError<
CTX extends Context> - A bot error that occurred during update processing.
- FetcherException
- Exception thrown by fetchers when an error occurs.
- TelegramException
- HttpException is thrown when the HTTP request fails.
- TeleverseException
- TeleverseException is thrown when an error occurs in the library.