Skip to content

Commit 03de69d

Browse files
committed
Create extensions for all KAbstractMultipartRequest requests
1 parent 8b224bd commit 03de69d

File tree

8 files changed

+496
-0
lines changed

8 files changed

+496
-0
lines changed
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
package com.pengrad.telegrambot.utility.kotlin.extension.request
2+
3+
import com.pengrad.telegrambot.TelegramAware
4+
import com.pengrad.telegrambot.request.SendAnimation
5+
import com.pengrad.telegrambot.utility.kotlin.extension.execute
6+
import java.io.File
7+
8+
inline fun TelegramAware.sendAnimation(
9+
chatId: Long,
10+
animationUrl: String,
11+
modifier: SendAnimation.() -> Unit = {}
12+
) = this.execute(SendAnimation(
13+
chatId = chatId,
14+
animationUrl = animationUrl
15+
), modifier)
16+
17+
inline fun TelegramAware.sendAnimation(
18+
channelUsername: String,
19+
animationUrl: String,
20+
modifier: SendAnimation.() -> Unit = {}
21+
) = this.execute(SendAnimation(
22+
channelUsername = channelUsername,
23+
animationUrl = animationUrl
24+
), modifier)
25+
26+
27+
inline fun TelegramAware.sendAnimation(
28+
chatId: Long,
29+
animationFile: File,
30+
modifier: SendAnimation.() -> Unit = {}
31+
) = this.execute(SendAnimation(
32+
chatId = chatId,
33+
animationFile = animationFile
34+
), modifier)
35+
36+
inline fun TelegramAware.sendAnimation(
37+
channelUsername: String,
38+
animationFile: File,
39+
modifier: SendAnimation.() -> Unit = {}
40+
) = this.execute(SendAnimation(
41+
channelUsername = channelUsername,
42+
animationFile = animationFile
43+
), modifier)
44+
45+
46+
inline fun TelegramAware.sendAnimation(
47+
chatId: Long,
48+
animationBytes: ByteArray,
49+
modifier: SendAnimation.() -> Unit = {}
50+
) = this.execute(SendAnimation(
51+
chatId = chatId,
52+
animationBytes = animationBytes
53+
), modifier)
54+
55+
inline fun TelegramAware.sendAnimation(
56+
channelUsername: String,
57+
animationBytes: ByteArray,
58+
modifier: SendAnimation.() -> Unit = {}
59+
) = this.execute(SendAnimation(
60+
channelUsername = channelUsername,
61+
animationBytes = animationBytes
62+
), modifier)
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
package com.pengrad.telegrambot.utility.kotlin.extension.request
2+
3+
import com.pengrad.telegrambot.TelegramAware
4+
import com.pengrad.telegrambot.request.SendAudio
5+
import com.pengrad.telegrambot.utility.kotlin.extension.execute
6+
import java.io.File
7+
8+
inline fun TelegramAware.sendAudio(
9+
chatId: Long,
10+
audioUrl: String,
11+
modifier: SendAudio.() -> Unit = {}
12+
) = this.execute(SendAudio(
13+
chatId = chatId,
14+
audioUrl = audioUrl
15+
), modifier)
16+
17+
inline fun TelegramAware.sendAudio(
18+
channelUsername: String,
19+
audioUrl: String,
20+
modifier: SendAudio.() -> Unit = {}
21+
) = this.execute(SendAudio(
22+
channelUsername = channelUsername,
23+
audioUrl = audioUrl
24+
), modifier)
25+
26+
27+
inline fun TelegramAware.sendAudio(
28+
chatId: Long,
29+
audioFile: File,
30+
modifier: SendAudio.() -> Unit = {}
31+
) = this.execute(SendAudio(
32+
chatId = chatId,
33+
audioFile = audioFile
34+
), modifier)
35+
36+
inline fun TelegramAware.sendAudio(
37+
channelUsername: String,
38+
audioFile: File,
39+
modifier: SendAudio.() -> Unit = {}
40+
) = this.execute(SendAudio(
41+
channelUsername = channelUsername,
42+
audioFile = audioFile
43+
), modifier)
44+
45+
46+
inline fun TelegramAware.sendAudio(
47+
chatId: Long,
48+
audioBytes: ByteArray,
49+
modifier: SendAudio.() -> Unit = {}
50+
) = this.execute(SendAudio(
51+
chatId = chatId,
52+
audioBytes = audioBytes
53+
), modifier)
54+
55+
inline fun TelegramAware.sendAudio(
56+
channelUsername: String,
57+
audioBytes: ByteArray,
58+
modifier: SendAudio.() -> Unit = {}
59+
) = this.execute(SendAudio(
60+
channelUsername = channelUsername,
61+
audioBytes = audioBytes
62+
), modifier)
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
package com.pengrad.telegrambot.utility.kotlin.extension.request
2+
3+
import com.pengrad.telegrambot.TelegramAware
4+
import com.pengrad.telegrambot.request.SendDocument
5+
import com.pengrad.telegrambot.utility.kotlin.extension.execute
6+
import java.io.File
7+
8+
inline fun TelegramAware.sendDocument(
9+
chatId: Long,
10+
documentUrl: String,
11+
modifier: SendDocument.() -> Unit = {}
12+
) = this.execute(SendDocument(
13+
chatId = chatId,
14+
documentUrl = documentUrl
15+
), modifier)
16+
17+
inline fun TelegramAware.sendDocument(
18+
channelUsername: String,
19+
documentUrl: String,
20+
modifier: SendDocument.() -> Unit = {}
21+
) = this.execute(SendDocument(
22+
channelUsername = channelUsername,
23+
documentUrl = documentUrl
24+
), modifier)
25+
26+
27+
inline fun TelegramAware.sendDocument(
28+
chatId: Long,
29+
documentFile: File,
30+
modifier: SendDocument.() -> Unit = {}
31+
) = this.execute(SendDocument(
32+
chatId = chatId,
33+
documentFile = documentFile
34+
), modifier)
35+
36+
inline fun TelegramAware.sendDocument(
37+
channelUsername: String,
38+
documentFile: File,
39+
modifier: SendDocument.() -> Unit = {}
40+
) = this.execute(SendDocument(
41+
channelUsername = channelUsername,
42+
documentFile = documentFile
43+
), modifier)
44+
45+
46+
inline fun TelegramAware.sendDocument(
47+
chatId: Long,
48+
documentBytes: ByteArray,
49+
modifier: SendDocument.() -> Unit = {}
50+
) = this.execute(SendDocument(
51+
chatId = chatId,
52+
documentBytes = documentBytes
53+
), modifier)
54+
55+
inline fun TelegramAware.sendDocument(
56+
channelUsername: String,
57+
documentBytes: ByteArray,
58+
modifier: SendDocument.() -> Unit = {}
59+
) = this.execute(SendDocument(
60+
channelUsername = channelUsername,
61+
documentBytes = documentBytes
62+
), modifier)
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
package com.pengrad.telegrambot.utility.kotlin.extension.request
2+
3+
import com.pengrad.telegrambot.TelegramAware
4+
import com.pengrad.telegrambot.request.SendPhoto
5+
import com.pengrad.telegrambot.utility.kotlin.extension.execute
6+
import java.io.File
7+
8+
inline fun TelegramAware.sendPhoto(
9+
chatId: Long,
10+
photoUrl: String,
11+
modifier: SendPhoto.() -> Unit = {}
12+
) = this.execute(SendPhoto(
13+
chatId = chatId,
14+
photoUrl = photoUrl
15+
), modifier)
16+
17+
inline fun TelegramAware.sendPhoto(
18+
channelUsername: String,
19+
photoUrl: String,
20+
modifier: SendPhoto.() -> Unit = {}
21+
) = this.execute(SendPhoto(
22+
channelUsername = channelUsername,
23+
photoUrl = photoUrl
24+
), modifier)
25+
26+
27+
inline fun TelegramAware.sendPhoto(
28+
chatId: Long,
29+
photoFile: File,
30+
modifier: SendPhoto.() -> Unit = {}
31+
) = this.execute(SendPhoto(
32+
chatId = chatId,
33+
photoFile = photoFile
34+
), modifier)
35+
36+
inline fun TelegramAware.sendPhoto(
37+
channelUsername: String,
38+
photoFile: File,
39+
modifier: SendPhoto.() -> Unit = {}
40+
) = this.execute(SendPhoto(
41+
channelUsername = channelUsername,
42+
photoFile = photoFile
43+
), modifier)
44+
45+
46+
inline fun TelegramAware.sendPhoto(
47+
chatId: Long,
48+
photoBytes: ByteArray,
49+
modifier: SendPhoto.() -> Unit = {}
50+
) = this.execute(SendPhoto(
51+
chatId = chatId,
52+
photoBytes = photoBytes
53+
), modifier)
54+
55+
inline fun TelegramAware.sendPhoto(
56+
channelUsername: String,
57+
photoBytes: ByteArray,
58+
modifier: SendPhoto.() -> Unit = {}
59+
) = this.execute(SendPhoto(
60+
channelUsername = channelUsername,
61+
photoBytes = photoBytes
62+
), modifier)
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
package com.pengrad.telegrambot.utility.kotlin.extension.request
2+
3+
import com.pengrad.telegrambot.TelegramAware
4+
import com.pengrad.telegrambot.request.SendSticker
5+
import com.pengrad.telegrambot.utility.kotlin.extension.execute
6+
import java.io.File
7+
8+
inline fun TelegramAware.sendSticker(
9+
chatId: Long,
10+
stickerUrl: String,
11+
modifier: SendSticker.() -> Unit = {}
12+
) = this.execute(SendSticker(
13+
chatId = chatId,
14+
stickerUrl = stickerUrl
15+
), modifier)
16+
17+
inline fun TelegramAware.sendSticker(
18+
channelUsername: String,
19+
stickerUrl: String,
20+
modifier: SendSticker.() -> Unit = {}
21+
) = this.execute(SendSticker(
22+
channelUsername = channelUsername,
23+
stickerUrl = stickerUrl
24+
), modifier)
25+
26+
27+
inline fun TelegramAware.sendSticker(
28+
chatId: Long,
29+
stickerFile: File,
30+
modifier: SendSticker.() -> Unit = {}
31+
) = this.execute(SendSticker(
32+
chatId = chatId,
33+
stickerFile = stickerFile
34+
), modifier)
35+
36+
inline fun TelegramAware.sendSticker(
37+
channelUsername: String,
38+
stickerFile: File,
39+
modifier: SendSticker.() -> Unit = {}
40+
) = this.execute(SendSticker(
41+
channelUsername = channelUsername,
42+
stickerFile = stickerFile
43+
), modifier)
44+
45+
46+
inline fun TelegramAware.sendSticker(
47+
chatId: Long,
48+
stickerBytes: ByteArray,
49+
modifier: SendSticker.() -> Unit = {}
50+
) = this.execute(SendSticker(
51+
chatId = chatId,
52+
stickerBytes = stickerBytes
53+
), modifier)
54+
55+
inline fun TelegramAware.sendSticker(
56+
channelUsername: String,
57+
stickerBytes: ByteArray,
58+
modifier: SendSticker.() -> Unit = {}
59+
) = this.execute(SendSticker(
60+
channelUsername = channelUsername,
61+
stickerBytes = stickerBytes
62+
), modifier)
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
package com.pengrad.telegrambot.utility.kotlin.extension.request
2+
3+
import com.pengrad.telegrambot.TelegramAware
4+
import com.pengrad.telegrambot.request.SendVideo
5+
import com.pengrad.telegrambot.utility.kotlin.extension.execute
6+
import java.io.File
7+
8+
inline fun TelegramAware.sendVideo(
9+
chatId: Long,
10+
videoUrl: String,
11+
modifier: SendVideo.() -> Unit = {}
12+
) = this.execute(SendVideo(
13+
chatId = chatId,
14+
videoUrl = videoUrl
15+
), modifier)
16+
17+
inline fun TelegramAware.sendVideo(
18+
channelUsername: String,
19+
videoUrl: String,
20+
modifier: SendVideo.() -> Unit = {}
21+
) = this.execute(SendVideo(
22+
channelUsername = channelUsername,
23+
videoUrl = videoUrl
24+
), modifier)
25+
26+
27+
inline fun TelegramAware.sendVideo(
28+
chatId: Long,
29+
videoFile: File,
30+
modifier: SendVideo.() -> Unit = {}
31+
) = this.execute(SendVideo(
32+
chatId = chatId,
33+
videoFile = videoFile
34+
), modifier)
35+
36+
inline fun TelegramAware.sendVideo(
37+
channelUsername: String,
38+
videoFile: File,
39+
modifier: SendVideo.() -> Unit = {}
40+
) = this.execute(SendVideo(
41+
channelUsername = channelUsername,
42+
videoFile = videoFile
43+
), modifier)
44+
45+
46+
inline fun TelegramAware.sendVideo(
47+
chatId: Long,
48+
videoBytes: ByteArray,
49+
modifier: SendVideo.() -> Unit = {}
50+
) = this.execute(SendVideo(
51+
chatId = chatId,
52+
videoBytes = videoBytes
53+
), modifier)
54+
55+
inline fun TelegramAware.sendVideo(
56+
channelUsername: String,
57+
videoBytes: ByteArray,
58+
modifier: SendVideo.() -> Unit = {}
59+
) = this.execute(SendVideo(
60+
channelUsername = channelUsername,
61+
videoBytes = videoBytes
62+
), modifier)

0 commit comments

Comments
 (0)