@@ -55,6 +55,22 @@ class ApiHttp4sImp[F[_]: ConcurrentEffect: ContextShift](http: Client[F], baseUr
55
55
56
56
}
57
57
58
+ /** Use this method to change the list of the bot's commands. Returns True on
59
+ success. */
60
+ def setMyCommands (x : SetMyCommandsReq ): F [SetMyCommandsRes ] = {
61
+ for {
62
+ uri <- F .fromEither[Uri ](Uri .fromString(s " $baseUrl/setMyCommands " ))
63
+ req = Request [F ]()
64
+ .withMethod(GET )
65
+ .withUri(uri)
66
+ .withEntity(x.asJson)
67
+ res <- http.expect(req)(jsonOf[F , SetMyCommandsRes ])
68
+ } yield {
69
+ res
70
+ }
71
+
72
+ }
73
+
58
74
/** Use this method to set a new profile photo for the chat. Photos can't be
59
75
changed for private chats. The bot must be an administrator in the chat for this
60
76
to work and must have the appropriate admin rights. Returns True on success. */
@@ -200,20 +216,27 @@ class ApiHttp4sImp[F[_]: ConcurrentEffect: ContextShift](http: Client[F], baseUr
200
216
201
217
}
202
218
203
- /** Use this method to create new sticker set owned by a user. The bot will be able
204
- to edit the created sticker set. Returns True on success. */
219
+ /** Use this method to create a new sticker set owned by a user. The bot will be
220
+ able to edit the sticker set thus created. You must use exactly one of the
221
+ fields png_sticker or tgs_sticker. Returns True on success. */
205
222
def createNewStickerSet (x : CreateNewStickerSetReq ): F [CreateNewStickerSetRes ] = {
206
223
207
224
val pngStickerPartF = x.pngSticker match {
208
- case InputPartFile (f) => makePart(" png_sticker" , f)
209
- case _ => F .pure(List .empty[Part [F ]])
225
+ case Some ( InputPartFile (f) ) => makePart(" png_sticker" , f)
226
+ case _ => F .pure(List .empty[Part [F ]])
210
227
}
211
228
212
- List (pngStickerPartF).sequence.map(_.flatten).flatMap { l =>
229
+ val tgsStickerPartF = x.tgsSticker match {
230
+ case Some (InputPartFile (f)) => makePart(" tgs_sticker" , f)
231
+ case _ => F .pure(List .empty[Part [F ]])
232
+ }
233
+
234
+ List (pngStickerPartF, tgsStickerPartF).sequence.map(_.flatten).flatMap { l =>
213
235
if (l.nonEmpty) {
214
236
for {
215
237
uri <- F .fromEither[Uri ](Uri .fromString(s " $baseUrl/createNewStickerSet " ))
216
238
pngStickerPart <- pngStickerPartF
239
+ tgsStickerPart <- tgsStickerPartF
217
240
body = Multipart [F ](
218
241
Vector (
219
242
(" user_id" , x.userId.asJson),
@@ -222,9 +245,11 @@ class ApiHttp4sImp[F[_]: ConcurrentEffect: ContextShift](http: Client[F], baseUr
222
245
(" emojis" , x.emojis.asJson),
223
246
(" contains_masks" , x.containsMasks.asJson),
224
247
(" mask_position" , x.maskPosition.asJson),
225
- (" pngSticker" , if (pngStickerPart.isEmpty) { x.pngSticker.asJson } else { Json .Null })
248
+ (" pngSticker" ,
249
+ if (pngStickerPart.isEmpty) { x.pngSticker.asJson } else { Json .Null }),
250
+ (" tgsSticker" , if (tgsStickerPart.isEmpty) { x.tgsSticker.asJson } else { Json .Null })
226
251
).filter(! _._2.isNull).map { case (n, v) => Part .formData(n, v.noSpaces) } ++
227
- pngStickerPart
252
+ pngStickerPart ++ tgsStickerPart
228
253
)
229
254
req = Request [F ]()
230
255
.withMethod(POST )
@@ -384,6 +409,24 @@ class ApiHttp4sImp[F[_]: ConcurrentEffect: ContextShift](http: Client[F], baseUr
384
409
385
410
}
386
411
412
+ /** Use this method to send a dice, which will have a random value from 1 to 6. On
413
+ success, the sent Message is returned. (Yes, we're aware of the “proper”
414
+ singular of die. But it's awkward, and we decided to help it change. One dice at
415
+ a time!) */
416
+ def sendDice (x : SendDiceReq ): F [SendDiceRes ] = {
417
+ for {
418
+ uri <- F .fromEither[Uri ](Uri .fromString(s " $baseUrl/sendDice " ))
419
+ req = Request [F ]()
420
+ .withMethod(GET )
421
+ .withUri(uri)
422
+ .withEntity(x.asJson)
423
+ res <- http.expect(req)(jsonOf[F , SendDiceRes ])
424
+ } yield {
425
+ res
426
+ }
427
+
428
+ }
429
+
387
430
/** Use this method when you need to tell the user that something is happening on
388
431
the bot's side. The status is set for 5 seconds or less (when a message arrives
389
432
from your bot, Telegram clients clear its typing status). Returns True on
@@ -402,7 +445,10 @@ class ApiHttp4sImp[F[_]: ConcurrentEffect: ContextShift](http: Client[F], baseUr
402
445
403
446
}
404
447
405
- /** Use this method to add a new sticker to a set created by the bot. Returns True
448
+ /** Use this method to add a new sticker to a set created by the bot. You must use
449
+ exactly one of the fields png_sticker or tgs_sticker. Animated stickers can be
450
+ added to animated sticker sets and only to them. Animated sticker sets can have
451
+ up to 50 stickers. Static sticker sets can have up to 120 stickers. Returns True
406
452
on success. */
407
453
def addStickerToSet (x : AddStickerToSetReq ): F [AddStickerToSetRes ] = {
408
454
@@ -411,20 +457,28 @@ class ApiHttp4sImp[F[_]: ConcurrentEffect: ContextShift](http: Client[F], baseUr
411
457
case _ => F .pure(List .empty[Part [F ]])
412
458
}
413
459
414
- List (pngStickerPartF).sequence.map(_.flatten).flatMap { l =>
460
+ val tgsStickerPartF = x.tgsSticker match {
461
+ case Some (InputPartFile (f)) => makePart(" tgs_sticker" , f)
462
+ case _ => F .pure(List .empty[Part [F ]])
463
+ }
464
+
465
+ List (pngStickerPartF, tgsStickerPartF).sequence.map(_.flatten).flatMap { l =>
415
466
if (l.nonEmpty) {
416
467
for {
417
468
uri <- F .fromEither[Uri ](Uri .fromString(s " $baseUrl/addStickerToSet " ))
418
469
pngStickerPart <- pngStickerPartF
470
+ tgsStickerPart <- tgsStickerPartF
419
471
body = Multipart [F ](
420
472
Vector (
421
473
(" user_id" , x.userId.asJson),
422
474
(" name" , x.name.asJson),
423
475
(" emojis" , x.emojis.asJson),
424
476
(" mask_position" , x.maskPosition.asJson),
425
- (" pngSticker" , if (pngStickerPart.isEmpty) { x.pngSticker.asJson } else { Json .Null })
477
+ (" pngSticker" ,
478
+ if (pngStickerPart.isEmpty) { x.pngSticker.asJson } else { Json .Null }),
479
+ (" tgsSticker" , if (tgsStickerPart.isEmpty) { x.tgsSticker.asJson } else { Json .Null })
426
480
).filter(! _._2.isNull).map { case (n, v) => Part .formData(n, v.noSpaces) } ++
427
- pngStickerPart
481
+ pngStickerPart ++ tgsStickerPart
428
482
)
429
483
req = Request [F ]()
430
484
.withMethod(POST )
@@ -863,12 +917,13 @@ class ApiHttp4sImp[F[_]: ConcurrentEffect: ContextShift](http: Client[F], baseUr
863
917
864
918
/** Use this method to delete a message, including service messages, with the
865
919
following limitations: - A message can only be deleted if it was sent less than
866
- 48 hours ago. - Bots can delete outgoing messages in private chats, groups, and
867
- supergroups. - Bots can delete incoming messages in private chats. - Bots
868
- granted can_post_messages permissions can delete outgoing messages in channels.
869
- - If the bot is an administrator of a group, it can delete any message there. -
870
- If the bot has can_delete_messages permission in a supergroup or a channel, it
871
- can delete any message there. Returns True on success. */
920
+ 48 hours ago. - A dice message in a private chat can only be deleted if it was
921
+ sent more than 24 hours ago. - Bots can delete outgoing messages in private
922
+ chats, groups, and supergroups. - Bots can delete incoming messages in private
923
+ chats. - Bots granted can_post_messages permissions can delete outgoing messages
924
+ in channels. - If the bot is an administrator of a group, it can delete any
925
+ message there. - If the bot has can_delete_messages permission in a supergroup
926
+ or a channel, it can delete any message there. Returns True on success. */
872
927
def deleteMessage (x : DeleteMessageReq ): F [DeleteMessageRes ] = {
873
928
for {
874
929
uri <- F .fromEither[Uri ](Uri .fromString(s " $baseUrl/deleteMessage " ))
@@ -1048,6 +1103,22 @@ class ApiHttp4sImp[F[_]: ConcurrentEffect: ContextShift](http: Client[F], baseUr
1048
1103
1049
1104
}
1050
1105
1106
+ /** Use this method to get the current list of the bot's commands. Requires no
1107
+ parameters. Returns Array of BotCommand on success. */
1108
+ def getMyCommands (): F [GetMyCommandsRes ] = {
1109
+ for {
1110
+ uri <- F .fromEither[Uri ](Uri .fromString(s " $baseUrl/getMyCommands " ))
1111
+ req = Request [F ]()
1112
+ .withMethod(GET )
1113
+ .withUri(uri)
1114
+
1115
+ res <- http.expect(req)(jsonOf[F , GetMyCommandsRes ])
1116
+ } yield {
1117
+ res
1118
+ }
1119
+
1120
+ }
1121
+
1051
1122
/** Use this method to get a list of administrators in a chat. On success, returns
1052
1123
an Array of ChatMember objects that contains information about all chat
1053
1124
administrators except other bots. If the chat is a group or a supergroup and no
@@ -1193,6 +1264,53 @@ class ApiHttp4sImp[F[_]: ConcurrentEffect: ContextShift](http: Client[F], baseUr
1193
1264
1194
1265
}
1195
1266
1267
+ /** Use this method to set the thumbnail of a sticker set. Animated thumbnails can
1268
+ be set for animated sticker sets only. Returns True on success. */
1269
+ def setStickerSetThumb (x : SetStickerSetThumbReq ): F [SetStickerSetThumbRes ] = {
1270
+
1271
+ val thumbPartF = x.thumb match {
1272
+ case Some (InputPartFile (f)) => makePart(" thumb" , f)
1273
+ case _ => F .pure(List .empty[Part [F ]])
1274
+ }
1275
+
1276
+ List (thumbPartF).sequence.map(_.flatten).flatMap { l =>
1277
+ if (l.nonEmpty) {
1278
+ for {
1279
+ uri <- F .fromEither[Uri ](Uri .fromString(s " $baseUrl/setStickerSetThumb " ))
1280
+ thumbPart <- thumbPartF
1281
+ body = Multipart [F ](
1282
+ Vector ((" name" , x.name.asJson),
1283
+ (" user_id" , x.userId.asJson),
1284
+ (" thumb" , if (thumbPart.isEmpty) { x.thumb.asJson } else { Json .Null }))
1285
+ .filter(! _._2.isNull)
1286
+ .map { case (n, v) => Part .formData(n, v.noSpaces) } ++
1287
+ thumbPart
1288
+ )
1289
+ req = Request [F ]()
1290
+ .withMethod(POST )
1291
+ .withUri(uri)
1292
+ .withEntity(body)
1293
+ .withHeaders(body.headers)
1294
+ res <- http.expect(req)(jsonOf[F , SetStickerSetThumbRes ])
1295
+ } yield {
1296
+ res
1297
+ }
1298
+ } else {
1299
+ for {
1300
+ uri <- F .fromEither[Uri ](Uri .fromString(s " $baseUrl/setStickerSetThumb " ))
1301
+ req = Request [F ]()
1302
+ .withMethod(GET )
1303
+ .withUri(uri)
1304
+ .withEntity(x.asJson)
1305
+ res <- http.expect(req)(jsonOf[F , SetStickerSetThumbRes ])
1306
+ } yield {
1307
+ res
1308
+ }
1309
+
1310
+ }
1311
+ }
1312
+ }
1313
+
1196
1314
/** Use this method to edit only the reply markup of messages. On success, if
1197
1315
edited message is sent by the bot, the edited Message is returned, otherwise
1198
1316
True is returned. */
0 commit comments