1
0
mirror of https://github.com/InsanusMokrassar/TelegramBotAPI.git synced 2024-06-01 23:45:25 +00:00
tgbotapi/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/Replies.kt

382 lines
11 KiB
Kotlin
Raw Normal View History

2021-06-24 05:21:02 +00:00
package dev.inmo.tgbotapi.extensions.api.send
import dev.inmo.tgbotapi.bot.TelegramBot
import dev.inmo.tgbotapi.extensions.api.send.games.sendGame
import dev.inmo.tgbotapi.extensions.api.send.media.sendAnimation
import dev.inmo.tgbotapi.extensions.api.send.media.sendAudio
import dev.inmo.tgbotapi.requests.abstracts.InputFile
import dev.inmo.tgbotapi.types.*
import dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSourcesList
import dev.inmo.tgbotapi.types.ParseMode.ParseMode
import dev.inmo.tgbotapi.types.buttons.KeyboardMarkup
import dev.inmo.tgbotapi.types.dice.DiceAnimationType
import dev.inmo.tgbotapi.types.files.AnimationFile
import dev.inmo.tgbotapi.types.files.AudioFile
import dev.inmo.tgbotapi.types.games.Game
import dev.inmo.tgbotapi.types.location.StaticLocation
import dev.inmo.tgbotapi.types.message.abstracts.Message
import dev.inmo.tgbotapi.types.venue.Venue
// Contact
suspend inline fun TelegramBot.reply(
to: Message,
phoneNumber: String,
firstName: String,
lastName: String? = null,
disableNotification: Boolean = false,
allowSendingWithoutReply: Boolean? = null,
replyMarkup: KeyboardMarkup? = null
) = sendContact(
to.chat,
phoneNumber,
firstName,
lastName,
disableNotification,
to.messageId,
allowSendingWithoutReply,
replyMarkup
)
suspend inline fun TelegramBot.reply(
to: Message,
contact: Contact,
disableNotification: Boolean = false,
allowSendingWithoutReply: Boolean? = null,
replyMarkup: KeyboardMarkup? = null
) = sendContact(
to.chat,
contact,
disableNotification,
to.messageId,
allowSendingWithoutReply,
replyMarkup
)
// Dice
suspend inline fun TelegramBot.replyWithDice(
to: Message,
animationType: DiceAnimationType? = null,
disableNotification: Boolean = false,
allowSendingWithoutReply: Boolean? = null,
replyMarkup: KeyboardMarkup? = null
) = sendDice(to.chat, animationType, disableNotification, to.messageId, allowSendingWithoutReply, replyMarkup)
suspend inline fun TelegramBot.reply(
to: Message,
animationType: DiceAnimationType,
disableNotification: Boolean = false,
allowSendingWithoutReply: Boolean? = null,
replyMarkup: KeyboardMarkup? = null
) = replyWithDice(to, animationType, disableNotification, allowSendingWithoutReply, replyMarkup)
// Location
suspend inline fun TelegramBot.reply(
to: Message,
latitude: Double,
longitude: Double,
disableNotification: Boolean = false,
replyMarkup: KeyboardMarkup? = null
) = sendLocation(
to.chat,
latitude,
longitude,
disableNotification,
to.messageId,
replyMarkup
)
suspend inline fun TelegramBot.reply(
to: Message,
location: StaticLocation,
disableNotification: Boolean = false,
replyMarkup: KeyboardMarkup? = null
) = sendLocation(
to.chat,
location,
disableNotification,
to.messageId,
replyMarkup
)
// Text message
suspend inline fun TelegramBot.reply(
to: Message,
text: String,
parseMode: ParseMode? = null,
disableWebPagePreview: Boolean? = null,
disableNotification: Boolean = false,
allowSendingWithoutReply: Boolean? = null,
replyMarkup: KeyboardMarkup? = null
) = sendTextMessage(
to.chat,
text,
parseMode,
disableWebPagePreview,
disableNotification,
to.messageId,
allowSendingWithoutReply,
replyMarkup
)
suspend inline fun TelegramBot.reply(
to: Message,
entities: TextSourcesList,
disableWebPagePreview: Boolean? = null,
disableNotification: Boolean = false,
allowSendingWithoutReply: Boolean? = null,
replyMarkup: KeyboardMarkup? = null
) = sendTextMessage(
to.chat,
entities,
disableWebPagePreview,
disableNotification,
to.messageId,
allowSendingWithoutReply,
replyMarkup
)
// Venue
suspend inline fun TelegramBot.reply(
to: Message,
latitude: Double,
longitude: Double,
title: String,
address: String,
foursquareId: FoursquareId? = null,
foursquareType: FoursquareType? = null,
googlePlaceId: GooglePlaceId? = null,
googlePlaceType: GooglePlaceType? = null,
disableNotification: Boolean = false,
allowSendingWithoutReply: Boolean? = null,
replyMarkup: KeyboardMarkup? = null
) = sendVenue(
chat = to.chat,
latitude = latitude,
longitude = longitude,
title = title,
address = address,
foursquareId = foursquareId,
foursquareType = foursquareType,
googlePlaceId = googlePlaceId,
googlePlaceType = googlePlaceType,
disableNotification = disableNotification,
replyToMessageId = to.messageId,
allowSendingWithoutReply = allowSendingWithoutReply,
replyMarkup = replyMarkup
)
suspend inline fun TelegramBot.reply(
to: Message,
location: StaticLocation,
title: String,
address: String,
foursquareId: FoursquareId? = null,
foursquareType: FoursquareType? = null,
googlePlaceId: GooglePlaceId? = null,
googlePlaceType: GooglePlaceType? = null,
disableNotification: Boolean = false,
allowSendingWithoutReply: Boolean? = null,
replyMarkup: KeyboardMarkup? = null
) = sendVenue(
chat = to.chat,
latitude = location.latitude,
longitude = location.longitude,
title = title,
address = address,
foursquareId = foursquareId,
foursquareType = foursquareType,
googlePlaceId = googlePlaceId,
googlePlaceType = googlePlaceType,
disableNotification = disableNotification,
replyToMessageId = to.messageId,
allowSendingWithoutReply = allowSendingWithoutReply,
replyMarkup = replyMarkup
)
suspend inline fun TelegramBot.reply(
to: Message,
venue: Venue,
disableNotification: Boolean = false,
allowSendingWithoutReply: Boolean? = null,
replyMarkup: KeyboardMarkup? = null
) = sendVenue(
chat = to.chat,
venue = venue,
disableNotification = disableNotification,
replyToMessageId = to.messageId,
allowSendingWithoutReply = allowSendingWithoutReply,
replyMarkup = replyMarkup
)
// Game
suspend inline fun TelegramBot.replyWithGame(
to: Message,
gameShortName: String,
disableNotification: Boolean = false,
allowSendingWithoutReply: Boolean? = null,
replyMarkup: KeyboardMarkup? = null
) = sendGame(
to.chat, gameShortName, disableNotification, to.messageId, allowSendingWithoutReply, replyMarkup
)
suspend inline fun TelegramBot.replyWithGame(
to: Message,
game: Game,
disableNotification: Boolean = false,
allowSendingWithoutReply: Boolean? = null,
replyMarkup: KeyboardMarkup? = null
) = sendGame(
to.chat, game.title, disableNotification, to.messageId, allowSendingWithoutReply, replyMarkup
)
suspend inline fun TelegramBot.reply(
to: Message,
game: Game,
disableNotification: Boolean = false,
allowSendingWithoutReply: Boolean? = null,
replyMarkup: KeyboardMarkup? = null
) = replyWithGame(to, game, disableNotification, allowSendingWithoutReply, replyMarkup)
// Animation
suspend inline fun TelegramBot.replyWithAnimation(
to: Message,
animation: InputFile,
thumb: InputFile? = null,
text: String? = null,
parseMode: ParseMode? = null,
duration: Long? = null,
width: Int? = null,
height: Int? = null,
disableNotification: Boolean = false,
allowSendingWithoutReply: Boolean? = null,
replyMarkup: KeyboardMarkup? = null
) = sendAnimation(
to.chat,
animation,
thumb,
text,
parseMode,
duration,
width,
height,
disableNotification,
to.messageId,
allowSendingWithoutReply,
replyMarkup
)
suspend inline fun TelegramBot.reply(
to: Message,
animation: AnimationFile,
text: String? = null,
parseMode: ParseMode? = null,
duration: Long? = null,
width: Int? = null,
height: Int? = null,
disableNotification: Boolean = false,
allowSendingWithoutReply: Boolean? = null,
replyMarkup: KeyboardMarkup? = null
) = sendAnimation(to.chat, animation, text, parseMode, duration, width, height, disableNotification, to.messageId, allowSendingWithoutReply, replyMarkup)
suspend inline fun TelegramBot.replyWithAnimation(
to: Message,
animation: InputFile,
entities: TextSourcesList,
thumb: InputFile? = null,
duration: Long? = null,
width: Int? = null,
height: Int? = null,
disableNotification: Boolean = false,
allowSendingWithoutReply: Boolean? = null,
replyMarkup: KeyboardMarkup? = null
) = sendAnimation(
to.chat,
animation,
thumb,
entities,
duration,
width,
height,
disableNotification,
to.messageId,
allowSendingWithoutReply,
replyMarkup
)
suspend inline fun TelegramBot.reply(
to: Message,
animation: AnimationFile,
entities: TextSourcesList,
duration: Long? = null,
width: Int? = null,
height: Int? = null,
disableNotification: Boolean = false,
allowSendingWithoutReply: Boolean? = null,
replyMarkup: KeyboardMarkup? = null
) = sendAnimation(to.chat, animation, entities, duration, width, height, disableNotification, to.messageId, allowSendingWithoutReply, replyMarkup)
// Audio
suspend inline fun TelegramBot.replyWithAudio(
to: Message,
audio: InputFile,
thumb: InputFile? = null,
text: String? = null,
parseMode: ParseMode? = null,
duration: Long? = null,
performer: String? = null,
title: String? = null,
disableNotification: Boolean = false,
allowSendingWithoutReply: Boolean? = null,
replyMarkup: KeyboardMarkup? = null
) = sendAudio(to.chat, audio, thumb, text, parseMode, duration, performer, title, disableNotification, to.messageId, allowSendingWithoutReply, replyMarkup)
suspend inline fun TelegramBot.reply(
to: Message,
audio: AudioFile,
text: String? = null,
parseMode: ParseMode? = null,
title: String? = null,
disableNotification: Boolean = false,
allowSendingWithoutReply: Boolean? = null,
replyMarkup: KeyboardMarkup? = null
) = sendAudio(to.chat, audio, text, parseMode, title, disableNotification, to.messageId, allowSendingWithoutReply, replyMarkup)
suspend inline fun TelegramBot.replyWithAudio(
to: Message,
audio: InputFile,
thumb: InputFile? = null,
entities: TextSourcesList,
duration: Long? = null,
performer: String? = null,
title: String? = null,
disableNotification: Boolean = false,
allowSendingWithoutReply: Boolean? = null,
replyMarkup: KeyboardMarkup? = null
) = sendAudio(to.chat, audio, thumb, entities, duration, performer, title, disableNotification, to.messageId, allowSendingWithoutReply, replyMarkup)
suspend inline fun TelegramBot.reply(
to: Message,
audio: AudioFile,
entities: TextSourcesList,
title: String? = null,
disableNotification: Boolean = false,
allowSendingWithoutReply: Boolean? = null,
replyMarkup: KeyboardMarkup? = null
) = sendAudio(to.chat, audio, entities, title, disableNotification, to.messageId, allowSendingWithoutReply, replyMarkup)