sendChatAction method
FutureOr<Map>
sendChatAction({
- required Map parameters,
- required TelegramClientCallApiInvoke callApiInvoke,
method SendChatAction
Implementation
FutureOr<Map> sendChatAction({
required Map parameters,
required TelegramClientCallApiInvoke callApiInvoke,
}) async {
dynamic target_chat_id = TgUtils.parse_all_chat_id(parameters: parameters);
if (target_chat_id is String &&
RegExp(r"^((@)[a-z0-9_]+)$", caseSensitive: false)
.hashData(target_chat_id)) {
var search_public_chat = await callApiInvoke(
parameters: {
"@type": "searchPublicChat",
"username": (target_chat_id)
.replaceAll(RegExp(r"@", caseSensitive: false), ""),
},
is_invoke_no_relevance: true,
);
if (search_public_chat["@type"] == "chat") {
parameters["chat_id"] = search_public_chat["id"];
} else {
return search_public_chat;
}
}
Map request_parameters = {
"@type": "sendChatAction",
"chat_id": parameters["chat_id"],
"action": {
"@type": "chatActionTyping",
}
};
if (parameters["action"] is String == false) {
parameters["action"] = "";
}
String action_type = (parameters["action"]).toString();
if (action_type == "typing") {
request_parameters["action"]["@type"] = "chatActionTyping";
}
if (action_type == "play_game") {
request_parameters["action"]["@type"] = "chatActionStartPlayingGame";
}
if (action_type == "choose_contact") {
request_parameters["action"]["@type"] = "chatActionChoosingContact";
}
if (action_type == "record_voice") {
request_parameters["action"]["@type"] = "chatActionRecordingVoiceNote";
}
if (action_type == "choose_location") {
request_parameters["action"]["@type"] = "chatActionChoosingLocation";
}
if (action_type == "watch_animation") {
request_parameters["action"]["@type"] = "chatActionWatchingAnimations";
}
if (action_type == "choose_sticker") {
request_parameters["action"]["@type"] = "chatActionChoosingSticker";
}
if (action_type == "cancel") {
request_parameters["action"]["@type"] = "chatActionCancel";
}
if (parameters["progress"] is int) {
request_parameters["progress"] = parameters["progress"];
}
if (parameters["emoji"] is String) {
request_parameters["emoji"] = parameters["emoji"];
}
if (parameters["message_thread_id"] is int) {
request_parameters["message_thread_id"] =
(parameters["message_thread_id"]);
}
Map message_send = await callApiInvoke(
parameters: request_parameters,
);
return message_send;
}