Skip to content

Commit

Permalink
Telegram Bot API December 29, 2023 updates (v7.0)
Browse files Browse the repository at this point in the history
  • Loading branch information
johnspade committed Dec 31, 2023
1 parent b7a58b8 commit e0e7768
Show file tree
Hide file tree
Showing 78 changed files with 3,158 additions and 1,404 deletions.
3 changes: 0 additions & 3 deletions .scalafmt.conf
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@ maxColumn = 120
continuationIndent.defnSite = 2
assumeStandardLibraryStripMargin = true
danglingParentheses.preset = true
newlines.topLevelStatementBlankLines = [
{ blanks = 1 }
]
runner.dialect = scala3
project.git = true
project.excludePaths = [
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# F[Tg] - Telegramium

[![Telegram](https://img.shields.io/badge/Telegram%20Bot%20API-6.9%20(September%2022%2C%202023)-blue)](https://core.telegram.org/bots/api#recent-changes)
[![Telegram](https://img.shields.io/badge/Telegram%20Bot%20API-7.0%20(December%2029%2C%202023)-blue)](https://core.telegram.org/bots/api#recent-changes)
[![Scala Steward badge](https://img.shields.io/badge/Scala_Steward-helping-blue.svg?style=flat&logo=data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAA4AAAAQCAMAAAARSr4IAAAAVFBMVEUAAACHjojlOy5NWlrKzcYRKjGFjIbp293YycuLa3pYY2LSqql4f3pCUFTgSjNodYRmcXUsPD/NTTbjRS+2jomhgnzNc223cGvZS0HaSD0XLjbaSjElhIr+AAAAAXRSTlMAQObYZgAAAHlJREFUCNdNyosOwyAIhWHAQS1Vt7a77/3fcxxdmv0xwmckutAR1nkm4ggbyEcg/wWmlGLDAA3oL50xi6fk5ffZ3E2E3QfZDCcCN2YtbEWZt+Drc6u6rlqv7Uk0LdKqqr5rk2UCRXOk0vmQKGfc94nOJyQjouF9H/wCc9gECEYfONoAAAAASUVORK5CYII=)](https://scala-steward.org)
[![Maven Central](https://maven-badges.herokuapp.com/maven-central/io.github.apimorphism/telegramium-core_2.13/badge.svg)](https://maven-badges.herokuapp.com/maven-central/io.github.apimorphism/telegramium-core_2.13)

Expand Down
2 changes: 1 addition & 1 deletion build.sbt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
enablePlugins(GitPlugin)

ThisBuild / version := Version.mkVersion(
"8.69.0",
"8.70.0",
git.gitCurrentBranch.value,
git.gitDescribedVersion.value,
git.gitUncommittedChanges.value
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@ package telegramium.bots
* Global identifier, uniquely corresponding to the chat to which the message with the callback button was sent.
* Useful for high scores in games.
* @param message
* Optional. Message with the callback button that originated the query. Note that message content and message date
* will not be available if the message is too old
* Optional. Message sent by the bot with the callback button that originated the query
* @param inlineMessageId
* Optional. Identifier of the message sent via the bot in inline mode, that originated the query.
* @param data
Expand All @@ -27,7 +26,7 @@ final case class CallbackQuery(
id: String,
from: User,
chatInstance: String,
message: Option[Message] = Option.empty,
message: Option[MaybeInaccessibleMessage] = Option.empty,
inlineMessageId: Option[String] = Option.empty,
data: Option[String] = Option.empty,
gameShortName: Option[String] = Option.empty
Expand Down
31 changes: 28 additions & 3 deletions telegramium-core/src/main/scala/telegramium/bots/Chat.scala
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,27 @@ package telegramium.bots
* @param activeUsernames
* Optional. If non-empty, the list of all active chat usernames; for private chats, supergroups and channels.
* Returned only in getChat.
* @param availableReactions
* Optional. List of available reactions allowed in the chat. If omitted, then all emoji reactions are allowed.
* Returned only in getChat.
* @param accentColorId
* Optional. Identifier of the accent color for the chat name and backgrounds of the chat photo, reply header, and
* link preview. See accent colors for more details. Returned only in getChat. Always returned in getChat.
* @param backgroundCustomEmojiId
* Optional. Custom emoji identifier of emoji chosen by the chat for the reply header and link preview background.
* Returned only in getChat.
* @param profileAccentColorId
* Optional. Identifier of the accent color for the chat's profile background. See profile accent colors for more
* details. Returned only in getChat.
* @param profileBackgroundCustomEmojiId
* Optional. Custom emoji identifier of the emoji chosen by the chat for its profile background. Returned only in
* getChat.
* @param emojiStatusCustomEmojiId
* Optional. Custom emoji identifier of emoji status of the other party in a private chat. Returned only in getChat.
* @param emojiStatusExpirationDate
* Optional. Expiration date of the emoji status of the other party in a private chat in Unix time, if any. Returned
* Optional. Custom emoji identifier of the emoji status of the chat or the other party in a private chat. Returned
* only in getChat.
* @param emojiStatusExpirationDate
* Optional. Expiration date of the emoji status of the chat or the other party in a private chat, in Unix time, if
* any. Returned only in getChat.
* @param bio
* Optional. Bio of the other party in a private chat. Returned only in getChat.
* @param hasPrivateForwards
Expand Down Expand Up @@ -63,6 +79,9 @@ package telegramium.bots
* in getChat.
* @param hasProtectedContent
* Optional. True, if messages from the chat can't be forwarded to other chats. Returned only in getChat.
* @param hasVisibleHistory
* Optional. True, if new chat members will have access to old messages; available only to chat administrators.
* Returned only in getChat.
* @param stickerSetName
* Optional. For supergroups, name of group sticker set. Returned only in getChat.
* @param canSetStickerSet
Expand All @@ -85,6 +104,11 @@ final case class Chat(
isForum: Option[Boolean] = Option.empty,
photo: Option[ChatPhoto] = Option.empty,
activeUsernames: List[String] = List.empty,
availableReactions: List[ReactionType] = List.empty,
accentColorId: Option[Int] = Option.empty,
backgroundCustomEmojiId: Option[String] = Option.empty,
profileAccentColorId: Option[Int] = Option.empty,
profileBackgroundCustomEmojiId: Option[String] = Option.empty,
emojiStatusCustomEmojiId: Option[String] = Option.empty,
emojiStatusExpirationDate: Option[Int] = Option.empty,
bio: Option[String] = Option.empty,
Expand All @@ -101,6 +125,7 @@ final case class Chat(
hasAggressiveAntiSpamEnabled: Option[Boolean] = Option.empty,
hasHiddenMembers: Option[Boolean] = Option.empty,
hasProtectedContent: Option[Boolean] = Option.empty,
hasVisibleHistory: Option[Boolean] = Option.empty,
stickerSetName: Option[String] = Option.empty,
canSetStickerSet: Option[Boolean] = Option.empty,
linkedChatId: Option[Long] = Option.empty,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@ package telegramium.bots
* @param isAnonymous
* True, if the user's presence in the chat is hidden
* @param canManageChat
* True, if the administrator can access the chat event log, chat statistics, boost list in channels, message
* statistics in channels, see channel members, see anonymous administrators in supergroups and ignore slow mode.
* Implied by any other administrator privilege
* True, if the administrator can access the chat event log, boost list in channels, see channel members, report spam
* messages, see anonymous administrators in supergroups and ignore slow mode. Implied by any other administrator
* privilege
* @param canDeleteMessages
* True, if the administrator can delete messages of other users
* @param canManageVideoChats
* True, if the administrator can manage video chats
* @param canRestrictMembers
* True, if the administrator can restrict, ban or unban chat members
* True, if the administrator can restrict, ban or unban chat members, or access supergroup statistics
* @param canPromoteMembers
* True, if the administrator can add new administrators with a subset of their own privileges or demote
* administrators that they have promoted, directly or indirectly (promoted by administrators that were appointed by
Expand All @@ -23,7 +23,7 @@ package telegramium.bots
* @param canInviteUsers
* True, if the user is allowed to invite new users to the chat
* @param canPostMessages
* Optional. True, if the administrator can post messages in the channel; channels only
* Optional. True, if the administrator can post messages in the channel, or access channel statistics; channels only
* @param canEditMessages
* Optional. True, if the administrator can edit messages of other users and can pin messages; channels only
* @param canPinMessages
Expand Down
15 changes: 15 additions & 0 deletions telegramium-core/src/main/scala/telegramium/bots/ChatBoost.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package telegramium.bots

/** This object contains information about a chat boost.
*
* @param boostId
* Unique identifier of the boost
* @param addDate
* Point in time (Unix timestamp) when the chat was boosted
* @param expirationDate
* Point in time (Unix timestamp) when the boost will automatically expire, unless the booster's Telegram Premium
* subscription is prolonged
* @param source
* Source of the added boost
*/
final case class ChatBoost(boostId: String, addDate: Int, expirationDate: Int, source: ChatBoostSource)
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package telegramium.bots

/** This object represents a boost removed from a chat.
*
* @param chat
* Chat which was boosted
* @param boostId
* Unique identifier of the boost
* @param removeDate
* Point in time (Unix timestamp) when the boost was removed
* @param source
* Source of the removed boost
*/
final case class ChatBoostRemoved(chat: Chat, boostId: String, removeDate: Int, source: ChatBoostSource)
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
package telegramium.bots

sealed trait ChatBoostSource {}

/** The boost was obtained by the creation of Telegram Premium gift codes to boost a chat. Each such code boosts the
* chat 4 times for the duration of the corresponding Telegram Premium subscription.
*
* @param source
* Source of the boost, always “gift_code”
* @param user
* User for which the gift code was created
*/
final case class ChatBoostSourceGiftCode(source: String, user: User) extends ChatBoostSource

/** The boost was obtained by the creation of a Telegram Premium giveaway. This boosts the chat 4 times for the duration
* of the corresponding Telegram Premium subscription.
*
* @param source
* Source of the boost, always “giveaway”
* @param giveawayMessageId
* Identifier of a message in the chat with the giveaway; the message could have been deleted already. May be 0 if
* the message isn't sent yet.
* @param user
* Optional. User that won the prize in the giveaway if any
* @param isUnclaimed
* Optional. True, if the giveaway was completed, but there was no user to win the prize
*/
final case class ChatBoostSourceGiveaway(
source: String,
giveawayMessageId: Int,
user: Option[User] = Option.empty,
isUnclaimed: Option[Boolean] = Option.empty
) extends ChatBoostSource

/** The boost was obtained by subscribing to Telegram Premium or by gifting a Telegram Premium subscription to another
* user.
*
* @param source
* Source of the boost, always “premium”
* @param user
* User that boosted the chat
*/
final case class ChatBoostSourcePremium(source: String, user: User) extends ChatBoostSource
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package telegramium.bots

/** This object represents a boost added to a chat or changed.
*
* @param chat
* Chat which was boosted
* @param boost
* Infomation about the chat boost
*/
final case class ChatBoostUpdated(chat: Chat, boost: ChatBoost)
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ package telegramium.bots
* Identifier of a private chat with the user who sent the join request. This number may have more than 32
* significant bits and some programming languages may have difficulty/silent defects in interpreting it. But it has
* at most 52 significant bits, so a 64-bit integer or double-precision float type are safe for storing this
* identifier. The bot can use this identifier for 24 hours to send messages until the join request is processed,
* identifier. The bot can use this identifier for 5 minutes to send messages until the join request is processed,
* assuming no other administrator contacted the user.
* @param date
* Date the request was sent in Unix time
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,15 @@ final case class ChatMemberOwner(
* @param isAnonymous
* True, if the user's presence in the chat is hidden
* @param canManageChat
* True, if the administrator can access the chat event log, chat statistics, boost list in channels, message
* statistics in channels, see channel members, see anonymous administrators in supergroups and ignore slow mode.
* Implied by any other administrator privilege
* True, if the administrator can access the chat event log, boost list in channels, see channel members, report spam
* messages, see anonymous administrators in supergroups and ignore slow mode. Implied by any other administrator
* privilege
* @param canDeleteMessages
* True, if the administrator can delete messages of other users
* @param canManageVideoChats
* True, if the administrator can manage video chats
* @param canRestrictMembers
* True, if the administrator can restrict, ban or unban chat members
* True, if the administrator can restrict, ban or unban chat members, or access supergroup statistics
* @param canPromoteMembers
* True, if the administrator can add new administrators with a subset of their own privileges or demote
* administrators that they have promoted, directly or indirectly (promoted by administrators that were appointed by
Expand All @@ -49,7 +49,7 @@ final case class ChatMemberOwner(
* @param canInviteUsers
* True, if the user is allowed to invite new users to the chat
* @param canPostMessages
* Optional. True, if the administrator can post messages in the channel; channels only
* Optional. True, if the administrator can post messages in the channel, or access channel statistics; channels only
* @param canEditMessages
* Optional. True, if the administrator can edit messages of other users and can pin messages; channels only
* @param canPinMessages
Expand Down Expand Up @@ -125,7 +125,8 @@ final case class ChatMemberBanned(status: String, user: User, untilDate: Int) ex
* @param isMember
* True, if the user is a member of the chat at the moment of the request
* @param canSendMessages
* True, if the user is allowed to send text messages, contacts, invoices, locations and venues
* True, if the user is allowed to send text messages, contacts, giveaways, giveaway winners, invoices, locations and
* venues
* @param canSendAudios
* True, if the user is allowed to send audios
* @param canSendDocuments
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ package telegramium.bots
/** Describes actions that a non-administrator user is allowed to take in a chat.
*
* @param canSendMessages
* Optional. True, if the user is allowed to send text messages, contacts, invoices, locations and venues
* Optional. True, if the user is allowed to send text messages, contacts, giveaways, giveaway winners, invoices,
* locations and venues
* @param canSendAudios
* Optional. True, if the user is allowed to send audios
* @param canSendDocuments
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
package telegramium.bots

/** This object contains information about a message that is being replied to, which may come from another chat or forum
* topic.
*
* @param origin
* Origin of the message replied to by the given message
* @param chat
* Optional. Chat the original message belongs to. Available only if the chat is a supergroup or a channel.
* @param messageId
* Optional. Unique message identifier inside the original chat. Available only if the original chat is a supergroup
* or a channel.
* @param linkPreviewOptions
* Optional. Options used for link preview generation for the original message, if it is a text message
* @param animation
* Optional. Message is an animation, information about the animation
* @param audio
* Optional. Message is an audio file, information about the file
* @param document
* Optional. Message is a general file, information about the file
* @param photo
* Optional. Message is a photo, available sizes of the photo
* @param sticker
* Optional. Message is a sticker, information about the sticker
* @param story
* Optional. Message is a forwarded story
* @param video
* Optional. Message is a video, information about the video
* @param videoNote
* Optional. Message is a video note, information about the video message
* @param voice
* Optional. Message is a voice message, information about the file
* @param hasMediaSpoiler
* Optional. True, if the message media is covered by a spoiler animation
* @param contact
* Optional. Message is a shared contact, information about the contact
* @param dice
* Optional. Message is a dice with random value
* @param game
* Optional. Message is a game, information about the game.
* @param giveaway
* Optional. Message is a scheduled giveaway, information about the giveaway
* @param giveawayWinners
* Optional. A giveaway with public winners was completed
* @param invoice
* Optional. Message is an invoice for a payment, information about the invoice.
* @param location
* Optional. Message is a shared location, information about the location
* @param poll
* Optional. Message is a native poll, information about the poll
* @param venue
* Optional. Message is a venue, information about the venue
*/
final case class ExternalReplyInfo(
origin: MessageOrigin,
chat: Option[Chat] = Option.empty,
messageId: Option[Int] = Option.empty,
linkPreviewOptions: Option[LinkPreviewOptions] = Option.empty,
animation: Option[Animation] = Option.empty,
audio: Option[Audio] = Option.empty,
document: Option[Document] = Option.empty,
photo: List[PhotoSize] = List.empty,
sticker: Option[Sticker] = Option.empty,
story: Option[Story.type] = Option.empty,
video: Option[Video] = Option.empty,
videoNote: Option[VideoNote] = Option.empty,
voice: Option[Voice] = Option.empty,
hasMediaSpoiler: Option[Boolean] = Option.empty,
contact: Option[Contact] = Option.empty,
dice: Option[Dice] = Option.empty,
game: Option[Game] = Option.empty,
giveaway: Option[Giveaway] = Option.empty,
giveawayWinners: Option[GiveawayWinners] = Option.empty,
invoice: Option[Invoice] = Option.empty,
location: Option[Location] = Option.empty,
poll: Option[Poll] = Option.empty,
venue: Option[Venue] = Option.empty
)
33 changes: 33 additions & 0 deletions telegramium-core/src/main/scala/telegramium/bots/Giveaway.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package telegramium.bots

/** This object represents a message about a scheduled giveaway.
*
* @param winnersSelectionDate
* Point in time (Unix timestamp) when winners of the giveaway will be selected
* @param winnerCount
* The number of users which are supposed to be selected as winners of the giveaway
* @param chats
* The list of chats which the user must join to participate in the giveaway
* @param onlyNewMembers
* Optional. True, if only users who join the chats after the giveaway started should be eligible to win
* @param hasPublicWinners
* Optional. True, if the list of giveaway winners will be visible to everyone
* @param prizeDescription
* Optional. Description of additional giveaway prize
* @param countryCodes
* Optional. A list of two-letter ISO 3166-1 alpha-2 country codes indicating the countries from which eligible users
* for the giveaway must come. If empty, then all users can participate in the giveaway. Users with a phone number
* that was bought on Fragment can always participate in giveaways.
* @param premiumSubscriptionMonthCount
* Optional. The number of months the Telegram Premium subscription won from the giveaway will be active for
*/
final case class Giveaway(
winnersSelectionDate: Int,
winnerCount: Int,
chats: List[Chat] = List.empty,
onlyNewMembers: Option[Boolean] = Option.empty,
hasPublicWinners: Option[Boolean] = Option.empty,
prizeDescription: Option[String] = Option.empty,
countryCodes: List[String] = List.empty,
premiumSubscriptionMonthCount: Option[Int] = Option.empty
)
Loading

0 comments on commit e0e7768

Please sign in to comment.