1
+ package com.pengrad.telegrambot.request
2
+
3
+ import com.pengrad.telegrambot.model.MessageEntity
4
+ import com.pengrad.telegrambot.model.Poll
5
+ import com.pengrad.telegrambot.model.request.InputPollOption
6
+ import com.pengrad.telegrambot.model.request.ParseMode
7
+ import com.pengrad.telegrambot.utility.kotlin.checkDeprecatedConstructorParameters
8
+ import com.pengrad.telegrambot.utility.kotlin.optionalRequestParameter
9
+ import com.pengrad.telegrambot.utility.kotlin.requestParameter
10
+
11
+ class SendPoll private constructor(
12
+ chatId : Long? = null ,
13
+ channelUsername : String? = null ,
14
+
15
+ question : String ,
16
+ options : List <InputPollOption >
17
+ ) : KAbstractSendRequest<SendPoll>(
18
+ chatId = chatId,
19
+ channelUsername = channelUsername,
20
+ ) {
21
+
22
+ constructor (
23
+ chatId: Long ,
24
+ question: String ,
25
+ options: List <InputPollOption >
26
+ ) : this (
27
+ chatId = chatId,
28
+ channelUsername = null ,
29
+ question = question,
30
+ options = options
31
+ )
32
+
33
+ constructor (
34
+ channelUsername: String ,
35
+ question: String ,
36
+ options: List <InputPollOption >
37
+ ) : this (
38
+ chatId = null ,
39
+ channelUsername = channelUsername,
40
+ question = question,
41
+ options = options
42
+ )
43
+
44
+ @Deprecated(" Use constructor with chatId or channelUsername instead" , ReplaceWith (" SendPoll(chatId, question, options)" ))
45
+ constructor (
46
+ chatId: Any ,
47
+ question: String ,
48
+ vararg options: InputPollOption
49
+ ) : this (
50
+ chatId = (chatId as ? Number )?.toLong(),
51
+ channelUsername = chatId as ? String ,
52
+ question = question,
53
+ options = options.toList()
54
+ ) {
55
+ checkDeprecatedConstructorParameters()
56
+ }
57
+
58
+ val question: String by requestParameter(question)
59
+ val options: List <InputPollOption > by requestParameter(options)
60
+
61
+ var type: Poll .Type ? by optionalRequestParameter()
62
+ var typeRaw: String? by optionalRequestParameter(customParameterName = " type" )
63
+
64
+ var isAnonymous: Boolean? by optionalRequestParameter()
65
+ var allowsMultipleAnswers: Boolean? by optionalRequestParameter()
66
+ var correctOptionId: Int? by optionalRequestParameter()
67
+
68
+ var questionParseMode: ParseMode ? by optionalRequestParameter()
69
+ var questionEntities: List <MessageEntity >? by optionalRequestParameter()
70
+
71
+ var explanation: String? by optionalRequestParameter()
72
+ var explanationParseMode: ParseMode ? by optionalRequestParameter()
73
+ var explanationEntities: List <MessageEntity >? by optionalRequestParameter()
74
+
75
+ var openPeriod: Int? by optionalRequestParameter()
76
+ var closeDate: Long? by optionalRequestParameter()
77
+ var isClosed: Boolean? by optionalRequestParameter()
78
+
79
+ fun type (type : Poll .Type ) = applySelf { this .type = type }
80
+
81
+ fun type (typeRaw : String ) = applySelf { this .typeRaw = typeRaw }
82
+
83
+ fun isAnonymous (isAnonymous : Boolean ) = applySelf { this .isAnonymous = isAnonymous }
84
+
85
+ fun allowsMultipleAnswers (allowMultipleAnswers : Boolean ) = applySelf { this .allowsMultipleAnswers = allowMultipleAnswers }
86
+
87
+ fun correctOptionId (correctOptionId : Int ) = applySelf { this .correctOptionId = correctOptionId }
88
+
89
+ fun questionParseMode (questionParseMode : ParseMode ) = applySelf { this .questionParseMode = questionParseMode }
90
+
91
+ fun questionEntities (questionEntities : List <MessageEntity >) = applySelf { this .questionEntities = questionEntities }
92
+
93
+ fun questionEntities (vararg questionEntities : MessageEntity ) = questionEntities(questionEntities.toList())
94
+
95
+ fun explanation (explanation : String ) = applySelf { this .explanation = explanation }
96
+
97
+ fun explanationParseMode (explanationParseMode : ParseMode ) = applySelf { this .explanationParseMode = explanationParseMode }
98
+
99
+ fun explanationEntities (explanationEntities : List <MessageEntity >) = applySelf { this .explanationEntities = explanationEntities }
100
+
101
+ fun explanationEntities (vararg explanationEntities : MessageEntity ) = explanationEntities(explanationEntities.toList())
102
+
103
+ fun openPeriod (openPeriod : Int ) = applySelf { this .openPeriod = openPeriod }
104
+
105
+ fun closeDate (closeDate : Long ) = applySelf { this .closeDate = closeDate }
106
+
107
+ fun isClosed (isClosed : Boolean ) = applySelf { this .isClosed = isClosed }
108
+
109
+ }
0 commit comments