tom_chattools library
Tom ChatTools - Unified chat API abstraction for messaging platforms.
This library provides a platform-agnostic API for integrating with various messaging platforms like Telegram, WhatsApp, Signal, etc.
Quick Start
import 'package:tom_chattools/tom_chattools.dart';
void main() async {
// Connect to Telegram
final api = await ChatAPI.connect(TelegramChatConfig(
token: 'YOUR_BOT_TOKEN',
));
// Send a message
await api.sendMessage(ChatReceiver.id('123456789'), 'Hello!');
// Wait for response
final response = await api.getMessages(
maxWait: Duration(seconds: 30),
minWait: Duration(seconds: 5),
);
for (final message in response.messages) {
print('Received: ${message.text}');
}
await api.disconnect();
}
Supported Platforms
- Telegram - Full support via Bot API
- More platforms coming soon (WhatsApp, Signal, etc.)
Classes
- ChatApi
- Abstract base class for chat platform integrations.
- ChatAttachment
- Represents an attachment in a message.
- ChatConfig
- Base class for chat platform configuration.
- ChatMessage
- A message sent or received through the chat API.
- ChatMessageFilter
- Filter for selecting specific message types.
- ChatReceiver
- Identifies a recipient for sending messages.
- ChatReceiverInfo
- Additional information about a receiver.
- ChatResponse
-
Encapsulates the response from
ChatAPI.getMessages. - ChatSender
- Represents the sender of a message.
- ChatSettings
- Settings for connecting to chat platforms.
- TelegramChatConfig
- Configuration for connecting to Telegram via Bot API.
Enums
- ChatAttachmentType
- Types of attachments.
- ChatMessageType
- Types of chat messages.
- ChatReceiverType
- Types of receiver identifiers.
- ChatResponseStatus
- Status codes for chat responses.