request method
Future<Map>
request({
- required Map parameters,
- required TelegramClientData telegramClientData,
- bool is_return_as_api = true,
- bool is_form = false,
- String? urlApi,
- String? clientType,
- void onUploadProgress()?,
- bool isVoid = false,
- bool? isUseCache,
- Duration? durationCacheExpire,
- Duration? delayDuration,
- Duration? invokeTimeOut,
- String? extra,
- bool? isAutoGetChat,
- bool isInvokeThrowOnError = true,
- bool isAutoExtendMessage = false,
- FutureOr<
String> onGenerateExtraInvoke()?, - FutureOr<
Map> onGetInvokeData()?,
return original data json
Implementation
Future<Map> request({
required Map parameters,
required TelegramClientData telegramClientData,
bool is_return_as_api = true,
bool is_form = false,
String? urlApi,
String? clientType,
void Function(int bytes, int bytess)? onUploadProgress,
bool isVoid = false,
bool? isUseCache,
Duration? durationCacheExpire,
Duration? delayDuration,
Duration? invokeTimeOut,
String? extra,
bool? isAutoGetChat,
bool isInvokeThrowOnError = true,
bool isAutoExtendMessage = false,
FutureOr<String> Function(int client_id, TdlibBase libTdJson)?
onGenerateExtraInvoke,
FutureOr<Map<dynamic, dynamic>> Function(
String, int client_id, TdlibBase libTdJson)?
onGetInvokeData,
}) async {
if (telegramClientData.telegramClientType != TelegramClientType.tdlib) {
return await invoke(
parameters: parameters,
telegramClientData: telegramClientData,
is_form: is_form,
urlApi: urlApi,
clientType: clientType,
onUploadProgress: onUploadProgress,
isVoid: isVoid,
isUseCache: isUseCache,
durationCacheExpire: durationCacheExpire,
delayDuration: delayDuration,
invokeTimeOut: invokeTimeOut,
extra: extra,
isAutoGetChat: isAutoGetChat,
isAutoExtendMessage: isAutoExtendMessage,
isInvokeThrowOnError: isInvokeThrowOnError,
onGenerateExtraInvoke: onGenerateExtraInvoke,
onGetInvokeData: onGetInvokeData,
);
}
final String method = (parameters["@type"] as String);
/// return original data json
FutureOr<Map> callApiInvoke({
required Map parameters,
bool? is_invoke_no_relevance,
bool? is_use_cache,
Duration? duration_cache_expire,
}) async {
return await invoke(
parameters: parameters,
telegramClientData: telegramClientData,
is_form: is_form,
urlApi: urlApi,
isUseCache: is_use_cache ?? isUseCache,
durationCacheExpire: duration_cache_expire ?? durationCacheExpire,
clientType: clientType,
onUploadProgress: onUploadProgress,
isVoid: (is_invoke_no_relevance == true) ? false : isVoid,
delayDuration: delayDuration,
invokeTimeOut: invokeTimeOut,
extra: (is_invoke_no_relevance == true) ? null : extra,
isAutoGetChat: isAutoGetChat,
isInvokeThrowOnError: isInvokeThrowOnError,
onGenerateExtraInvoke: onGenerateExtraInvoke,
onGetInvokeData: onGetInvokeData,
);
}
if (RegExp(r"^(answerCallbackQuery)$", caseSensitive: false)
.hasMatch(method)) {
return requestReturnAsApi(
is_return_as_api: is_return_as_api,
result: await answerCallbackQuery(
parameters: parameters,
callApiInvoke: callApiInvoke,
),
);
}
if (RegExp(r"^(answerInlineQuery)$", caseSensitive: false)
.hasMatch(method)) {
return requestReturnAsApi(
is_return_as_api: is_return_as_api,
result: await answerInlineQuery(
parameters: parameters,
callApiInvoke: callApiInvoke,
),
);
}
if (RegExp(r"^(banChatMember)$", caseSensitive: false).hasMatch(method)) {
return requestReturnAsApi(
is_return_as_api: is_return_as_api,
result: await banChatMember(
parameters: parameters,
callApiInvoke: callApiInvoke,
),
);
}
if (RegExp(r"^(banChatSenderChat)$", caseSensitive: false)
.hasMatch(method)) {
return requestReturnAsApi(
is_return_as_api: is_return_as_api,
result: await banChatSenderChat(
parameters: parameters,
callApiInvoke: callApiInvoke,
),
);
}
if (RegExp(r"^(copyMessage)$", caseSensitive: false).hasMatch(method)) {
return requestReturnAsApi(
is_return_as_api: is_return_as_api,
result: await copyMessage(
parameters: parameters,
callApiInvoke: callApiInvoke,
telegramClientData: telegramClientData,
),
);
}
if (RegExp(r"^(createInvoiceLink)$", caseSensitive: false)
.hasMatch(method)) {
return requestReturnAsApi(
is_return_as_api: is_return_as_api,
result: await createInvoiceLink(
parameters: parameters,
callApiInvoke: callApiInvoke,
),
);
}
if (RegExp(r"^(deleteMessage)$", caseSensitive: false).hasMatch(method)) {
return requestReturnAsApi(
is_return_as_api: is_return_as_api,
result: await deleteMessage(
parameters: parameters,
callApiInvoke: callApiInvoke,
),
);
}
if (RegExp(r"^(deleteMessages)$", caseSensitive: false).hasMatch(method)) {
return requestReturnAsApi(
is_return_as_api: is_return_as_api,
result: await deleteMessages(
parameters: parameters,
callApiInvoke: callApiInvoke,
),
);
}
if (RegExp(r"^(editMessageText)$", caseSensitive: false).hasMatch(method)) {
return requestReturnAsApi(
is_return_as_api: is_return_as_api,
result: await editMessageText(
parameters: parameters,
callApiInvoke: callApiInvoke,
telegramClientData: telegramClientData,
),
);
}
if (RegExp(r"^(editMessageCaption)$", caseSensitive: false)
.hasMatch(method)) {
return requestReturnAsApi(
is_return_as_api: is_return_as_api,
result: await editMessageCaption(
parameters: parameters,
callApiInvoke: callApiInvoke,
telegramClientData: telegramClientData,
),
);
}
if (RegExp(r"^(editMessageMedia)$", caseSensitive: false)
.hasMatch(method)) {
return requestReturnAsApi(
is_return_as_api: is_return_as_api,
result: await editMessageMedia(
parameters: parameters,
callApiInvoke: callApiInvoke,
telegramClientData: telegramClientData,
),
);
}
if (RegExp(r"^(editMessageReplyMarkup)$", caseSensitive: false)
.hasMatch(method)) {
return requestReturnAsApi(
is_return_as_api: is_return_as_api,
result: await editMessageReplyMarkup(
parameters: parameters,
callApiInvoke: callApiInvoke,
telegramClientData: telegramClientData,
),
);
}
if (RegExp(r"^(forwardMessage)$", caseSensitive: false).hasMatch(method)) {
return requestReturnAsApi(
is_return_as_api: is_return_as_api,
result: await forwardMessage(
parameters: parameters,
callApiInvoke: callApiInvoke,
telegramClientData: telegramClientData,
),
);
}
if (RegExp(r"^(getChatAdministrators)$", caseSensitive: false)
.hasMatch(method)) {
return requestReturnAsApi(
is_return_as_api: is_return_as_api,
result: await getChatAdministrators(
parameters: parameters,
callApiInvoke: callApiInvoke,
),
);
}
if (RegExp(r"^(getChatMember)$", caseSensitive: false).hasMatch(method)) {
return requestReturnAsApi(
is_return_as_api: is_return_as_api,
result: await getChatMember(
parameters: parameters,
callApiInvoke: callApiInvoke,
),
);
}
if (RegExp(r"^(getChat)$", caseSensitive: false).hasMatch(method)) {
return requestReturnAsApi(
is_return_as_api: is_return_as_api,
result: await getChat(
parameters: parameters,
callApiInvoke: callApiInvoke,
),
);
}
if (RegExp(r"^(getMe)$", caseSensitive: false).hasMatch(method)) {
return requestReturnAsApi(
is_return_as_api: is_return_as_api,
result: await getMe(
parameters: parameters,
callApiInvoke: callApiInvoke,
),
);
}
if (RegExp(r"^(getUser)$", caseSensitive: false).hasMatch(method)) {
return requestReturnAsApi(
is_return_as_api: is_return_as_api,
result: await getUser(
parameters: parameters,
callApiInvoke: callApiInvoke,
),
);
}
if (RegExp(r"^(joinChat)$", caseSensitive: false).hasMatch(method)) {
return requestReturnAsApi(
is_return_as_api: is_return_as_api,
result: await joinChat(
parameters: parameters,
callApiInvoke: callApiInvoke,
),
);
}
if (RegExp(r"^(reportMessage)$", caseSensitive: false).hasMatch(method)) {
return requestReturnAsApi(
is_return_as_api: is_return_as_api,
result: await reportMessage(
parameters: parameters,
callApiInvoke: callApiInvoke,
),
);
}
if (RegExp(r"^(reportMessages)$", caseSensitive: false).hasMatch(method)) {
return requestReturnAsApi(
is_return_as_api: is_return_as_api,
result: await reportMessages(
parameters: parameters,
callApiInvoke: callApiInvoke,
),
);
}
if (RegExp(r"^(sendAnimation)$", caseSensitive: false).hasMatch(method)) {
return requestReturnAsApi(
is_return_as_api: is_return_as_api,
result: await sendAnimation(
parameters: parameters,
callApiInvoke: callApiInvoke,
telegramClientData: telegramClientData,
),
);
}
if (RegExp(r"^(sendAudio)$", caseSensitive: false).hasMatch(method)) {
return requestReturnAsApi(
is_return_as_api: is_return_as_api,
result: await sendAudio(
parameters: parameters,
callApiInvoke: callApiInvoke,
telegramClientData: telegramClientData,
),
);
}
if (RegExp(r"^(sendChatAction)$", caseSensitive: false).hasMatch(method)) {
return requestReturnAsApi(
is_return_as_api: is_return_as_api,
result: await sendChatAction(
parameters: parameters,
callApiInvoke: callApiInvoke,
),
);
}
if (RegExp(r"^(sendChatScreenshotTakenNotification)$", caseSensitive: false)
.hasMatch(method)) {
return requestReturnAsApi(
is_return_as_api: is_return_as_api,
result: await sendChatScreenshotTakenNotification(
parameters: parameters,
callApiInvoke: callApiInvoke,
),
);
}
if (RegExp(r"^(sendContact)$", caseSensitive: false).hasMatch(method)) {
return requestReturnAsApi(
is_return_as_api: is_return_as_api,
result: await sendContact(
parameters: parameters,
callApiInvoke: callApiInvoke,
telegramClientData: telegramClientData,
),
);
}
if (RegExp(r"^(sendDice)$", caseSensitive: false).hasMatch(method)) {
return requestReturnAsApi(
is_return_as_api: is_return_as_api,
result: await sendDice(
parameters: parameters,
callApiInvoke: callApiInvoke,
telegramClientData: telegramClientData,
),
);
}
if (RegExp(r"^(sendDocument)$", caseSensitive: false).hasMatch(method)) {
return requestReturnAsApi(
is_return_as_api: is_return_as_api,
result: await sendDocument(
parameters: parameters,
callApiInvoke: callApiInvoke,
telegramClientData: telegramClientData,
),
);
}
if (RegExp(r"^(sendGame)$", caseSensitive: false).hasMatch(method)) {
return requestReturnAsApi(
is_return_as_api: is_return_as_api,
result: await sendGame(
parameters: parameters,
callApiInvoke: callApiInvoke,
telegramClientData: telegramClientData,
),
);
}
if (RegExp(r"^(sendInvoice)$", caseSensitive: false).hasMatch(method)) {
return requestReturnAsApi(
is_return_as_api: is_return_as_api,
result: await sendInvoice(
parameters: parameters,
callApiInvoke: callApiInvoke,
telegramClientData: telegramClientData,
),
);
}
if (RegExp(r"^(sendLocation)$", caseSensitive: false).hasMatch(method)) {
return requestReturnAsApi(
is_return_as_api: is_return_as_api,
result: await sendLocation(
parameters: parameters,
callApiInvoke: callApiInvoke,
telegramClientData: telegramClientData,
),
);
}
if (RegExp(r"^(sendMediaGroup)$", caseSensitive: false).hasMatch(method)) {
return requestReturnAsApi(
is_return_as_api: is_return_as_api,
result: await sendMediaGroup(
parameters: parameters,
callApiInvoke: callApiInvoke,
telegramClientData: telegramClientData,
),
);
}
if (RegExp(r"^(sendMessage)$", caseSensitive: false).hasMatch(method)) {
return requestReturnAsApi(
is_return_as_api: is_return_as_api,
result: await sendMessage(
parameters: parameters,
callApiInvoke: callApiInvoke,
telegramClientData: telegramClientData,
),
);
}
if (RegExp(r"^(sendPhoto)$", caseSensitive: false).hasMatch(method)) {
return requestReturnAsApi(
is_return_as_api: is_return_as_api,
result: await sendPhoto(
parameters: parameters,
callApiInvoke: callApiInvoke,
telegramClientData: telegramClientData,
),
);
}
if (RegExp(r"^(sendPoll)$", caseSensitive: false).hasMatch(method)) {
return requestReturnAsApi(
is_return_as_api: is_return_as_api,
result: await sendPoll(
parameters: parameters,
callApiInvoke: callApiInvoke,
telegramClientData: telegramClientData,
),
);
}
if (RegExp(r"^(sendSticker)$", caseSensitive: false).hasMatch(method)) {
return requestReturnAsApi(
is_return_as_api: is_return_as_api,
result: await sendSticker(
parameters: parameters,
callApiInvoke: callApiInvoke,
telegramClientData: telegramClientData,
),
);
}
if (RegExp(r"^(sendVenue)$", caseSensitive: false).hasMatch(method)) {
return requestReturnAsApi(
is_return_as_api: is_return_as_api,
result: await sendVenue(
parameters: parameters,
callApiInvoke: callApiInvoke,
telegramClientData: telegramClientData,
),
);
}
if (RegExp(r"^(sendVideoNote)$", caseSensitive: false).hasMatch(method)) {
return requestReturnAsApi(
is_return_as_api: is_return_as_api,
result: await sendVideoNote(
parameters: parameters,
callApiInvoke: callApiInvoke,
telegramClientData: telegramClientData,
),
);
}
if (RegExp(r"^(sendVideo)$", caseSensitive: false).hasMatch(method)) {
return requestReturnAsApi(
is_return_as_api: is_return_as_api,
result: await sendVideo(
parameters: parameters,
callApiInvoke: callApiInvoke,
telegramClientData: telegramClientData,
),
);
}
if (RegExp(r"^(sendVoice)$", caseSensitive: false).hasMatch(method)) {
return requestReturnAsApi(
is_return_as_api: is_return_as_api,
result: await sendVoice(
parameters: parameters,
callApiInvoke: callApiInvoke,
telegramClientData: telegramClientData,
),
);
}
if (RegExp(r"^(pinChatMessage)$", caseSensitive: false).hasMatch(method)) {
return requestReturnAsApi(
is_return_as_api: is_return_as_api,
result: await pinChatMessage(
parameters: parameters,
callApiInvoke: callApiInvoke,
),
);
}
if (RegExp(r"^(unPinAllChatMessages)$", caseSensitive: false)
.hasMatch(method)) {
return requestReturnAsApi(
is_return_as_api: is_return_as_api,
result: await unPinAllChatMessages(
parameters: parameters,
callApiInvoke: callApiInvoke,
),
);
}
if (RegExp(r"^(unPinChatMessage)$", caseSensitive: false)
.hasMatch(method)) {
return requestReturnAsApi(
is_return_as_api: is_return_as_api,
result: await unPinChatMessage(
parameters: parameters,
callApiInvoke: callApiInvoke,
),
);
}
if (RegExp(r"^(viewMessage)$", caseSensitive: false).hasMatch(method)) {
return requestReturnAsApi(
is_return_as_api: is_return_as_api,
result: await viewMessage(
parameters: parameters,
callApiInvoke: callApiInvoke,
),
);
}
if (RegExp(r"^(viewMessages)$", caseSensitive: false).hasMatch(method)) {
return requestReturnAsApi(
is_return_as_api: is_return_as_api,
result: await viewMessages(
parameters: parameters,
callApiInvoke: callApiInvoke,
),
);
}
final TelegramClientLibraryError error = TelegramClientLibraryError.create(
special_extra: "error",
code: 500,
message: "telegram_client_type_not_found",
description: "",
);
if (isInvokeThrowOnError == true) {
throw requestReturnAsApi(
is_return_as_api: is_return_as_api,
result: (error.rawData),
);
}
return requestReturnAsApi(
is_return_as_api: is_return_as_api,
result: (error.rawData),
);
}