TelegramNotifier class

The main service class that communicates with the Telegram API.

Example Usage:

// 1. Simple Usage
final notifier = TelegramNotifier(
  botToken: "YOUR_BOT_TOKEN",
  defaultChatId: "@your_channel",
);

await notifier.sendJson(
  data: {
    "error_code": 500,
    "message": "Invalid credentials",
    "request": {
      "endpoint": "/api/login",
      "method": "POST",
    }
  },
);

// 2. Advanced Usage (with your own Dio and Formatter)
final myDio = Dio(BaseOptions(connectTimeout: Duration(seconds: 10)));
final myFormatter = MyCustomFormatter();

final advancedNotifier = TelegramNotifier(
  botToken: "YOUR_BOT_TOKEN",
  defaultChatId: "123456789",
  dio: myDio,
  formatter: myFormatter,
);

Constructors

TelegramNotifier({required String botToken, required String defaultChatId, Dio? dio, MessageFormatter? formatter})
Creates a service for sending notifications to Telegram.

Properties

hashCode int
The hash code for this object.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
sendJson({required Map<String, dynamic> data, String? overrideChatId, ParseMode parseMode = ParseMode.MarkdownV2}) Future<void>
Sends a given Map (JSON) to Telegram using the configured formatter.
sendMessage({required String text, String? overrideChatId, ParseMode parseMode = ParseMode.MarkdownV2}) Future<void>
Sends a plain text message to Telegram.
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited