feat: payload для /start в ботах.

This commit is contained in:
Jganenokk
2026-07-30 18:39:31 +07:00
parent 8f42692708
commit f6de41f11d
13 changed files with 483 additions and 38 deletions
+25
View File
@@ -412,6 +412,11 @@ class CachedMessage {
this.editHistory,
});
bool get isBotStartMarker {
final control = attachments?.whereType<ControlAttachment>().firstOrNull;
return control != null && control.isBotStart;
}
CachedMessage copyWith({
String? status,
bool? deleted,
@@ -809,6 +814,26 @@ class MessagesModule {
return _api.sendRequest(Opcode.msgSend, payload);
}
Future<Map<String, dynamic>?> sendBotStart(
int chatId,
String startPayload,
) async {
final response = await _api.sendRequest(Opcode.msgSend, {
'chatId': chatId,
'message': {
'cid': DateTime.now().millisecondsSinceEpoch * -1,
'attaches': [
{
'_type': 'CONTROL',
'event': ControlAttachment.botStartedEvent,
'startPayload': startPayload,
},
],
},
});
return _sentMessageMap(response);
}
Future<String> _sendAndExtractMessageId(
Map<String, dynamic> payload,
String defaultError,