Skip to content

Commit edc0cd5

Browse files
authored
[api] Support version 5.7 (#189)
### Bot API 5.7 - Added support for [Video Stickers](https://telegram.org/blog/video-stickers-better-reactions). - Added the field is_video to the classes [Sticker](https://core.telegram.org/bots/api#sticker) and [StickerSet](https://core.telegram.org/bots/api#stickerset). - Added the parameter webm_sticker to the methods [createNewStickerSet](https://core.telegram.org/bots/api#createnewstickerset) and [addStickerToSet](https://core.telegram.org/bots/api#addstickertoset). https://core.telegram.org/bots/api#january-31-2022
1 parent 9ab5871 commit edc0cd5

File tree

10 files changed

+62
-20
lines changed

10 files changed

+62
-20
lines changed

.github/workflows/build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ jobs:
2222
arguments: "-c .scalafmt.conf --test core akka examples"
2323
- uses: jodersky/setup-mill@v0.2.3
2424
with:
25-
mill-version: 0.10.0
25+
mill-version: 0.10.2
2626
- name: Compile
2727
run: mill '_._[_].compile'
2828
- name: Test

.github/workflows/publish_snapshot.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ jobs:
1515
uses: actions/checkout@v2
1616
- uses: jodersky/setup-mill@v0.2.3
1717
with:
18-
mill-version: 0.10.0
18+
mill-version: 0.10.2
1919
- name: Import GPG key
2020
id: import_gpg
2121
uses: crazy-max/ghaction-import-gpg@v3

.github/workflows/release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ jobs:
1111
uses: actions/checkout@v2
1212
- uses: jodersky/setup-mill@v0.2.3
1313
with:
14-
mill-version: 0.10.0
14+
mill-version: 0.10.2
1515
- name: Import GPG key
1616
id: import_gpg
1717
uses: crazy-max/ghaction-import-gpg@v3

.mill-version

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
0.10.0
1+
0.10.2

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -69,16 +69,16 @@ Table of contents
6969
Add to your `build.sbt` file:
7070
```scala
7171
// Core with minimal dependencies, enough to spawn your first bot.
72-
libraryDependencies += "com.bot4s" %% "telegram-core" % "5.3.0"
72+
libraryDependencies += "com.bot4s" %% "telegram-core" % "5.4.0"
7373

7474
// Extra goodies: Webhooks, support for games, bindings for actors.
75-
libraryDependencies += "com.bot4s" %% "telegram-akka" % "5.3.0"
75+
libraryDependencies += "com.bot4s" %% "telegram-akka" % "5.4.0"
7676
```
7777

7878
For [mill](https://www.lihaoyi.com/mill/) add to your `build.sc` project deps:
7979
```scala
80-
ivy"com.bot4s::telegram-core:5.3.0", // core
81-
ivy"com.bot4s::telegram-akka:5.3.0" // extra goodies
80+
ivy"com.bot4s::telegram-core:5.4.0", // core
81+
ivy"com.bot4s::telegram-akka:5.4.0" // extra goodies
8282
```
8383

8484
## Leaking bot tokens

build.sc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import mill._
22
import mill.scalalib._
33
import mill.scalalib.publish._
44

5-
val ScalaVersions = Seq("2.12.15", "2.13.7")
5+
val ScalaVersions = Seq("2.12.15", "2.13.8")
66

77
object library {
88

@@ -111,7 +111,7 @@ abstract class Bot4sTelegramCrossPlatform(val platformSegment: String, location:
111111

112112
trait Publishable extends PublishModule {
113113

114-
override def publishVersion = "5.3.0"
114+
override def publishVersion = "5.4.0"
115115

116116
def pomSettings = PomSettings(
117117
description = "Telegram Bot API wrapper for Scala",

core/src/com/bot4s/telegram/methods/AddStickerToSet.scala

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,35 @@ import com.bot4s.telegram.models.InputFile
1010
* @param userId Long User identifier of sticker set owner
1111
* @param name String Sticker set name
1212
* @param pngSticker InputFile or String Png image with the sticker, must be up to 512 kilobytes in size, dimensions must not exceed 512px, and either width or height must be exactly 512px. Pass a file_id as a String to send a file that already exists on the Telegram servers, pass an HTTP URL as a String for Telegram to get a file from the Internet, or upload a new one using multipart/form-data. More info on Sending Files »
13+
* @param tgsSticker InputFile Optional TGS animation with the sticker, uploaded using multipart/form-data. See
14+
* [[https://core.telegram.org/stickers#animated-sticker-requirements for technical requirements]]
15+
* @param webmSticker InputFile Optional WEBM video with the sticker, uploaded using multipart/form-data see
16+
* [[https://core.telegram.org/stickers#video-sticker-requirements for technical requirements]]
17+
* @param webmSticker InputFile or String Png image with the sticker, must be up to 512 kilobytes in size, dimensions must not exceed 512px, and either width or height must be exactly 512px. Pass a file_id as a String to send a file that already exists on the Telegram servers, pass an HTTP URL as a String for Telegram to get a file from the Internet, or upload a new one using multipart/form-data. More info on Sending Files »
1318
* @param emojis String One or more emoji corresponding to the sticker
1419
* @param maskPosition MaskPosition Optional Position where the mask should be placed on faces
1520
*/
1621
case class AddStickerToSet(
1722
userId: Long,
1823
name: String,
19-
pngSticker: InputFile,
24+
pngSticker: Option[InputFile],
25+
tgsSticker: Option[InputFile],
26+
webmSticker: Option[InputFile],
2027
emojis: String,
2128
maskPosition: Option[MaskPosition] = None
2229
) extends MultipartRequest[Boolean] {
23-
override def getFiles: List[(String, InputFile)] = List("pngSticker" -> pngSticker)
30+
31+
require(
32+
Seq[Option[_]](
33+
pngSticker,
34+
tgsSticker,
35+
webmSticker
36+
).count(_.isDefined) == 1,
37+
"You must use exactly one of the fields png_sticker, tgs_sticker, or webm_sticker"
38+
)
39+
override def getFiles: List[(String, InputFile)] = List(
40+
"png_sticker" -> pngSticker,
41+
"tgs_sticker" -> tgsSticker,
42+
"webm_sticker" -> webmSticker
43+
).collect { case (key, Some(value)) => (key, value) }
2444
}

core/src/com/bot4s/telegram/methods/CreateNewStickerSet.scala

Lines changed: 26 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,24 +11,42 @@ import com.bot4s.telegram.models.InputFile
1111
* @param userId Long User identifier of created sticker set owner
1212
* @param name String Short name of sticker set, to be used in t.me/addstickers/ URLs (e.g., animals). Can contain only english letters, digits and underscores. Must begin with a letter, can't contain consecutive underscores and must end in “_by_<bot username>”. <bot_username> is case insensitive. 1-64 characters.
1313
* @param title String Sticker set title, 1-64 characters
14-
* @param pngSticker InputFile or String Png image with the sticker, must be up to 512 kilobytes in size,
15-
* dimensions must not exceed 512px, and either width or height must be exactly 512px.
16-
* Pass a file_id as a String to send a file that already exists on the Telegram servers,
17-
* pass an HTTP URL as a String for Telegram to get a file from the Internet,
18-
* or upload a new one using multipart/form-data.
14+
* @param pngSticker InputFile or String Optional
15+
* image with the sticker, must be up to 512 kilobytes in size, dimensions must not exceed 512px, and either width or height must be exactly 512px.
16+
* Pass a file_id as a String to send a file that already exists on the Telegram servers, pass an HTTP URL as a String for Telegram to get a file from the Internet, or upload a new one using multipart/form-data.
1917
* [[https://core.telegram.org/bots/api#sending-files More info on Sending Files]]
20-
* @param emojis String One or more emoji corresponding to the sticker
18+
* @param tgsSticker InputFile Optional TGS animation with the sticker, uploaded using multipart/form-data. See
19+
* [[https://core.telegram.org/stickers#animated-sticker-requirements for technical requirements]]
20+
* @param webmSticker InputFile Optional WEBM video with the sticker, uploaded using multipart/form-data see
21+
* [[https://core.telegram.org/stickers#video-sticker-requirements for technical requirements]]
22+
* @param emojis String One or more emoji corresponding to the sticker
2123
* @param containsMasks Boolean Optional Pass True, if a set of mask stickers should be created
2224
* @param maskPosition MaskPosition Optional Position where the mask should be placed on faces
2325
*/
2426
case class CreateNewStickerSet(
2527
userId: Long,
2628
name: String,
2729
title: String,
28-
pngSticker: InputFile,
30+
pngSticker: Option[InputFile],
31+
tgsSticker: Option[InputFile],
32+
webmSticker: Option[InputFile],
2933
emojis: String,
3034
containsMasks: Option[Boolean] = None,
3135
maskPosition: Option[MaskPosition] = None
3236
) extends MultipartRequest[Boolean] {
33-
override def getFiles: List[(String, InputFile)] = List("png_sticker" -> pngSticker)
37+
38+
require(
39+
Seq[Option[_]](
40+
pngSticker,
41+
tgsSticker,
42+
webmSticker
43+
).count(_.isDefined) == 1,
44+
"You must use exactly one of the fields png_sticker, tgs_sticker, or webm_sticker"
45+
)
46+
47+
override def getFiles: List[(String, InputFile)] = List(
48+
"png_sticker" -> pngSticker,
49+
"tgs_sticker" -> tgsSticker,
50+
"webm_sticker" -> webmSticker
51+
).collect { case (key, Some(value)) => (key, value) }
3452
}

core/src/com/bot4s/telegram/models/Sticker.scala

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ package com.bot4s.telegram.models
88
* @param width Sticker width
99
* @param height Sticker height
1010
* @param isAnimated Boolean True, if the sticker is animated
11+
* @param isVideo Boolean True, if the sticker is a video sticker
1112
* @param thumb Optional Sticker thumbnail in .webp or .jpg format
1213
* @param emoji Optional. Emoji associated with the sticker
1314
* @param setName String Optional. Name of the sticker set to which the sticker belongs
@@ -21,6 +22,7 @@ case class Sticker(
2122
width: Int,
2223
height: Int,
2324
isAnimated: Boolean,
25+
isVideo: Boolean,
2426
thumb: Option[PhotoSize] = None,
2527
emoji: Option[String] = None,
2628
setName: Option[String] = None,

core/src/com/bot4s/telegram/models/StickerSet.scala

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,15 @@ package com.bot4s.telegram.models
66
* @param name String Sticker set name
77
* @param title String Sticker set title
88
* @param isAnimated Boolean True, if the sticker set contains animated stickers
9+
* @param isVideo Boolean True, if the sticker set contains video stickers
910
* @param containsMasks Boolean True, if the sticker set contains masks
1011
* @param stickers Array of Sticker List of all set stickers
1112
*/
1213
case class StickerSet(
1314
name: String,
1415
title: String,
1516
isAnimated: Boolean,
17+
isVideo: Boolean,
1618
containsMasks: Boolean,
1719
stickers: Array[Sticker]
1820
)

0 commit comments

Comments
 (0)