types.go 116 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330
  1. package tgbotapi
  2. import (
  3. "encoding/json"
  4. "errors"
  5. "fmt"
  6. "net/url"
  7. "strings"
  8. "time"
  9. )
  10. // APIResponse is a response from the Telegram API with the result
  11. // stored raw.
  12. type APIResponse struct {
  13. Ok bool `json:"ok"`
  14. Result json.RawMessage `json:"result,omitempty"`
  15. ErrorCode int `json:"error_code,omitempty"`
  16. Description string `json:"description,omitempty"`
  17. Parameters *ResponseParameters `json:"parameters,omitempty"`
  18. }
  19. // Error is an error containing extra information returned by the Telegram API.
  20. type Error struct {
  21. Code int
  22. Message string
  23. ResponseParameters
  24. }
  25. // Error message string.
  26. func (e Error) Error() string {
  27. return e.Message
  28. }
  29. // Update is an update response, from GetUpdates.
  30. type Update struct {
  31. // UpdateID is the update's unique identifier.
  32. // Update identifiers start from a certain positive number and increase
  33. // sequentially.
  34. // This ID becomes especially handy if you're using Webhooks,
  35. // since it allows you to ignore repeated updates or to restore
  36. // the correct update sequence, should they get out of order.
  37. // If there are no new updates for at least a week, then identifier
  38. // of the next update will be chosen randomly instead of sequentially.
  39. UpdateID int `json:"update_id"`
  40. // Message new incoming message of any kind — text, photo, sticker, etc.
  41. //
  42. // optional
  43. Message *Message `json:"message,omitempty"`
  44. // EditedMessage new version of a message that is known to the bot and was
  45. // edited
  46. //
  47. // optional
  48. EditedMessage *Message `json:"edited_message,omitempty"`
  49. // ChannelPost new version of a message that is known to the bot and was
  50. // edited
  51. //
  52. // optional
  53. ChannelPost *Message `json:"channel_post,omitempty"`
  54. // EditedChannelPost new incoming channel post of any kind — text, photo,
  55. // sticker, etc.
  56. //
  57. // optional
  58. EditedChannelPost *Message `json:"edited_channel_post,omitempty"`
  59. // InlineQuery new incoming inline query
  60. //
  61. // optional
  62. InlineQuery *InlineQuery `json:"inline_query,omitempty"`
  63. // ChosenInlineResult is the result of an inline query
  64. // that was chosen by a user and sent to their chat partner.
  65. // Please see our documentation on the feedback collecting
  66. // for details on how to enable these updates for your bot.
  67. //
  68. // optional
  69. ChosenInlineResult *ChosenInlineResult `json:"chosen_inline_result,omitempty"`
  70. // CallbackQuery new incoming callback query
  71. //
  72. // optional
  73. CallbackQuery *CallbackQuery `json:"callback_query,omitempty"`
  74. // ShippingQuery new incoming shipping query. Only for invoices with
  75. // flexible price
  76. //
  77. // optional
  78. ShippingQuery *ShippingQuery `json:"shipping_query,omitempty"`
  79. // PreCheckoutQuery new incoming pre-checkout query. Contains full
  80. // information about checkout
  81. //
  82. // optional
  83. PreCheckoutQuery *PreCheckoutQuery `json:"pre_checkout_query,omitempty"`
  84. // Pool new poll state. Bots receive only updates about stopped polls and
  85. // polls, which are sent by the bot
  86. //
  87. // optional
  88. Poll *Poll `json:"poll,omitempty"`
  89. // PollAnswer user changed their answer in a non-anonymous poll. Bots
  90. // receive new votes only in polls that were sent by the bot itself.
  91. //
  92. // optional
  93. PollAnswer *PollAnswer `json:"poll_answer,omitempty"`
  94. // MyChatMember is the bot's chat member status was updated in a chat. For
  95. // private chats, this update is received only when the bot is blocked or
  96. // unblocked by the user.
  97. //
  98. // optional
  99. MyChatMember *ChatMemberUpdated `json:"my_chat_member,omitempty"`
  100. // ChatMember is a chat member's status was updated in a chat. The bot must
  101. // be an administrator in the chat and must explicitly specify "chat_member"
  102. // in the list of allowed_updates to receive these updates.
  103. //
  104. // optional
  105. ChatMember *ChatMemberUpdated `json:"chat_member,omitempty"`
  106. // ChatJoinRequest is a request to join the chat has been sent. The bot must
  107. // have the can_invite_users administrator right in the chat to receive
  108. // these updates.
  109. //
  110. // optional
  111. ChatJoinRequest *ChatJoinRequest `json:"chat_join_request,omitempty"`
  112. }
  113. // SentFrom returns the user who sent an update. Can be nil, if Telegram did not provide information
  114. // about the user in the update object.
  115. func (u *Update) SentFrom() *User {
  116. switch {
  117. case u.Message != nil:
  118. return u.Message.From
  119. case u.EditedMessage != nil:
  120. return u.EditedMessage.From
  121. case u.InlineQuery != nil:
  122. return u.InlineQuery.From
  123. case u.ChosenInlineResult != nil:
  124. return u.ChosenInlineResult.From
  125. case u.CallbackQuery != nil:
  126. return u.CallbackQuery.From
  127. case u.ShippingQuery != nil:
  128. return u.ShippingQuery.From
  129. case u.PreCheckoutQuery != nil:
  130. return u.PreCheckoutQuery.From
  131. default:
  132. return nil
  133. }
  134. }
  135. // CallbackData returns the callback query data, if it exists.
  136. func (u *Update) CallbackData() string {
  137. if u.CallbackQuery != nil {
  138. return u.CallbackQuery.Data
  139. }
  140. return ""
  141. }
  142. // FromChat returns the chat where an update occurred.
  143. func (u *Update) FromChat() *Chat {
  144. switch {
  145. case u.Message != nil:
  146. return u.Message.Chat
  147. case u.EditedMessage != nil:
  148. return u.EditedMessage.Chat
  149. case u.ChannelPost != nil:
  150. return u.ChannelPost.Chat
  151. case u.EditedChannelPost != nil:
  152. return u.EditedChannelPost.Chat
  153. case u.CallbackQuery != nil:
  154. return u.CallbackQuery.Message.Chat
  155. default:
  156. return nil
  157. }
  158. }
  159. // UpdatesChannel is the channel for getting updates.
  160. type UpdatesChannel <-chan Update
  161. // Clear discards all unprocessed incoming updates.
  162. func (ch UpdatesChannel) Clear() {
  163. for len(ch) != 0 {
  164. <-ch
  165. }
  166. }
  167. // User represents a Telegram user or bot.
  168. type User struct {
  169. // ID is a unique identifier for this user or bot
  170. ID int64 `json:"id"`
  171. // IsBot true, if this user is a bot
  172. //
  173. // optional
  174. IsBot bool `json:"is_bot,omitempty"`
  175. // IsPremium true, if user has Telegram Premium
  176. //
  177. // optional
  178. IsPremium bool `json:"is_premium,omitempty"`
  179. // FirstName user's or bot's first name
  180. FirstName string `json:"first_name"`
  181. // LastName user's or bot's last name
  182. //
  183. // optional
  184. LastName string `json:"last_name,omitempty"`
  185. // UserName user's or bot's username
  186. //
  187. // optional
  188. UserName string `json:"username,omitempty"`
  189. // LanguageCode IETF language tag of the user's language
  190. // more info: https://en.wikipedia.org/wiki/IETF_language_tag
  191. //
  192. // optional
  193. LanguageCode string `json:"language_code,omitempty"`
  194. // CanJoinGroups is true, if the bot can be invited to groups.
  195. // Returned only in getMe.
  196. //
  197. // optional
  198. CanJoinGroups bool `json:"can_join_groups,omitempty"`
  199. // CanReadAllGroupMessages is true, if privacy mode is disabled for the bot.
  200. // Returned only in getMe.
  201. //
  202. // optional
  203. CanReadAllGroupMessages bool `json:"can_read_all_group_messages,omitempty"`
  204. // SupportsInlineQueries is true, if the bot supports inline queries.
  205. // Returned only in getMe.
  206. //
  207. // optional
  208. SupportsInlineQueries bool `json:"supports_inline_queries,omitempty"`
  209. }
  210. // String displays a simple text version of a user.
  211. //
  212. // It is normally a user's username, but falls back to a first/last
  213. // name as available.
  214. func (u *User) String() string {
  215. if u == nil {
  216. return ""
  217. }
  218. if u.UserName != "" {
  219. return u.UserName
  220. }
  221. name := u.FirstName
  222. if u.LastName != "" {
  223. name += " " + u.LastName
  224. }
  225. return name
  226. }
  227. // Chat represents a chat.
  228. type Chat struct {
  229. // ID is a unique identifier for this chat
  230. ID int64 `json:"id"`
  231. // Type of chat, can be either “private”, “group”, “supergroup” or “channel”
  232. Type string `json:"type"`
  233. // Title for supergroups, channels and group chats
  234. //
  235. // optional
  236. Title string `json:"title,omitempty"`
  237. // UserName for private chats, supergroups and channels if available
  238. //
  239. // optional
  240. UserName string `json:"username,omitempty"`
  241. // FirstName of the other party in a private chat
  242. //
  243. // optional
  244. FirstName string `json:"first_name,omitempty"`
  245. // LastName of the other party in a private chat
  246. //
  247. // optional
  248. LastName string `json:"last_name,omitempty"`
  249. // Photo is a chat photo
  250. Photo *ChatPhoto `json:"photo"`
  251. // Bio is the bio of the other party in a private chat. Returned only in
  252. // getChat
  253. //
  254. // optional
  255. Bio string `json:"bio,omitempty"`
  256. // HasPrivateForwards is true if privacy settings of the other party in the
  257. // private chat allows to use tg://user?id=<user_id> links only in chats
  258. // with the user. Returned only in getChat.
  259. //
  260. // optional
  261. HasPrivateForwards bool `json:"has_private_forwards,omitempty"`
  262. // Description for groups, supergroups and channel chats
  263. //
  264. // optional
  265. Description string `json:"description,omitempty"`
  266. // InviteLink is a chat invite link, for groups, supergroups and channel chats.
  267. // Each administrator in a chat generates their own invite links,
  268. // so the bot must first generate the link using exportChatInviteLink
  269. //
  270. // optional
  271. InviteLink string `json:"invite_link,omitempty"`
  272. // PinnedMessage is the pinned message, for groups, supergroups and channels
  273. //
  274. // optional
  275. PinnedMessage *Message `json:"pinned_message,omitempty"`
  276. // Permissions are default chat member permissions, for groups and
  277. // supergroups. Returned only in getChat.
  278. //
  279. // optional
  280. Permissions *ChatPermissions `json:"permissions,omitempty"`
  281. // SlowModeDelay is for supergroups, the minimum allowed delay between
  282. // consecutive messages sent by each unprivileged user. Returned only in
  283. // getChat.
  284. //
  285. // optional
  286. SlowModeDelay int `json:"slow_mode_delay,omitempty"`
  287. // MessageAutoDeleteTime is the time after which all messages sent to the
  288. // chat will be automatically deleted; in seconds. Returned only in getChat.
  289. //
  290. // optional
  291. MessageAutoDeleteTime int `json:"message_auto_delete_time,omitempty"`
  292. // HasProtectedContent is true if messages from the chat can't be forwarded
  293. // to other chats. Returned only in getChat.
  294. //
  295. // optional
  296. HasProtectedContent bool `json:"has_protected_content,omitempty"`
  297. // StickerSetName is for supergroups, name of group sticker set.Returned
  298. // only in getChat.
  299. //
  300. // optional
  301. StickerSetName string `json:"sticker_set_name,omitempty"`
  302. // CanSetStickerSet is true, if the bot can change the group sticker set.
  303. // Returned only in getChat.
  304. //
  305. // optional
  306. CanSetStickerSet bool `json:"can_set_sticker_set,omitempty"`
  307. // LinkedChatID is a unique identifier for the linked chat, i.e. the
  308. // discussion group identifier for a channel and vice versa; for supergroups
  309. // and channel chats.
  310. //
  311. // optional
  312. LinkedChatID int64 `json:"linked_chat_id,omitempty"`
  313. // Location is for supergroups, the location to which the supergroup is
  314. // connected. Returned only in getChat.
  315. //
  316. // optional
  317. Location *ChatLocation `json:"location,omitempty"`
  318. }
  319. // IsPrivate returns if the Chat is a private conversation.
  320. func (c Chat) IsPrivate() bool {
  321. return c.Type == "private"
  322. }
  323. // IsGroup returns if the Chat is a group.
  324. func (c Chat) IsGroup() bool {
  325. return c.Type == "group"
  326. }
  327. // IsSuperGroup returns if the Chat is a supergroup.
  328. func (c Chat) IsSuperGroup() bool {
  329. return c.Type == "supergroup"
  330. }
  331. // IsChannel returns if the Chat is a channel.
  332. func (c Chat) IsChannel() bool {
  333. return c.Type == "channel"
  334. }
  335. // ChatConfig returns a ChatConfig struct for chat related methods.
  336. func (c Chat) ChatConfig() ChatConfig {
  337. return ChatConfig{ChatID: c.ID}
  338. }
  339. // Message represents a message.
  340. type Message struct {
  341. // MessageID is a unique message identifier inside this chat
  342. MessageID int `json:"message_id"`
  343. // From is a sender, empty for messages sent to channels;
  344. //
  345. // optional
  346. From *User `json:"from,omitempty"`
  347. // SenderChat is the sender of the message, sent on behalf of a chat. The
  348. // channel itself for channel messages. The supergroup itself for messages
  349. // from anonymous group administrators. The linked channel for messages
  350. // automatically forwarded to the discussion group
  351. //
  352. // optional
  353. SenderChat *Chat `json:"sender_chat,omitempty"`
  354. // Date of the message was sent in Unix time
  355. Date int `json:"date"`
  356. // Chat is the conversation the message belongs to
  357. Chat *Chat `json:"chat"`
  358. // ForwardFrom for forwarded messages, sender of the original message;
  359. //
  360. // optional
  361. ForwardFrom *User `json:"forward_from,omitempty"`
  362. // ForwardFromChat for messages forwarded from channels,
  363. // information about the original channel;
  364. //
  365. // optional
  366. ForwardFromChat *Chat `json:"forward_from_chat,omitempty"`
  367. // ForwardFromMessageID for messages forwarded from channels,
  368. // identifier of the original message in the channel;
  369. //
  370. // optional
  371. ForwardFromMessageID int `json:"forward_from_message_id,omitempty"`
  372. // ForwardSignature for messages forwarded from channels, signature of the
  373. // post author if present
  374. //
  375. // optional
  376. ForwardSignature string `json:"forward_signature,omitempty"`
  377. // ForwardSenderName is the sender's name for messages forwarded from users
  378. // who disallow adding a link to their account in forwarded messages
  379. //
  380. // optional
  381. ForwardSenderName string `json:"forward_sender_name,omitempty"`
  382. // ForwardDate for forwarded messages, date the original message was sent in Unix time;
  383. //
  384. // optional
  385. ForwardDate int `json:"forward_date,omitempty"`
  386. // IsAutomaticForward is true if the message is a channel post that was
  387. // automatically forwarded to the connected discussion group.
  388. //
  389. // optional
  390. IsAutomaticForward bool `json:"is_automatic_forward,omitempty"`
  391. // ReplyToMessage for replies, the original message.
  392. // Note that the Message object in this field will not contain further ReplyToMessage fields
  393. // even if it itself is a reply;
  394. //
  395. // optional
  396. ReplyToMessage *Message `json:"reply_to_message,omitempty"`
  397. // ViaBot through which the message was sent;
  398. //
  399. // optional
  400. ViaBot *User `json:"via_bot,omitempty"`
  401. // EditDate of the message was last edited in Unix time;
  402. //
  403. // optional
  404. EditDate int `json:"edit_date,omitempty"`
  405. // HasProtectedContent is true if the message can't be forwarded.
  406. //
  407. // optional
  408. HasProtectedContent bool `json:"has_protected_content,omitempty"`
  409. // MediaGroupID is the unique identifier of a media message group this message belongs to;
  410. //
  411. // optional
  412. MediaGroupID string `json:"media_group_id,omitempty"`
  413. // AuthorSignature is the signature of the post author for messages in channels;
  414. //
  415. // optional
  416. AuthorSignature string `json:"author_signature,omitempty"`
  417. // Text is for text messages, the actual UTF-8 text of the message, 0-4096 characters;
  418. //
  419. // optional
  420. Text string `json:"text,omitempty"`
  421. // Entities are for text messages, special entities like usernames,
  422. // URLs, bot commands, etc. that appear in the text;
  423. //
  424. // optional
  425. Entities []MessageEntity `json:"entities,omitempty"`
  426. // Animation message is an animation, information about the animation.
  427. // For backward compatibility, when this field is set, the document field will also be set;
  428. //
  429. // optional
  430. Animation *Animation `json:"animation,omitempty"`
  431. // PremiumAnimation message is an animation, information about the animation.
  432. // For backward compatibility, when this field is set, the document field will also be set;
  433. //
  434. // optional
  435. PremiumAnimation *Animation `json:"premium_animation,omitempty"`
  436. // Audio message is an audio file, information about the file;
  437. //
  438. // optional
  439. Audio *Audio `json:"audio,omitempty"`
  440. // Document message is a general file, information about the file;
  441. //
  442. // optional
  443. Document *Document `json:"document,omitempty"`
  444. // Photo message is a photo, available sizes of the photo;
  445. //
  446. // optional
  447. Photo []PhotoSize `json:"photo,omitempty"`
  448. // Sticker message is a sticker, information about the sticker;
  449. //
  450. // optional
  451. Sticker *Sticker `json:"sticker,omitempty"`
  452. // Video message is a video, information about the video;
  453. //
  454. // optional
  455. Video *Video `json:"video,omitempty"`
  456. // VideoNote message is a video note, information about the video message;
  457. //
  458. // optional
  459. VideoNote *VideoNote `json:"video_note,omitempty"`
  460. // Voice message is a voice message, information about the file;
  461. //
  462. // optional
  463. Voice *Voice `json:"voice,omitempty"`
  464. // Caption for the animation, audio, document, photo, video or voice, 0-1024 characters;
  465. //
  466. // optional
  467. Caption string `json:"caption,omitempty"`
  468. // CaptionEntities;
  469. //
  470. // optional
  471. CaptionEntities []MessageEntity `json:"caption_entities,omitempty"`
  472. // Contact message is a shared contact, information about the contact;
  473. //
  474. // optional
  475. Contact *Contact `json:"contact,omitempty"`
  476. // Dice is a dice with random value;
  477. //
  478. // optional
  479. Dice *Dice `json:"dice,omitempty"`
  480. // Game message is a game, information about the game;
  481. //
  482. // optional
  483. Game *Game `json:"game,omitempty"`
  484. // Poll is a native poll, information about the poll;
  485. //
  486. // optional
  487. Poll *Poll `json:"poll,omitempty"`
  488. // Venue message is a venue, information about the venue.
  489. // For backward compatibility, when this field is set, the location field
  490. // will also be set;
  491. //
  492. // optional
  493. Venue *Venue `json:"venue,omitempty"`
  494. // Location message is a shared location, information about the location;
  495. //
  496. // optional
  497. Location *Location `json:"location,omitempty"`
  498. // NewChatMembers that were added to the group or supergroup
  499. // and information about them (the bot itself may be one of these members);
  500. //
  501. // optional
  502. NewChatMembers []User `json:"new_chat_members,omitempty"`
  503. // LeftChatMember is a member was removed from the group,
  504. // information about them (this member may be the bot itself);
  505. //
  506. // optional
  507. LeftChatMember *User `json:"left_chat_member,omitempty"`
  508. // NewChatTitle is a chat title was changed to this value;
  509. //
  510. // optional
  511. NewChatTitle string `json:"new_chat_title,omitempty"`
  512. // NewChatPhoto is a chat photo was change to this value;
  513. //
  514. // optional
  515. NewChatPhoto []PhotoSize `json:"new_chat_photo,omitempty"`
  516. // DeleteChatPhoto is a service message: the chat photo was deleted;
  517. //
  518. // optional
  519. DeleteChatPhoto bool `json:"delete_chat_photo,omitempty"`
  520. // GroupChatCreated is a service message: the group has been created;
  521. //
  522. // optional
  523. GroupChatCreated bool `json:"group_chat_created,omitempty"`
  524. // SuperGroupChatCreated is a service message: the supergroup has been created.
  525. // This field can't be received in a message coming through updates,
  526. // because bot can't be a member of a supergroup when it is created.
  527. // It can only be found in ReplyToMessage if someone replies to a very first message
  528. // in a directly created supergroup;
  529. //
  530. // optional
  531. SuperGroupChatCreated bool `json:"supergroup_chat_created,omitempty"`
  532. // ChannelChatCreated is a service message: the channel has been created.
  533. // This field can't be received in a message coming through updates,
  534. // because bot can't be a member of a channel when it is created.
  535. // It can only be found in ReplyToMessage
  536. // if someone replies to a very first message in a channel;
  537. //
  538. // optional
  539. ChannelChatCreated bool `json:"channel_chat_created,omitempty"`
  540. // MessageAutoDeleteTimerChanged is a service message: auto-delete timer
  541. // settings changed in the chat.
  542. //
  543. // optional
  544. MessageAutoDeleteTimerChanged *MessageAutoDeleteTimerChanged `json:"message_auto_delete_timer_changed,omitempty"`
  545. // MigrateToChatID is the group has been migrated to a supergroup with the specified identifier.
  546. // This number may be greater than 32 bits and some programming languages
  547. // may have difficulty/silent defects in interpreting it.
  548. // But it is smaller than 52 bits, so a signed 64-bit integer
  549. // or double-precision float type are safe for storing this identifier;
  550. //
  551. // optional
  552. MigrateToChatID int64 `json:"migrate_to_chat_id,omitempty"`
  553. // MigrateFromChatID is the supergroup has been migrated from a group with the specified identifier.
  554. // This number may be greater than 32 bits and some programming languages
  555. // may have difficulty/silent defects in interpreting it.
  556. // But it is smaller than 52 bits, so a signed 64-bit integer
  557. // or double-precision float type are safe for storing this identifier;
  558. //
  559. // optional
  560. MigrateFromChatID int64 `json:"migrate_from_chat_id,omitempty"`
  561. // PinnedMessage is a specified message was pinned.
  562. // Note that the Message object in this field will not contain further ReplyToMessage
  563. // fields even if it is itself a reply;
  564. //
  565. // optional
  566. PinnedMessage *Message `json:"pinned_message,omitempty"`
  567. // Invoice message is an invoice for a payment;
  568. //
  569. // optional
  570. Invoice *Invoice `json:"invoice,omitempty"`
  571. // SuccessfulPayment message is a service message about a successful payment,
  572. // information about the payment;
  573. //
  574. // optional
  575. SuccessfulPayment *SuccessfulPayment `json:"successful_payment,omitempty"`
  576. // ConnectedWebsite is the domain name of the website on which the user has
  577. // logged in;
  578. //
  579. // optional
  580. ConnectedWebsite string `json:"connected_website,omitempty"`
  581. // PassportData is a Telegram Passport data;
  582. //
  583. // optional
  584. PassportData *PassportData `json:"passport_data,omitempty"`
  585. // ProximityAlertTriggered is a service message. A user in the chat
  586. // triggered another user's proximity alert while sharing Live Location
  587. //
  588. // optional
  589. ProximityAlertTriggered *ProximityAlertTriggered `json:"proximity_alert_triggered,omitempty"`
  590. // VideoChatScheduled is a service message: video chat scheduled.
  591. //
  592. // optional
  593. VideoChatScheduled *VideoChatScheduled `json:"video_chat_scheduled,omitempty"`
  594. // VideoChatStarted is a service message: video chat started.
  595. //
  596. // optional
  597. VideoChatStarted *VideoChatStarted `json:"video_chat_started,omitempty"`
  598. // VideoChatEnded is a service message: video chat ended.
  599. //
  600. // optional
  601. VideoChatEnded *VideoChatEnded `json:"video_chat_ended,omitempty"`
  602. // VideoChatParticipantsInvited is a service message: new participants
  603. // invited to a video chat.
  604. //
  605. // optional
  606. VideoChatParticipantsInvited *VideoChatParticipantsInvited `json:"video_chat_participants_invited,omitempty"`
  607. // WebAppData is a service message: data sent by a Web App.
  608. //
  609. // optional
  610. WebAppData *WebAppData `json:"web_app_data,omitempty"`
  611. // ReplyMarkup is the Inline keyboard attached to the message.
  612. // login_url buttons are represented as ordinary url buttons.
  613. //
  614. // optional
  615. ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"`
  616. }
  617. // Time converts the message timestamp into a Time.
  618. func (m *Message) Time() time.Time {
  619. return time.Unix(int64(m.Date), 0)
  620. }
  621. // IsCommand returns true if message starts with a "bot_command" entity.
  622. func (m *Message) IsCommand() bool {
  623. if m.Entities == nil || len(m.Entities) == 0 {
  624. return false
  625. }
  626. entity := m.Entities[0]
  627. return entity.Offset == 0 && entity.IsCommand()
  628. }
  629. // Command checks if the message was a command and if it was, returns the
  630. // command. If the Message was not a command, it returns an empty string.
  631. //
  632. // If the command contains the at name syntax, it is removed. Use
  633. // CommandWithAt() if you do not want that.
  634. func (m *Message) Command() string {
  635. command := m.CommandWithAt()
  636. if i := strings.Index(command, "@"); i != -1 {
  637. command = command[:i]
  638. }
  639. return command
  640. }
  641. // CommandWithAt checks if the message was a command and if it was, returns the
  642. // command. If the Message was not a command, it returns an empty string.
  643. //
  644. // If the command contains the at name syntax, it is not removed. Use Command()
  645. // if you want that.
  646. func (m *Message) CommandWithAt() string {
  647. if !m.IsCommand() {
  648. return ""
  649. }
  650. // IsCommand() checks that the message begins with a bot_command entity
  651. entity := m.Entities[0]
  652. return m.Text[1:entity.Length]
  653. }
  654. // CommandArguments checks if the message was a command and if it was,
  655. // returns all text after the command name. If the Message was not a
  656. // command, it returns an empty string.
  657. //
  658. // Note: The first character after the command name is omitted:
  659. // - "/foo bar baz" yields "bar baz", not " bar baz"
  660. // - "/foo-bar baz" yields "bar baz", too
  661. // Even though the latter is not a command conforming to the spec, the API
  662. // marks "/foo" as command entity.
  663. func (m *Message) CommandArguments() string {
  664. if !m.IsCommand() {
  665. return ""
  666. }
  667. // IsCommand() checks that the message begins with a bot_command entity
  668. entity := m.Entities[0]
  669. if len(m.Text) == entity.Length {
  670. return "" // The command makes up the whole message
  671. }
  672. return m.Text[entity.Length+1:]
  673. }
  674. // MessageID represents a unique message identifier.
  675. type MessageID struct {
  676. MessageID int `json:"message_id"`
  677. }
  678. // MessageEntity represents one special entity in a text message.
  679. type MessageEntity struct {
  680. // Type of the entity.
  681. // Can be:
  682. // “mention” (@username),
  683. // “hashtag” (#hashtag),
  684. // “cashtag” ($USD),
  685. // “bot_command” (/start@jobs_bot),
  686. // “url” (https://telegram.org),
  687. // “email” (do-not-reply@telegram.org),
  688. // “phone_number” (+1-212-555-0123),
  689. // “bold” (bold text),
  690. // “italic” (italic text),
  691. // “underline” (underlined text),
  692. // “strikethrough” (strikethrough text),
  693. // "spoiler" (spoiler message),
  694. // “code” (monowidth string),
  695. // “pre” (monowidth block),
  696. // “text_link” (for clickable text URLs),
  697. // “text_mention” (for users without usernames)
  698. Type string `json:"type"`
  699. // Offset in UTF-16 code units to the start of the entity
  700. Offset int `json:"offset"`
  701. // Length
  702. Length int `json:"length"`
  703. // URL for “text_link” only, url that will be opened after user taps on the text
  704. //
  705. // optional
  706. URL string `json:"url,omitempty"`
  707. // User for “text_mention” only, the mentioned user
  708. //
  709. // optional
  710. User *User `json:"user,omitempty"`
  711. // Language for “pre” only, the programming language of the entity text
  712. //
  713. // optional
  714. Language string `json:"language,omitempty"`
  715. }
  716. // ParseURL attempts to parse a URL contained within a MessageEntity.
  717. func (e MessageEntity) ParseURL() (*url.URL, error) {
  718. if e.URL == "" {
  719. return nil, errors.New(ErrBadURL)
  720. }
  721. return url.Parse(e.URL)
  722. }
  723. // IsMention returns true if the type of the message entity is "mention" (@username).
  724. func (e MessageEntity) IsMention() bool {
  725. return e.Type == "mention"
  726. }
  727. // IsTextMention returns true if the type of the message entity is "text_mention"
  728. // (At this time, the user field exists, and occurs when tagging a member without a username)
  729. func (e MessageEntity) IsTextMention() bool {
  730. return e.Type == "text_mention"
  731. }
  732. // IsHashtag returns true if the type of the message entity is "hashtag".
  733. func (e MessageEntity) IsHashtag() bool {
  734. return e.Type == "hashtag"
  735. }
  736. // IsCommand returns true if the type of the message entity is "bot_command".
  737. func (e MessageEntity) IsCommand() bool {
  738. return e.Type == "bot_command"
  739. }
  740. // IsURL returns true if the type of the message entity is "url".
  741. func (e MessageEntity) IsURL() bool {
  742. return e.Type == "url"
  743. }
  744. // IsEmail returns true if the type of the message entity is "email".
  745. func (e MessageEntity) IsEmail() bool {
  746. return e.Type == "email"
  747. }
  748. // IsBold returns true if the type of the message entity is "bold" (bold text).
  749. func (e MessageEntity) IsBold() bool {
  750. return e.Type == "bold"
  751. }
  752. // IsItalic returns true if the type of the message entity is "italic" (italic text).
  753. func (e MessageEntity) IsItalic() bool {
  754. return e.Type == "italic"
  755. }
  756. // IsCode returns true if the type of the message entity is "code" (monowidth string).
  757. func (e MessageEntity) IsCode() bool {
  758. return e.Type == "code"
  759. }
  760. // IsPre returns true if the type of the message entity is "pre" (monowidth block).
  761. func (e MessageEntity) IsPre() bool {
  762. return e.Type == "pre"
  763. }
  764. // IsTextLink returns true if the type of the message entity is "text_link" (clickable text URL).
  765. func (e MessageEntity) IsTextLink() bool {
  766. return e.Type == "text_link"
  767. }
  768. // PhotoSize represents one size of a photo or a file / sticker thumbnail.
  769. type PhotoSize struct {
  770. // FileID identifier for this file, which can be used to download or reuse
  771. // the file
  772. FileID string `json:"file_id"`
  773. // FileUniqueID is the unique identifier for this file, which is supposed to
  774. // be the same over time and for different bots. Can't be used to download
  775. // or reuse the file.
  776. FileUniqueID string `json:"file_unique_id"`
  777. // Width photo width
  778. Width int `json:"width"`
  779. // Height photo height
  780. Height int `json:"height"`
  781. // FileSize file size
  782. //
  783. // optional
  784. FileSize int `json:"file_size,omitempty"`
  785. }
  786. // Animation represents an animation file.
  787. type Animation struct {
  788. // FileID is the identifier for this file, which can be used to download or reuse
  789. // the file
  790. FileID string `json:"file_id"`
  791. // FileUniqueID is the unique identifier for this file, which is supposed to
  792. // be the same over time and for different bots. Can't be used to download
  793. // or reuse the file.
  794. FileUniqueID string `json:"file_unique_id"`
  795. // Width video width as defined by sender
  796. Width int `json:"width"`
  797. // Height video height as defined by sender
  798. Height int `json:"height"`
  799. // Duration of the video in seconds as defined by sender
  800. Duration int `json:"duration"`
  801. // Thumbnail animation thumbnail as defined by sender
  802. //
  803. // optional
  804. Thumbnail *PhotoSize `json:"thumb,omitempty"`
  805. // FileName original animation filename as defined by sender
  806. //
  807. // optional
  808. FileName string `json:"file_name,omitempty"`
  809. // MimeType of the file as defined by sender
  810. //
  811. // optional
  812. MimeType string `json:"mime_type,omitempty"`
  813. // FileSize file size
  814. //
  815. // optional
  816. FileSize int `json:"file_size,omitempty"`
  817. }
  818. // Audio represents an audio file to be treated as music by the Telegram clients.
  819. type Audio struct {
  820. // FileID is an identifier for this file, which can be used to download or
  821. // reuse the file
  822. FileID string `json:"file_id"`
  823. // FileUniqueID is the unique identifier for this file, which is supposed to
  824. // be the same over time and for different bots. Can't be used to download
  825. // or reuse the file.
  826. FileUniqueID string `json:"file_unique_id"`
  827. // Duration of the audio in seconds as defined by sender
  828. Duration int `json:"duration"`
  829. // Performer of the audio as defined by sender or by audio tags
  830. //
  831. // optional
  832. Performer string `json:"performer,omitempty"`
  833. // Title of the audio as defined by sender or by audio tags
  834. //
  835. // optional
  836. Title string `json:"title,omitempty"`
  837. // FileName is the original filename as defined by sender
  838. //
  839. // optional
  840. FileName string `json:"file_name,omitempty"`
  841. // MimeType of the file as defined by sender
  842. //
  843. // optional
  844. MimeType string `json:"mime_type,omitempty"`
  845. // FileSize file size
  846. //
  847. // optional
  848. FileSize int `json:"file_size,omitempty"`
  849. // Thumbnail is the album cover to which the music file belongs
  850. //
  851. // optional
  852. Thumbnail *PhotoSize `json:"thumb,omitempty"`
  853. }
  854. // Document represents a general file.
  855. type Document struct {
  856. // FileID is an identifier for this file, which can be used to download or
  857. // reuse the file
  858. FileID string `json:"file_id"`
  859. // FileUniqueID is the unique identifier for this file, which is supposed to
  860. // be the same over time and for different bots. Can't be used to download
  861. // or reuse the file.
  862. FileUniqueID string `json:"file_unique_id"`
  863. // Thumbnail document thumbnail as defined by sender
  864. //
  865. // optional
  866. Thumbnail *PhotoSize `json:"thumb,omitempty"`
  867. // FileName original filename as defined by sender
  868. //
  869. // optional
  870. FileName string `json:"file_name,omitempty"`
  871. // MimeType of the file as defined by sender
  872. //
  873. // optional
  874. MimeType string `json:"mime_type,omitempty"`
  875. // FileSize file size
  876. //
  877. // optional
  878. FileSize int `json:"file_size,omitempty"`
  879. }
  880. // Video represents a video file.
  881. type Video struct {
  882. // FileID identifier for this file, which can be used to download or reuse
  883. // the file
  884. FileID string `json:"file_id"`
  885. // FileUniqueID is the unique identifier for this file, which is supposed to
  886. // be the same over time and for different bots. Can't be used to download
  887. // or reuse the file.
  888. FileUniqueID string `json:"file_unique_id"`
  889. // Width video width as defined by sender
  890. Width int `json:"width"`
  891. // Height video height as defined by sender
  892. Height int `json:"height"`
  893. // Duration of the video in seconds as defined by sender
  894. Duration int `json:"duration"`
  895. // Thumbnail video thumbnail
  896. //
  897. // optional
  898. Thumbnail *PhotoSize `json:"thumb,omitempty"`
  899. // FileName is the original filename as defined by sender
  900. //
  901. // optional
  902. FileName string `json:"file_name,omitempty"`
  903. // MimeType of a file as defined by sender
  904. //
  905. // optional
  906. MimeType string `json:"mime_type,omitempty"`
  907. // FileSize file size
  908. //
  909. // optional
  910. FileSize int `json:"file_size,omitempty"`
  911. }
  912. // VideoNote object represents a video message.
  913. type VideoNote struct {
  914. // FileID identifier for this file, which can be used to download or reuse the file
  915. FileID string `json:"file_id"`
  916. // FileUniqueID is the unique identifier for this file, which is supposed to
  917. // be the same over time and for different bots. Can't be used to download
  918. // or reuse the file.
  919. FileUniqueID string `json:"file_unique_id"`
  920. // Length video width and height (diameter of the video message) as defined by sender
  921. Length int `json:"length"`
  922. // Duration of the video in seconds as defined by sender
  923. Duration int `json:"duration"`
  924. // Thumbnail video thumbnail
  925. //
  926. // optional
  927. Thumbnail *PhotoSize `json:"thumb,omitempty"`
  928. // FileSize file size
  929. //
  930. // optional
  931. FileSize int `json:"file_size,omitempty"`
  932. }
  933. // Voice represents a voice note.
  934. type Voice struct {
  935. // FileID identifier for this file, which can be used to download or reuse the file
  936. FileID string `json:"file_id"`
  937. // FileUniqueID is the unique identifier for this file, which is supposed to
  938. // be the same over time and for different bots. Can't be used to download
  939. // or reuse the file.
  940. FileUniqueID string `json:"file_unique_id"`
  941. // Duration of the audio in seconds as defined by sender
  942. Duration int `json:"duration"`
  943. // MimeType of the file as defined by sender
  944. //
  945. // optional
  946. MimeType string `json:"mime_type,omitempty"`
  947. // FileSize file size
  948. //
  949. // optional
  950. FileSize int `json:"file_size,omitempty"`
  951. }
  952. // Contact represents a phone contact.
  953. //
  954. // Note that LastName and UserID may be empty.
  955. type Contact struct {
  956. // PhoneNumber contact's phone number
  957. PhoneNumber string `json:"phone_number"`
  958. // FirstName contact's first name
  959. FirstName string `json:"first_name"`
  960. // LastName contact's last name
  961. //
  962. // optional
  963. LastName string `json:"last_name,omitempty"`
  964. // UserID contact's user identifier in Telegram
  965. //
  966. // optional
  967. UserID int64 `json:"user_id,omitempty"`
  968. // VCard is additional data about the contact in the form of a vCard.
  969. //
  970. // optional
  971. VCard string `json:"vcard,omitempty"`
  972. }
  973. // Dice represents an animated emoji that displays a random value.
  974. type Dice struct {
  975. // Emoji on which the dice throw animation is based
  976. Emoji string `json:"emoji"`
  977. // Value of the dice
  978. Value int `json:"value"`
  979. }
  980. // PollOption contains information about one answer option in a poll.
  981. type PollOption struct {
  982. // Text is the option text, 1-100 characters
  983. Text string `json:"text"`
  984. // VoterCount is the number of users that voted for this option
  985. VoterCount int `json:"voter_count"`
  986. }
  987. // PollAnswer represents an answer of a user in a non-anonymous poll.
  988. type PollAnswer struct {
  989. // PollID is the unique poll identifier
  990. PollID string `json:"poll_id"`
  991. // User who changed the answer to the poll
  992. User User `json:"user"`
  993. // OptionIDs is the 0-based identifiers of poll options chosen by the user.
  994. // May be empty if user retracted vote.
  995. OptionIDs []int `json:"option_ids"`
  996. }
  997. // Poll contains information about a poll.
  998. type Poll struct {
  999. // ID is the unique poll identifier
  1000. ID string `json:"id"`
  1001. // Question is the poll question, 1-255 characters
  1002. Question string `json:"question"`
  1003. // Options is the list of poll options
  1004. Options []PollOption `json:"options"`
  1005. // TotalVoterCount is the total numbers of users who voted in the poll
  1006. TotalVoterCount int `json:"total_voter_count"`
  1007. // IsClosed is if the poll is closed
  1008. IsClosed bool `json:"is_closed"`
  1009. // IsAnonymous is if the poll is anonymous
  1010. IsAnonymous bool `json:"is_anonymous"`
  1011. // Type is the poll type, currently can be "regular" or "quiz"
  1012. Type string `json:"type"`
  1013. // AllowsMultipleAnswers is true, if the poll allows multiple answers
  1014. AllowsMultipleAnswers bool `json:"allows_multiple_answers"`
  1015. // CorrectOptionID is the 0-based identifier of the correct answer option.
  1016. // Available only for polls in quiz mode, which are closed, or was sent (not
  1017. // forwarded) by the bot or to the private chat with the bot.
  1018. //
  1019. // optional
  1020. CorrectOptionID int `json:"correct_option_id,omitempty"`
  1021. // Explanation is text that is shown when a user chooses an incorrect answer
  1022. // or taps on the lamp icon in a quiz-style poll, 0-200 characters
  1023. //
  1024. // optional
  1025. Explanation string `json:"explanation,omitempty"`
  1026. // ExplanationEntities are special entities like usernames, URLs, bot
  1027. // commands, etc. that appear in the explanation
  1028. //
  1029. // optional
  1030. ExplanationEntities []MessageEntity `json:"explanation_entities,omitempty"`
  1031. // OpenPeriod is the amount of time in seconds the poll will be active
  1032. // after creation
  1033. //
  1034. // optional
  1035. OpenPeriod int `json:"open_period,omitempty"`
  1036. // CloseDate is the point in time (unix timestamp) when the poll will be
  1037. // automatically closed
  1038. //
  1039. // optional
  1040. CloseDate int `json:"close_date,omitempty"`
  1041. }
  1042. // Location represents a point on the map.
  1043. type Location struct {
  1044. // Longitude as defined by sender
  1045. Longitude float64 `json:"longitude"`
  1046. // Latitude as defined by sender
  1047. Latitude float64 `json:"latitude"`
  1048. // HorizontalAccuracy is the radius of uncertainty for the location,
  1049. // measured in meters; 0-1500
  1050. //
  1051. // optional
  1052. HorizontalAccuracy float64 `json:"horizontal_accuracy,omitempty"`
  1053. // LivePeriod is time relative to the message sending date, during which the
  1054. // location can be updated, in seconds. For active live locations only.
  1055. //
  1056. // optional
  1057. LivePeriod int `json:"live_period,omitempty"`
  1058. // Heading is the direction in which user is moving, in degrees; 1-360. For
  1059. // active live locations only.
  1060. //
  1061. // optional
  1062. Heading int `json:"heading,omitempty"`
  1063. // ProximityAlertRadius is the maximum distance for proximity alerts about
  1064. // approaching another chat member, in meters. For sent live locations only.
  1065. //
  1066. // optional
  1067. ProximityAlertRadius int `json:"proximity_alert_radius,omitempty"`
  1068. }
  1069. // Venue represents a venue.
  1070. type Venue struct {
  1071. // Location is the venue location
  1072. Location Location `json:"location"`
  1073. // Title is the name of the venue
  1074. Title string `json:"title"`
  1075. // Address of the venue
  1076. Address string `json:"address"`
  1077. // FoursquareID is the foursquare identifier of the venue
  1078. //
  1079. // optional
  1080. FoursquareID string `json:"foursquare_id,omitempty"`
  1081. // FoursquareType is the foursquare type of the venue
  1082. //
  1083. // optional
  1084. FoursquareType string `json:"foursquare_type,omitempty"`
  1085. // GooglePlaceID is the Google Places identifier of the venue
  1086. //
  1087. // optional
  1088. GooglePlaceID string `json:"google_place_id,omitempty"`
  1089. // GooglePlaceType is the Google Places type of the venue
  1090. //
  1091. // optional
  1092. GooglePlaceType string `json:"google_place_type,omitempty"`
  1093. }
  1094. // WebAppData Contains data sent from a Web App to the bot.
  1095. type WebAppData struct {
  1096. // Data is the data. Be aware that a bad client can send arbitrary data in this field.
  1097. Data string `json:"data"`
  1098. // ButtonText is the text of the web_app keyboard button, from which the Web App
  1099. // was opened. Be aware that a bad client can send arbitrary data in this field.
  1100. ButtonText string `json:"button_text"`
  1101. }
  1102. // ProximityAlertTriggered represents a service message sent when a user in the
  1103. // chat triggers a proximity alert sent by another user.
  1104. type ProximityAlertTriggered struct {
  1105. // Traveler is the user that triggered the alert
  1106. Traveler User `json:"traveler"`
  1107. // Watcher is the user that set the alert
  1108. Watcher User `json:"watcher"`
  1109. // Distance is the distance between the users
  1110. Distance int `json:"distance"`
  1111. }
  1112. // MessageAutoDeleteTimerChanged represents a service message about a change in
  1113. // auto-delete timer settings.
  1114. type MessageAutoDeleteTimerChanged struct {
  1115. // New auto-delete time for messages in the chat.
  1116. MessageAutoDeleteTime int `json:"message_auto_delete_time"`
  1117. }
  1118. // VideoChatScheduled represents a service message about a voice chat scheduled
  1119. // in the chat.
  1120. type VideoChatScheduled struct {
  1121. // Point in time (Unix timestamp) when the voice chat is supposed to be
  1122. // started by a chat administrator
  1123. StartDate int `json:"start_date"`
  1124. }
  1125. // Time converts the scheduled start date into a Time.
  1126. func (m *VideoChatScheduled) Time() time.Time {
  1127. return time.Unix(int64(m.StartDate), 0)
  1128. }
  1129. // VideoChatStarted represents a service message about a voice chat started in
  1130. // the chat.
  1131. type VideoChatStarted struct{}
  1132. // VideoChatEnded represents a service message about a voice chat ended in the
  1133. // chat.
  1134. type VideoChatEnded struct {
  1135. // Voice chat duration; in seconds.
  1136. Duration int `json:"duration"`
  1137. }
  1138. // VideoChatParticipantsInvited represents a service message about new members
  1139. // invited to a voice chat.
  1140. type VideoChatParticipantsInvited struct {
  1141. // New members that were invited to the voice chat.
  1142. //
  1143. // optional
  1144. Users []User `json:"users,omitempty"`
  1145. }
  1146. // UserProfilePhotos contains a set of user profile photos.
  1147. type UserProfilePhotos struct {
  1148. // TotalCount total number of profile pictures the target user has
  1149. TotalCount int `json:"total_count"`
  1150. // Photos requested profile pictures (in up to 4 sizes each)
  1151. Photos [][]PhotoSize `json:"photos"`
  1152. }
  1153. // File contains information about a file to download from Telegram.
  1154. type File struct {
  1155. // FileID identifier for this file, which can be used to download or reuse
  1156. // the file
  1157. FileID string `json:"file_id"`
  1158. // FileUniqueID is the unique identifier for this file, which is supposed to
  1159. // be the same over time and for different bots. Can't be used to download
  1160. // or reuse the file.
  1161. FileUniqueID string `json:"file_unique_id"`
  1162. // FileSize file size, if known
  1163. //
  1164. // optional
  1165. FileSize int `json:"file_size,omitempty"`
  1166. // FilePath file path
  1167. //
  1168. // optional
  1169. FilePath string `json:"file_path,omitempty"`
  1170. }
  1171. // Link returns a full path to the download URL for a File.
  1172. //
  1173. // It requires the Bot token to create the link.
  1174. func (f *File) Link(token string) string {
  1175. return fmt.Sprintf(FileEndpoint, token, f.FilePath)
  1176. }
  1177. // WebAppInfo contains information about a Web App.
  1178. type WebAppInfo struct {
  1179. // URL is the HTTPS URL of a Web App to be opened with additional data as
  1180. // specified in Initializing Web Apps.
  1181. URL string `json:"url"`
  1182. }
  1183. // ReplyKeyboardMarkup represents a custom keyboard with reply options.
  1184. type ReplyKeyboardMarkup struct {
  1185. // Keyboard is an array of button rows, each represented by an Array of KeyboardButton objects
  1186. Keyboard [][]KeyboardButton `json:"keyboard"`
  1187. // ResizeKeyboard requests clients to resize the keyboard vertically for optimal fit
  1188. // (e.g., make the keyboard smaller if there are just two rows of buttons).
  1189. // Defaults to false, in which case the custom keyboard
  1190. // is always of the same height as the app's standard keyboard.
  1191. //
  1192. // optional
  1193. ResizeKeyboard bool `json:"resize_keyboard,omitempty"`
  1194. // OneTimeKeyboard requests clients to hide the keyboard as soon as it's been used.
  1195. // The keyboard will still be available, but clients will automatically display
  1196. // the usual letter-keyboard in the chat – the user can press a special button
  1197. // in the input field to see the custom keyboard again.
  1198. // Defaults to false.
  1199. //
  1200. // optional
  1201. OneTimeKeyboard bool `json:"one_time_keyboard,omitempty"`
  1202. // InputFieldPlaceholder is the placeholder to be shown in the input field when
  1203. // the keyboard is active; 1-64 characters.
  1204. //
  1205. // optional
  1206. InputFieldPlaceholder string `json:"input_field_placeholder,omitempty"`
  1207. // Selective use this parameter if you want to show the keyboard to specific users only.
  1208. // Targets:
  1209. // 1) users that are @mentioned in the text of the Message object;
  1210. // 2) if the bot's message is a reply (has Message.ReplyToMessage not nil), sender of the original message.
  1211. //
  1212. // Example: A user requests to change the bot's language,
  1213. // bot replies to the request with a keyboard to select the new language.
  1214. // Other users in the group don't see the keyboard.
  1215. //
  1216. // optional
  1217. Selective bool `json:"selective,omitempty"`
  1218. }
  1219. // KeyboardButton represents one button of the reply keyboard. For simple text
  1220. // buttons String can be used instead of this object to specify text of the
  1221. // button. Optional fields request_contact, request_location, and request_poll
  1222. // are mutually exclusive.
  1223. type KeyboardButton struct {
  1224. // Text of the button. If none of the optional fields are used,
  1225. // it will be sent as a message when the button is pressed.
  1226. Text string `json:"text"`
  1227. // RequestContact if True, the user's phone number will be sent
  1228. // as a contact when the button is pressed.
  1229. // Available in private chats only.
  1230. //
  1231. // optional
  1232. RequestContact bool `json:"request_contact,omitempty"`
  1233. // RequestLocation if True, the user's current location will be sent when
  1234. // the button is pressed.
  1235. // Available in private chats only.
  1236. //
  1237. // optional
  1238. RequestLocation bool `json:"request_location,omitempty"`
  1239. // RequestPoll if specified, the user will be asked to create a poll and send it
  1240. // to the bot when the button is pressed. Available in private chats only
  1241. //
  1242. // optional
  1243. RequestPoll *KeyboardButtonPollType `json:"request_poll,omitempty"`
  1244. // WebApp if specified, the described Web App will be launched when the button
  1245. // is pressed. The Web App will be able to send a “web_app_data” service
  1246. // message. Available in private chats only.
  1247. //
  1248. // optional
  1249. WebApp *WebAppInfo `json:"web_app,omitempty"`
  1250. }
  1251. // KeyboardButtonPollType represents type of poll, which is allowed to
  1252. // be created and sent when the corresponding button is pressed.
  1253. type KeyboardButtonPollType struct {
  1254. // Type is if quiz is passed, the user will be allowed to create only polls
  1255. // in the quiz mode. If regular is passed, only regular polls will be
  1256. // allowed. Otherwise, the user will be allowed to create a poll of any type.
  1257. Type string `json:"type"`
  1258. }
  1259. // ReplyKeyboardRemove Upon receiving a message with this object, Telegram
  1260. // clients will remove the current custom keyboard and display the default
  1261. // letter-keyboard. By default, custom keyboards are displayed until a new
  1262. // keyboard is sent by a bot. An exception is made for one-time keyboards
  1263. // that are hidden immediately after the user presses a button.
  1264. type ReplyKeyboardRemove struct {
  1265. // RemoveKeyboard requests clients to remove the custom keyboard
  1266. // (user will not be able to summon this keyboard;
  1267. // if you want to hide the keyboard from sight but keep it accessible,
  1268. // use one_time_keyboard in ReplyKeyboardMarkup).
  1269. RemoveKeyboard bool `json:"remove_keyboard"`
  1270. // Selective use this parameter if you want to remove the keyboard for specific users only.
  1271. // Targets:
  1272. // 1) users that are @mentioned in the text of the Message object;
  1273. // 2) if the bot's message is a reply (has Message.ReplyToMessage not nil), sender of the original message.
  1274. //
  1275. // Example: A user votes in a poll, bot returns confirmation message
  1276. // in reply to the vote and removes the keyboard for that user,
  1277. // while still showing the keyboard with poll options to users who haven't voted yet.
  1278. //
  1279. // optional
  1280. Selective bool `json:"selective,omitempty"`
  1281. }
  1282. // InlineKeyboardMarkup represents an inline keyboard that appears right next to
  1283. // the message it belongs to.
  1284. type InlineKeyboardMarkup struct {
  1285. // InlineKeyboard array of button rows, each represented by an Array of
  1286. // InlineKeyboardButton objects
  1287. InlineKeyboard [][]InlineKeyboardButton `json:"inline_keyboard"`
  1288. }
  1289. // InlineKeyboardButton represents one button of an inline keyboard. You must
  1290. // use exactly one of the optional fields.
  1291. //
  1292. // Note that some values are references as even an empty string
  1293. // will change behavior.
  1294. //
  1295. // CallbackGame, if set, MUST be first button in first row.
  1296. type InlineKeyboardButton struct {
  1297. // Text label text on the button
  1298. Text string `json:"text"`
  1299. // URL HTTP or tg:// url to be opened when button is pressed.
  1300. //
  1301. // optional
  1302. URL *string `json:"url,omitempty"`
  1303. // LoginURL is an HTTP URL used to automatically authorize the user. Can be
  1304. // used as a replacement for the Telegram Login Widget
  1305. //
  1306. // optional
  1307. LoginURL *LoginURL `json:"login_url,omitempty"`
  1308. // CallbackData data to be sent in a callback query to the bot when button is pressed, 1-64 bytes.
  1309. //
  1310. // optional
  1311. CallbackData *string `json:"callback_data,omitempty"`
  1312. // WebApp is the Description of the Web App that will be launched when the user presses the button.
  1313. // The Web App will be able to send an arbitrary message on behalf of the user using the method
  1314. // answerWebAppQuery. Available only in private chats between a user and the bot.
  1315. //
  1316. // optional
  1317. WebApp *WebAppInfo `json:"web_app,omitempty"`
  1318. // SwitchInlineQuery if set, pressing the button will prompt the user to select one of their chats,
  1319. // open that chat and insert the bot's username and the specified inline query in the input field.
  1320. // Can be empty, in which case just the bot's username will be inserted.
  1321. //
  1322. // This offers an easy way for users to start using your bot
  1323. // in inline mode when they are currently in a private chat with it.
  1324. // Especially useful when combined with switch_pm… actions – in this case
  1325. // the user will be automatically returned to the chat they switched from,
  1326. // skipping the chat selection screen.
  1327. //
  1328. // optional
  1329. SwitchInlineQuery *string `json:"switch_inline_query,omitempty"`
  1330. // SwitchInlineQueryCurrentChat if set, pressing the button will insert the bot's username
  1331. // and the specified inline query in the current chat's input field.
  1332. // Can be empty, in which case only the bot's username will be inserted.
  1333. //
  1334. // This offers a quick way for the user to open your bot in inline mode
  1335. // in the same chat – good for selecting something from multiple options.
  1336. //
  1337. // optional
  1338. SwitchInlineQueryCurrentChat *string `json:"switch_inline_query_current_chat,omitempty"`
  1339. // CallbackGame description of the game that will be launched when the user presses the button.
  1340. //
  1341. // optional
  1342. CallbackGame *CallbackGame `json:"callback_game,omitempty"`
  1343. // Pay specify True, to send a Pay button.
  1344. //
  1345. // NOTE: This type of button must always be the first button in the first row.
  1346. //
  1347. // optional
  1348. Pay bool `json:"pay,omitempty"`
  1349. }
  1350. // LoginURL represents a parameter of the inline keyboard button used to
  1351. // automatically authorize a user. Serves as a great replacement for the
  1352. // Telegram Login Widget when the user is coming from Telegram. All the user
  1353. // needs to do is tap/click a button and confirm that they want to log in.
  1354. type LoginURL struct {
  1355. // URL is an HTTP URL to be opened with user authorization data added to the
  1356. // query string when the button is pressed. If the user refuses to provide
  1357. // authorization data, the original URL without information about the user
  1358. // will be opened. The data added is the same as described in Receiving
  1359. // authorization data.
  1360. //
  1361. // NOTE: You must always check the hash of the received data to verify the
  1362. // authentication and the integrity of the data as described in Checking
  1363. // authorization.
  1364. URL string `json:"url"`
  1365. // ForwardText is the new text of the button in forwarded messages
  1366. //
  1367. // optional
  1368. ForwardText string `json:"forward_text,omitempty"`
  1369. // BotUsername is the username of a bot, which will be used for user
  1370. // authorization. See Setting up a bot for more details. If not specified,
  1371. // the current bot's username will be assumed. The url's domain must be the
  1372. // same as the domain linked with the bot. See Linking your domain to the
  1373. // bot for more details.
  1374. //
  1375. // optional
  1376. BotUsername string `json:"bot_username,omitempty"`
  1377. // RequestWriteAccess if true requests permission for your bot to send
  1378. // messages to the user
  1379. //
  1380. // optional
  1381. RequestWriteAccess bool `json:"request_write_access,omitempty"`
  1382. }
  1383. // CallbackQuery represents an incoming callback query from a callback button in
  1384. // an inline keyboard. If the button that originated the query was attached to a
  1385. // message sent by the bot, the field message will be present. If the button was
  1386. // attached to a message sent via the bot (in inline mode), the field
  1387. // inline_message_id will be present. Exactly one of the fields data or
  1388. // game_short_name will be present.
  1389. type CallbackQuery struct {
  1390. // ID unique identifier for this query
  1391. ID string `json:"id"`
  1392. // From sender
  1393. From *User `json:"from"`
  1394. // Message with the callback button that originated the query.
  1395. // Note that message content and message date will not be available if the
  1396. // message is too old.
  1397. //
  1398. // optional
  1399. Message *Message `json:"message,omitempty"`
  1400. // InlineMessageID identifier of the message sent via the bot in inline
  1401. // mode, that originated the query.
  1402. //
  1403. // optional
  1404. InlineMessageID string `json:"inline_message_id,omitempty"`
  1405. // ChatInstance global identifier, uniquely corresponding to the chat to
  1406. // which the message with the callback button was sent. Useful for high
  1407. // scores in games.
  1408. ChatInstance string `json:"chat_instance"`
  1409. // Data associated with the callback button. Be aware that
  1410. // a bad client can send arbitrary data in this field.
  1411. //
  1412. // optional
  1413. Data string `json:"data,omitempty"`
  1414. // GameShortName short name of a Game to be returned, serves as the unique identifier for the game.
  1415. //
  1416. // optional
  1417. GameShortName string `json:"game_short_name,omitempty"`
  1418. }
  1419. // ForceReply when receiving a message with this object, Telegram clients will
  1420. // display a reply interface to the user (act as if the user has selected the
  1421. // bot's message and tapped 'Reply'). This can be extremely useful if you want
  1422. // to create user-friendly step-by-step interfaces without having to sacrifice
  1423. // privacy mode.
  1424. type ForceReply struct {
  1425. // ForceReply shows reply interface to the user,
  1426. // as if they manually selected the bot's message and tapped 'Reply'.
  1427. ForceReply bool `json:"force_reply"`
  1428. // InputFieldPlaceholder is the placeholder to be shown in the input field when
  1429. // the reply is active; 1-64 characters.
  1430. //
  1431. // optional
  1432. InputFieldPlaceholder string `json:"input_field_placeholder,omitempty"`
  1433. // Selective use this parameter if you want to force reply from specific users only.
  1434. // Targets:
  1435. // 1) users that are @mentioned in the text of the Message object;
  1436. // 2) if the bot's message is a reply (has Message.ReplyToMessage not nil), sender of the original message.
  1437. //
  1438. // optional
  1439. Selective bool `json:"selective,omitempty"`
  1440. }
  1441. // ChatPhoto represents a chat photo.
  1442. type ChatPhoto struct {
  1443. // SmallFileID is a file identifier of small (160x160) chat photo.
  1444. // This file_id can be used only for photo download and
  1445. // only for as long as the photo is not changed.
  1446. SmallFileID string `json:"small_file_id"`
  1447. // SmallFileUniqueID is a unique file identifier of small (160x160) chat
  1448. // photo, which is supposed to be the same over time and for different bots.
  1449. // Can't be used to download or reuse the file.
  1450. SmallFileUniqueID string `json:"small_file_unique_id"`
  1451. // BigFileID is a file identifier of big (640x640) chat photo.
  1452. // This file_id can be used only for photo download and
  1453. // only for as long as the photo is not changed.
  1454. BigFileID string `json:"big_file_id"`
  1455. // BigFileUniqueID is a file identifier of big (640x640) chat photo, which
  1456. // is supposed to be the same over time and for different bots. Can't be
  1457. // used to download or reuse the file.
  1458. BigFileUniqueID string `json:"big_file_unique_id"`
  1459. }
  1460. // ChatInviteLink represents an invite link for a chat.
  1461. type ChatInviteLink struct {
  1462. // InviteLink is the invite link. If the link was created by another chat
  1463. // administrator, then the second part of the link will be replaced with “…”.
  1464. InviteLink string `json:"invite_link"`
  1465. // Creator of the link.
  1466. Creator User `json:"creator"`
  1467. // CreatesJoinRequest is true if users joining the chat via the link need to
  1468. // be approved by chat administrators.
  1469. //
  1470. // optional
  1471. CreatesJoinRequest bool `json:"creates_join_request,omitempty"`
  1472. // IsPrimary is true, if the link is primary.
  1473. IsPrimary bool `json:"is_primary"`
  1474. // IsRevoked is true, if the link is revoked.
  1475. IsRevoked bool `json:"is_revoked"`
  1476. // Name is the name of the invite link.
  1477. //
  1478. // optional
  1479. Name string `json:"name,omitempty"`
  1480. // ExpireDate is the point in time (Unix timestamp) when the link will
  1481. // expire or has been expired.
  1482. //
  1483. // optional
  1484. ExpireDate int `json:"expire_date,omitempty"`
  1485. // MemberLimit is the maximum number of users that can be members of the
  1486. // chat simultaneously after joining the chat via this invite link; 1-99999.
  1487. //
  1488. // optional
  1489. MemberLimit int `json:"member_limit,omitempty"`
  1490. // PendingJoinRequestCount is the number of pending join requests created
  1491. // using this link.
  1492. //
  1493. // optional
  1494. PendingJoinRequestCount int `json:"pending_join_request_count,omitempty"`
  1495. }
  1496. type ChatAdministratorRights struct {
  1497. IsAnonymous bool `json:"is_anonymous"`
  1498. CanManageChat bool `json:"can_manage_chat"`
  1499. CanDeleteMessages bool `json:"can_delete_messages"`
  1500. CanManageVideoChats bool `json:"can_manage_video_chats"`
  1501. CanRestrictMembers bool `json:"can_restrict_members"`
  1502. CanPromoteMembers bool `json:"can_promote_members"`
  1503. CanChangeInfo bool `json:"can_change_info"`
  1504. CanInviteUsers bool `json:"can_invite_users"`
  1505. CanPostMessages bool `json:"can_post_messages"`
  1506. CanEditMessages bool `json:"can_edit_messages"`
  1507. CanPinMessages bool `json:"can_pin_messages"`
  1508. }
  1509. // ChatMember contains information about one member of a chat.
  1510. type ChatMember struct {
  1511. // User information about the user
  1512. User *User `json:"user"`
  1513. // Status the member's status in the chat.
  1514. // Can be
  1515. // “creator”,
  1516. // “administrator”,
  1517. // “member”,
  1518. // “restricted”,
  1519. // “left” or
  1520. // “kicked”
  1521. Status string `json:"status"`
  1522. // CustomTitle owner and administrators only. Custom title for this user
  1523. //
  1524. // optional
  1525. CustomTitle string `json:"custom_title,omitempty"`
  1526. // IsAnonymous owner and administrators only. True, if the user's presence
  1527. // in the chat is hidden
  1528. //
  1529. // optional
  1530. IsAnonymous bool `json:"is_anonymous,omitempty"`
  1531. // UntilDate restricted and kicked only.
  1532. // Date when restrictions will be lifted for this user;
  1533. // unix time.
  1534. //
  1535. // optional
  1536. UntilDate int64 `json:"until_date,omitempty"`
  1537. // CanBeEdited administrators only.
  1538. // True, if the bot is allowed to edit administrator privileges of that user.
  1539. //
  1540. // optional
  1541. CanBeEdited bool `json:"can_be_edited,omitempty"`
  1542. // CanManageChat administrators only.
  1543. // True, if the administrator can access the chat event log, chat
  1544. // statistics, message statistics in channels, see channel members, see
  1545. // anonymous administrators in supergroups and ignore slow mode. Implied by
  1546. // any other administrator privilege.
  1547. //
  1548. // optional
  1549. CanManageChat bool `json:"can_manage_chat,omitempty"`
  1550. // CanPostMessages administrators only.
  1551. // True, if the administrator can post in the channel;
  1552. // channels only.
  1553. //
  1554. // optional
  1555. CanPostMessages bool `json:"can_post_messages,omitempty"`
  1556. // CanEditMessages administrators only.
  1557. // True, if the administrator can edit messages of other users and can pin messages;
  1558. // channels only.
  1559. //
  1560. // optional
  1561. CanEditMessages bool `json:"can_edit_messages,omitempty"`
  1562. // CanDeleteMessages administrators only.
  1563. // True, if the administrator can delete messages of other users.
  1564. //
  1565. // optional
  1566. CanDeleteMessages bool `json:"can_delete_messages,omitempty"`
  1567. // CanManageVideoChats administrators only.
  1568. // True, if the administrator can manage video chats.
  1569. //
  1570. // optional
  1571. CanManageVideoChats bool `json:"can_manage_video_chats,omitempty"`
  1572. // CanRestrictMembers administrators only.
  1573. // True, if the administrator can restrict, ban or unban chat members.
  1574. //
  1575. // optional
  1576. CanRestrictMembers bool `json:"can_restrict_members,omitempty"`
  1577. // CanPromoteMembers administrators only.
  1578. // True, if the administrator can add new administrators
  1579. // with a subset of their own privileges or demote administrators that he has promoted,
  1580. // directly or indirectly (promoted by administrators that were appointed by the user).
  1581. //
  1582. // optional
  1583. CanPromoteMembers bool `json:"can_promote_members,omitempty"`
  1584. // CanChangeInfo administrators and restricted only.
  1585. // True, if the user is allowed to change the chat title, photo and other settings.
  1586. //
  1587. // optional
  1588. CanChangeInfo bool `json:"can_change_info,omitempty"`
  1589. // CanInviteUsers administrators and restricted only.
  1590. // True, if the user is allowed to invite new users to the chat.
  1591. //
  1592. // optional
  1593. CanInviteUsers bool `json:"can_invite_users,omitempty"`
  1594. // CanPinMessages administrators and restricted only.
  1595. // True, if the user is allowed to pin messages; groups and supergroups only
  1596. //
  1597. // optional
  1598. CanPinMessages bool `json:"can_pin_messages,omitempty"`
  1599. // IsMember is true, if the user is a member of the chat at the moment of
  1600. // the request
  1601. IsMember bool `json:"is_member"`
  1602. // CanSendMessages
  1603. //
  1604. // optional
  1605. CanSendMessages bool `json:"can_send_messages,omitempty"`
  1606. // CanSendMediaMessages restricted only.
  1607. // True, if the user is allowed to send text messages, contacts, locations and venues
  1608. //
  1609. // optional
  1610. CanSendMediaMessages bool `json:"can_send_media_messages,omitempty"`
  1611. // CanSendPolls restricted only.
  1612. // True, if the user is allowed to send polls
  1613. //
  1614. // optional
  1615. CanSendPolls bool `json:"can_send_polls,omitempty"`
  1616. // CanSendOtherMessages restricted only.
  1617. // True, if the user is allowed to send audios, documents,
  1618. // photos, videos, video notes and voice notes.
  1619. //
  1620. // optional
  1621. CanSendOtherMessages bool `json:"can_send_other_messages,omitempty"`
  1622. // CanAddWebPagePreviews restricted only.
  1623. // True, if the user is allowed to add web page previews to their messages.
  1624. //
  1625. // optional
  1626. CanAddWebPagePreviews bool `json:"can_add_web_page_previews,omitempty"`
  1627. }
  1628. // IsCreator returns if the ChatMember was the creator of the chat.
  1629. func (chat ChatMember) IsCreator() bool { return chat.Status == "creator" }
  1630. // IsAdministrator returns if the ChatMember is a chat administrator.
  1631. func (chat ChatMember) IsAdministrator() bool { return chat.Status == "administrator" }
  1632. // HasLeft returns if the ChatMember left the chat.
  1633. func (chat ChatMember) HasLeft() bool { return chat.Status == "left" }
  1634. // WasKicked returns if the ChatMember was kicked from the chat.
  1635. func (chat ChatMember) WasKicked() bool { return chat.Status == "kicked" }
  1636. // ChatMemberUpdated represents changes in the status of a chat member.
  1637. type ChatMemberUpdated struct {
  1638. // Chat the user belongs to.
  1639. Chat Chat `json:"chat"`
  1640. // From is the performer of the action, which resulted in the change.
  1641. From User `json:"from"`
  1642. // Date the change was done in Unix time.
  1643. Date int `json:"date"`
  1644. // Previous information about the chat member.
  1645. OldChatMember ChatMember `json:"old_chat_member"`
  1646. // New information about the chat member.
  1647. NewChatMember ChatMember `json:"new_chat_member"`
  1648. // InviteLink is the link which was used by the user to join the chat;
  1649. // for joining by invite link events only.
  1650. //
  1651. // optional
  1652. InviteLink *ChatInviteLink `json:"invite_link,omitempty"`
  1653. }
  1654. // ChatJoinRequest represents a join request sent to a chat.
  1655. type ChatJoinRequest struct {
  1656. // Chat to which the request was sent.
  1657. Chat Chat `json:"chat"`
  1658. // User that sent the join request.
  1659. From User `json:"from"`
  1660. // Date the request was sent in Unix time.
  1661. Date int `json:"date"`
  1662. // Bio of the user.
  1663. //
  1664. // optional
  1665. Bio string `json:"bio,omitempty"`
  1666. // InviteLink is the link that was used by the user to send the join request.
  1667. //
  1668. // optional
  1669. InviteLink *ChatInviteLink `json:"invite_link,omitempty"`
  1670. }
  1671. // ChatPermissions describes actions that a non-administrator user is
  1672. // allowed to take in a chat. All fields are optional.
  1673. type ChatPermissions struct {
  1674. // CanSendMessages is true, if the user is allowed to send text messages,
  1675. // contacts, locations and venues
  1676. //
  1677. // optional
  1678. CanSendMessages bool `json:"can_send_messages,omitempty"`
  1679. // CanSendMediaMessages is true, if the user is allowed to send audios,
  1680. // documents, photos, videos, video notes and voice notes, implies
  1681. // can_send_messages
  1682. //
  1683. // optional
  1684. CanSendMediaMessages bool `json:"can_send_media_messages,omitempty"`
  1685. // CanSendPolls is true, if the user is allowed to send polls, implies
  1686. // can_send_messages
  1687. //
  1688. // optional
  1689. CanSendPolls bool `json:"can_send_polls,omitempty"`
  1690. // CanSendOtherMessages is true, if the user is allowed to send animations,
  1691. // games, stickers and use inline bots, implies can_send_media_messages
  1692. //
  1693. // optional
  1694. CanSendOtherMessages bool `json:"can_send_other_messages,omitempty"`
  1695. // CanAddWebPagePreviews is true, if the user is allowed to add web page
  1696. // previews to their messages, implies can_send_media_messages
  1697. //
  1698. // optional
  1699. CanAddWebPagePreviews bool `json:"can_add_web_page_previews,omitempty"`
  1700. // CanChangeInfo is true, if the user is allowed to change the chat title,
  1701. // photo and other settings. Ignored in public supergroups
  1702. //
  1703. // optional
  1704. CanChangeInfo bool `json:"can_change_info,omitempty"`
  1705. // CanInviteUsers is true, if the user is allowed to invite new users to the
  1706. // chat
  1707. //
  1708. // optional
  1709. CanInviteUsers bool `json:"can_invite_users,omitempty"`
  1710. // CanPinMessages is true, if the user is allowed to pin messages. Ignored
  1711. // in public supergroups
  1712. //
  1713. // optional
  1714. CanPinMessages bool `json:"can_pin_messages,omitempty"`
  1715. }
  1716. // ChatLocation represents a location to which a chat is connected.
  1717. type ChatLocation struct {
  1718. // Location is the location to which the supergroup is connected. Can't be a
  1719. // live location.
  1720. Location Location `json:"location"`
  1721. // Address is the location address; 1-64 characters, as defined by the chat
  1722. // owner
  1723. Address string `json:"address"`
  1724. }
  1725. // BotCommand represents a bot command.
  1726. type BotCommand struct {
  1727. // Command text of the command, 1-32 characters.
  1728. // Can contain only lowercase English letters, digits and underscores.
  1729. Command string `json:"command"`
  1730. // Description of the command, 3-256 characters.
  1731. Description string `json:"description"`
  1732. }
  1733. // BotCommandScope represents the scope to which bot commands are applied.
  1734. //
  1735. // It contains the fields for all types of scopes, different types only support
  1736. // specific (or no) fields.
  1737. type BotCommandScope struct {
  1738. Type string `json:"type"`
  1739. ChatID int64 `json:"chat_id,omitempty"`
  1740. UserID int64 `json:"user_id,omitempty"`
  1741. }
  1742. // MenuButton describes the bot's menu button in a private chat.
  1743. type MenuButton struct {
  1744. // Type is the type of menu button, must be one of:
  1745. // - `commands`
  1746. // - `web_app`
  1747. // - `default`
  1748. Type string `json:"type"`
  1749. // Text is the text on the button, for `web_app` type.
  1750. Text string `json:"text,omitempty"`
  1751. // WebApp is the description of the Web App that will be launched when the
  1752. // user presses the button for the `web_app` type.
  1753. WebApp *WebAppInfo `json:"web_app,omitempty"`
  1754. }
  1755. // ResponseParameters are various errors that can be returned in APIResponse.
  1756. type ResponseParameters struct {
  1757. // The group has been migrated to a supergroup with the specified identifier.
  1758. //
  1759. // optional
  1760. MigrateToChatID int64 `json:"migrate_to_chat_id,omitempty"`
  1761. // In case of exceeding flood control, the number of seconds left to wait
  1762. // before the request can be repeated.
  1763. //
  1764. // optional
  1765. RetryAfter int `json:"retry_after,omitempty"`
  1766. }
  1767. // BaseInputMedia is a base type for the InputMedia types.
  1768. type BaseInputMedia struct {
  1769. // Type of the result.
  1770. Type string `json:"type"`
  1771. // Media file to send. Pass a file_id to send a file
  1772. // that exists on the Telegram servers (recommended),
  1773. // pass an HTTP URL for Telegram to get a file from the Internet,
  1774. // or pass “attach://<file_attach_name>” to upload a new one
  1775. // using multipart/form-data under <file_attach_name> name.
  1776. Media RequestFileData `json:"media"`
  1777. // thumb intentionally missing as it is not currently compatible
  1778. // Caption of the video to be sent, 0-1024 characters after entities parsing.
  1779. //
  1780. // optional
  1781. Caption string `json:"caption,omitempty"`
  1782. // ParseMode mode for parsing entities in the video caption.
  1783. // See formatting options for more details
  1784. // (https://core.telegram.org/bots/api#formatting-options).
  1785. //
  1786. // optional
  1787. ParseMode string `json:"parse_mode,omitempty"`
  1788. // CaptionEntities is a list of special entities that appear in the caption,
  1789. // which can be specified instead of parse_mode
  1790. //
  1791. // optional
  1792. CaptionEntities []MessageEntity `json:"caption_entities,omitempty"`
  1793. }
  1794. // InputMediaPhoto is a photo to send as part of a media group.
  1795. type InputMediaPhoto struct {
  1796. BaseInputMedia
  1797. }
  1798. // InputMediaVideo is a video to send as part of a media group.
  1799. type InputMediaVideo struct {
  1800. BaseInputMedia
  1801. // Thumbnail of the file sent; can be ignored if thumbnail generation for
  1802. // the file is supported server-side.
  1803. //
  1804. // optional
  1805. Thumb RequestFileData `json:"thumb,omitempty"`
  1806. // Width video width
  1807. //
  1808. // optional
  1809. Width int `json:"width,omitempty"`
  1810. // Height video height
  1811. //
  1812. // optional
  1813. Height int `json:"height,omitempty"`
  1814. // Duration video duration
  1815. //
  1816. // optional
  1817. Duration int `json:"duration,omitempty"`
  1818. // SupportsStreaming pass True, if the uploaded video is suitable for streaming.
  1819. //
  1820. // optional
  1821. SupportsStreaming bool `json:"supports_streaming,omitempty"`
  1822. }
  1823. // InputMediaAnimation is an animation to send as part of a media group.
  1824. type InputMediaAnimation struct {
  1825. BaseInputMedia
  1826. // Thumbnail of the file sent; can be ignored if thumbnail generation for
  1827. // the file is supported server-side.
  1828. //
  1829. // optional
  1830. Thumb RequestFileData `json:"thumb,omitempty"`
  1831. // Width video width
  1832. //
  1833. // optional
  1834. Width int `json:"width,omitempty"`
  1835. // Height video height
  1836. //
  1837. // optional
  1838. Height int `json:"height,omitempty"`
  1839. // Duration video duration
  1840. //
  1841. // optional
  1842. Duration int `json:"duration,omitempty"`
  1843. }
  1844. // InputMediaAudio is an audio to send as part of a media group.
  1845. type InputMediaAudio struct {
  1846. BaseInputMedia
  1847. // Thumbnail of the file sent; can be ignored if thumbnail generation for
  1848. // the file is supported server-side.
  1849. //
  1850. // optional
  1851. Thumb RequestFileData `json:"thumb,omitempty"`
  1852. // Duration of the audio in seconds
  1853. //
  1854. // optional
  1855. Duration int `json:"duration,omitempty"`
  1856. // Performer of the audio
  1857. //
  1858. // optional
  1859. Performer string `json:"performer,omitempty"`
  1860. // Title of the audio
  1861. //
  1862. // optional
  1863. Title string `json:"title,omitempty"`
  1864. }
  1865. // InputMediaDocument is a general file to send as part of a media group.
  1866. type InputMediaDocument struct {
  1867. BaseInputMedia
  1868. // Thumbnail of the file sent; can be ignored if thumbnail generation for
  1869. // the file is supported server-side.
  1870. //
  1871. // optional
  1872. Thumb RequestFileData `json:"thumb,omitempty"`
  1873. // DisableContentTypeDetection disables automatic server-side content type
  1874. // detection for files uploaded using multipart/form-data. Always true, if
  1875. // the document is sent as part of an album
  1876. //
  1877. // optional
  1878. DisableContentTypeDetection bool `json:"disable_content_type_detection,omitempty"`
  1879. }
  1880. // Sticker represents a sticker.
  1881. type Sticker struct {
  1882. // FileID is an identifier for this file, which can be used to download or
  1883. // reuse the file
  1884. FileID string `json:"file_id"`
  1885. // FileUniqueID is a unique identifier for this file,
  1886. // which is supposed to be the same over time and for different bots.
  1887. // Can't be used to download or reuse the file.
  1888. FileUniqueID string `json:"file_unique_id"`
  1889. // Width sticker width
  1890. Width int `json:"width"`
  1891. // Height sticker height
  1892. Height int `json:"height"`
  1893. // IsAnimated true, if the sticker is animated
  1894. //
  1895. // optional
  1896. IsAnimated bool `json:"is_animated,omitempty"`
  1897. // IsVideo true, if the sticker is a video sticker
  1898. //
  1899. // optional
  1900. IsVideo bool `json:"is_video,omitempty"`
  1901. // Thumbnail sticker thumbnail in the .WEBP or .JPG format
  1902. //
  1903. // optional
  1904. Thumbnail *PhotoSize `json:"thumb,omitempty"`
  1905. // Emoji associated with the sticker
  1906. //
  1907. // optional
  1908. Emoji string `json:"emoji,omitempty"`
  1909. // SetName of the sticker set to which the sticker belongs
  1910. //
  1911. // optional
  1912. SetName string `json:"set_name,omitempty"`
  1913. // PremiumAnimation for premium regular stickers, premium animation for the sticker
  1914. //
  1915. // optional
  1916. PremiumAnimation *File `json:"premium_animation,omitempty"`
  1917. // MaskPosition is for mask stickers, the position where the mask should be
  1918. // placed
  1919. //
  1920. // optional
  1921. MaskPosition *MaskPosition `json:"mask_position,omitempty"`
  1922. // CustomEmojiID for custom emoji stickers, unique identifier of the custom emoji
  1923. //
  1924. // optional
  1925. CustomEmojiID string `json:"custom_emoji_id,omitempty"`
  1926. // FileSize
  1927. //
  1928. // optional
  1929. FileSize int `json:"file_size,omitempty"`
  1930. }
  1931. // StickerSet represents a sticker set.
  1932. type StickerSet struct {
  1933. // Name sticker set name
  1934. Name string `json:"name"`
  1935. // Title sticker set title
  1936. Title string `json:"title"`
  1937. // StickerType of stickers in the set, currently one of “regular”, “mask”, “custom_emoji”
  1938. StickerType string `json:"sticker_type"`
  1939. // IsAnimated true, if the sticker set contains animated stickers
  1940. IsAnimated bool `json:"is_animated"`
  1941. // IsVideo true, if the sticker set contains video stickers
  1942. IsVideo bool `json:"is_video"`
  1943. // ContainsMasks true, if the sticker set contains masks
  1944. ContainsMasks bool `json:"contains_masks"`
  1945. // Stickers list of all set stickers
  1946. Stickers []Sticker `json:"stickers"`
  1947. // Thumb is the sticker set thumbnail in the .WEBP or .TGS format
  1948. Thumbnail *PhotoSize `json:"thumb"`
  1949. }
  1950. // MaskPosition describes the position on faces where a mask should be placed
  1951. // by default.
  1952. type MaskPosition struct {
  1953. // The part of the face relative to which the mask should be placed.
  1954. // One of “forehead”, “eyes”, “mouth”, or “chin”.
  1955. Point string `json:"point"`
  1956. // Shift by X-axis measured in widths of the mask scaled to the face size,
  1957. // from left to right. For example, choosing -1.0 will place mask just to
  1958. // the left of the default mask position.
  1959. XShift float64 `json:"x_shift"`
  1960. // Shift by Y-axis measured in heights of the mask scaled to the face size,
  1961. // from top to bottom. For example, 1.0 will place the mask just below the
  1962. // default mask position.
  1963. YShift float64 `json:"y_shift"`
  1964. // Mask scaling coefficient. For example, 2.0 means double size.
  1965. Scale float64 `json:"scale"`
  1966. }
  1967. // Game represents a game. Use BotFather to create and edit games, their short
  1968. // names will act as unique identifiers.
  1969. type Game struct {
  1970. // Title of the game
  1971. Title string `json:"title"`
  1972. // Description of the game
  1973. Description string `json:"description"`
  1974. // Photo that will be displayed in the game message in chats.
  1975. Photo []PhotoSize `json:"photo"`
  1976. // Text a brief description of the game or high scores included in the game message.
  1977. // Can be automatically edited to include current high scores for the game
  1978. // when the bot calls setGameScore, or manually edited using editMessageText. 0-4096 characters.
  1979. //
  1980. // optional
  1981. Text string `json:"text,omitempty"`
  1982. // TextEntities special entities that appear in text, such as usernames, URLs, bot commands, etc.
  1983. //
  1984. // optional
  1985. TextEntities []MessageEntity `json:"text_entities,omitempty"`
  1986. // Animation is an animation that will be displayed in the game message in chats.
  1987. // Upload via BotFather (https://t.me/botfather).
  1988. //
  1989. // optional
  1990. Animation Animation `json:"animation,omitempty"`
  1991. }
  1992. // GameHighScore is a user's score and position on the leaderboard.
  1993. type GameHighScore struct {
  1994. // Position in high score table for the game
  1995. Position int `json:"position"`
  1996. // User user
  1997. User User `json:"user"`
  1998. // Score score
  1999. Score int `json:"score"`
  2000. }
  2001. // CallbackGame is for starting a game in an inline keyboard button.
  2002. type CallbackGame struct{}
  2003. // WebhookInfo is information about a currently set webhook.
  2004. type WebhookInfo struct {
  2005. // URL webhook URL, may be empty if webhook is not set up.
  2006. URL string `json:"url"`
  2007. // HasCustomCertificate true, if a custom certificate was provided for webhook certificate checks.
  2008. HasCustomCertificate bool `json:"has_custom_certificate"`
  2009. // PendingUpdateCount number of updates awaiting delivery.
  2010. PendingUpdateCount int `json:"pending_update_count"`
  2011. // IPAddress is the currently used webhook IP address
  2012. //
  2013. // optional
  2014. IPAddress string `json:"ip_address,omitempty"`
  2015. // LastErrorDate unix time for the most recent error
  2016. // that happened when trying to deliver an update via webhook.
  2017. //
  2018. // optional
  2019. LastErrorDate int `json:"last_error_date,omitempty"`
  2020. // LastErrorMessage error message in human-readable format for the most recent error
  2021. // that happened when trying to deliver an update via webhook.
  2022. //
  2023. // optional
  2024. LastErrorMessage string `json:"last_error_message,omitempty"`
  2025. // LastSynchronizationErrorDate is the unix time of the most recent error that
  2026. // happened when trying to synchronize available updates with Telegram datacenters.
  2027. LastSynchronizationErrorDate int `json:"last_synchronization_error_date,omitempty"`
  2028. // MaxConnections maximum allowed number of simultaneous
  2029. // HTTPS connections to the webhook for update delivery.
  2030. //
  2031. // optional
  2032. MaxConnections int `json:"max_connections,omitempty"`
  2033. // AllowedUpdates is a list of update types the bot is subscribed to.
  2034. // Defaults to all update types
  2035. //
  2036. // optional
  2037. AllowedUpdates []string `json:"allowed_updates,omitempty"`
  2038. }
  2039. // IsSet returns true if a webhook is currently set.
  2040. func (info WebhookInfo) IsSet() bool {
  2041. return info.URL != ""
  2042. }
  2043. // InlineQuery is a Query from Telegram for an inline request.
  2044. type InlineQuery struct {
  2045. // ID unique identifier for this query
  2046. ID string `json:"id"`
  2047. // From sender
  2048. From *User `json:"from"`
  2049. // Query text of the query (up to 256 characters).
  2050. Query string `json:"query"`
  2051. // Offset of the results to be returned, can be controlled by the bot.
  2052. Offset string `json:"offset"`
  2053. // Type of the chat, from which the inline query was sent. Can be either
  2054. // “sender” for a private chat with the inline query sender, “private”,
  2055. // “group”, “supergroup”, or “channel”. The chat type should be always known
  2056. // for requests sent from official clients and most third-party clients,
  2057. // unless the request was sent from a secret chat
  2058. //
  2059. // optional
  2060. ChatType string `json:"chat_type,omitempty"`
  2061. // Location sender location, only for bots that request user location.
  2062. //
  2063. // optional
  2064. Location *Location `json:"location,omitempty"`
  2065. }
  2066. // InlineQueryResultCachedAudio is an inline query response with cached audio.
  2067. type InlineQueryResultCachedAudio struct {
  2068. // Type of the result, must be audio
  2069. Type string `json:"type"`
  2070. // ID unique identifier for this result, 1-64 bytes
  2071. ID string `json:"id"`
  2072. // AudioID a valid file identifier for the audio file
  2073. AudioID string `json:"audio_file_id"`
  2074. // Caption 0-1024 characters after entities parsing
  2075. //
  2076. // optional
  2077. Caption string `json:"caption,omitempty"`
  2078. // ParseMode mode for parsing entities in the video caption.
  2079. // See formatting options for more details
  2080. // (https://core.telegram.org/bots/api#formatting-options).
  2081. //
  2082. // optional
  2083. ParseMode string `json:"parse_mode,omitempty"`
  2084. // CaptionEntities is a list of special entities that appear in the caption,
  2085. // which can be specified instead of parse_mode
  2086. //
  2087. // optional
  2088. CaptionEntities []MessageEntity `json:"caption_entities,omitempty"`
  2089. // ReplyMarkup inline keyboard attached to the message
  2090. //
  2091. // optional
  2092. ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"`
  2093. // InputMessageContent content of the message to be sent instead of the audio
  2094. //
  2095. // optional
  2096. InputMessageContent interface{} `json:"input_message_content,omitempty"`
  2097. }
  2098. // InlineQueryResultCachedDocument is an inline query response with cached document.
  2099. type InlineQueryResultCachedDocument struct {
  2100. // Type of the result, must be a document
  2101. Type string `json:"type"`
  2102. // ID unique identifier for this result, 1-64 bytes
  2103. ID string `json:"id"`
  2104. // DocumentID a valid file identifier for the file
  2105. DocumentID string `json:"document_file_id"`
  2106. // Title for the result
  2107. //
  2108. // optional
  2109. Title string `json:"title,omitempty"`
  2110. // Caption of the document to be sent, 0-1024 characters after entities parsing
  2111. //
  2112. // optional
  2113. Caption string `json:"caption,omitempty"`
  2114. // Description short description of the result
  2115. //
  2116. // optional
  2117. Description string `json:"description,omitempty"`
  2118. // ParseMode mode for parsing entities in the video caption.
  2119. // // See formatting options for more details
  2120. // // (https://core.telegram.org/bots/api#formatting-options).
  2121. //
  2122. // optional
  2123. ParseMode string `json:"parse_mode,omitempty"`
  2124. // CaptionEntities is a list of special entities that appear in the caption,
  2125. // which can be specified instead of parse_mode
  2126. //
  2127. // optional
  2128. CaptionEntities []MessageEntity `json:"caption_entities,omitempty"`
  2129. // ReplyMarkup inline keyboard attached to the message
  2130. //
  2131. // optional
  2132. ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"`
  2133. // InputMessageContent content of the message to be sent instead of the file
  2134. //
  2135. // optional
  2136. InputMessageContent interface{} `json:"input_message_content,omitempty"`
  2137. }
  2138. // InlineQueryResultCachedGIF is an inline query response with cached gif.
  2139. type InlineQueryResultCachedGIF struct {
  2140. // Type of the result, must be gif.
  2141. Type string `json:"type"`
  2142. // ID unique identifier for this result, 1-64 bytes.
  2143. ID string `json:"id"`
  2144. // GifID a valid file identifier for the GIF file.
  2145. GIFID string `json:"gif_file_id"`
  2146. // Title for the result
  2147. //
  2148. // optional
  2149. Title string `json:"title,omitempty"`
  2150. // Caption of the GIF file to be sent, 0-1024 characters after entities parsing.
  2151. //
  2152. // optional
  2153. Caption string `json:"caption,omitempty"`
  2154. // ParseMode mode for parsing entities in the caption.
  2155. // See formatting options for more details
  2156. // (https://core.telegram.org/bots/api#formatting-options).
  2157. //
  2158. // optional
  2159. ParseMode string `json:"parse_mode,omitempty"`
  2160. // CaptionEntities is a list of special entities that appear in the caption,
  2161. // which can be specified instead of parse_mode
  2162. //
  2163. // optional
  2164. CaptionEntities []MessageEntity `json:"caption_entities,omitempty"`
  2165. // ReplyMarkup inline keyboard attached to the message.
  2166. //
  2167. // optional
  2168. ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"`
  2169. // InputMessageContent content of the message to be sent instead of the GIF animation.
  2170. //
  2171. // optional
  2172. InputMessageContent interface{} `json:"input_message_content,omitempty"`
  2173. }
  2174. // InlineQueryResultCachedMPEG4GIF is an inline query response with cached
  2175. // H.264/MPEG-4 AVC video without sound gif.
  2176. type InlineQueryResultCachedMPEG4GIF struct {
  2177. // Type of the result, must be mpeg4_gif
  2178. Type string `json:"type"`
  2179. // ID unique identifier for this result, 1-64 bytes
  2180. ID string `json:"id"`
  2181. // MPEG4FileID a valid file identifier for the MP4 file
  2182. MPEG4FileID string `json:"mpeg4_file_id"`
  2183. // Title for the result
  2184. //
  2185. // optional
  2186. Title string `json:"title,omitempty"`
  2187. // Caption of the MPEG-4 file to be sent, 0-1024 characters after entities parsing.
  2188. //
  2189. // optional
  2190. Caption string `json:"caption,omitempty"`
  2191. // ParseMode mode for parsing entities in the caption.
  2192. // See formatting options for more details
  2193. // (https://core.telegram.org/bots/api#formatting-options).
  2194. //
  2195. // optional
  2196. ParseMode string `json:"parse_mode,omitempty"`
  2197. // ParseMode mode for parsing entities in the video caption.
  2198. // See formatting options for more details
  2199. // (https://core.telegram.org/bots/api#formatting-options).
  2200. //
  2201. // optional
  2202. CaptionEntities []MessageEntity `json:"caption_entities,omitempty"`
  2203. // ReplyMarkup inline keyboard attached to the message.
  2204. //
  2205. // optional
  2206. ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"`
  2207. // InputMessageContent content of the message to be sent instead of the video animation.
  2208. //
  2209. // optional
  2210. InputMessageContent interface{} `json:"input_message_content,omitempty"`
  2211. }
  2212. // InlineQueryResultCachedPhoto is an inline query response with cached photo.
  2213. type InlineQueryResultCachedPhoto struct {
  2214. // Type of the result, must be a photo.
  2215. Type string `json:"type"`
  2216. // ID unique identifier for this result, 1-64 bytes.
  2217. ID string `json:"id"`
  2218. // PhotoID a valid file identifier of the photo.
  2219. PhotoID string `json:"photo_file_id"`
  2220. // Title for the result.
  2221. //
  2222. // optional
  2223. Title string `json:"title,omitempty"`
  2224. // Description short description of the result.
  2225. //
  2226. // optional
  2227. Description string `json:"description,omitempty"`
  2228. // Caption of the photo to be sent, 0-1024 characters after entities parsing.
  2229. //
  2230. // optional
  2231. Caption string `json:"caption,omitempty"`
  2232. // ParseMode mode for parsing entities in the photo caption.
  2233. // See formatting options for more details
  2234. // (https://core.telegram.org/bots/api#formatting-options).
  2235. //
  2236. // optional
  2237. ParseMode string `json:"parse_mode,omitempty"`
  2238. // CaptionEntities is a list of special entities that appear in the caption,
  2239. // which can be specified instead of parse_mode
  2240. //
  2241. // optional
  2242. CaptionEntities []MessageEntity `json:"caption_entities,omitempty"`
  2243. // ReplyMarkup inline keyboard attached to the message.
  2244. //
  2245. // optional
  2246. ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"`
  2247. // InputMessageContent content of the message to be sent instead of the photo.
  2248. //
  2249. // optional
  2250. InputMessageContent interface{} `json:"input_message_content,omitempty"`
  2251. }
  2252. // InlineQueryResultCachedSticker is an inline query response with cached sticker.
  2253. type InlineQueryResultCachedSticker struct {
  2254. // Type of the result, must be a sticker
  2255. Type string `json:"type"`
  2256. // ID unique identifier for this result, 1-64 bytes
  2257. ID string `json:"id"`
  2258. // StickerID a valid file identifier of the sticker
  2259. StickerID string `json:"sticker_file_id"`
  2260. // Title is a title
  2261. Title string `json:"title"`
  2262. // ReplyMarkup inline keyboard attached to the message
  2263. //
  2264. // optional
  2265. ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"`
  2266. // InputMessageContent content of the message to be sent instead of the sticker
  2267. //
  2268. // optional
  2269. InputMessageContent interface{} `json:"input_message_content,omitempty"`
  2270. }
  2271. // InlineQueryResultCachedVideo is an inline query response with cached video.
  2272. type InlineQueryResultCachedVideo struct {
  2273. // Type of the result, must be video
  2274. Type string `json:"type"`
  2275. // ID unique identifier for this result, 1-64 bytes
  2276. ID string `json:"id"`
  2277. // VideoID a valid file identifier for the video file
  2278. VideoID string `json:"video_file_id"`
  2279. // Title for the result
  2280. Title string `json:"title"`
  2281. // Description short description of the result
  2282. //
  2283. // optional
  2284. Description string `json:"description,omitempty"`
  2285. // Caption of the video to be sent, 0-1024 characters after entities parsing
  2286. //
  2287. // optional
  2288. Caption string `json:"caption,omitempty"`
  2289. // ParseMode mode for parsing entities in the video caption.
  2290. // See formatting options for more details
  2291. // (https://core.telegram.org/bots/api#formatting-options).
  2292. //
  2293. // optional
  2294. ParseMode string `json:"parse_mode,omitempty"`
  2295. // CaptionEntities is a list of special entities that appear in the caption,
  2296. // which can be specified instead of parse_mode
  2297. //
  2298. // optional
  2299. CaptionEntities []MessageEntity `json:"caption_entities,omitempty"`
  2300. // ReplyMarkup inline keyboard attached to the message
  2301. //
  2302. // optional
  2303. ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"`
  2304. // InputMessageContent content of the message to be sent instead of the video
  2305. //
  2306. // optional
  2307. InputMessageContent interface{} `json:"input_message_content,omitempty"`
  2308. }
  2309. // InlineQueryResultCachedVoice is an inline query response with cached voice.
  2310. type InlineQueryResultCachedVoice struct {
  2311. // Type of the result, must be voice
  2312. Type string `json:"type"`
  2313. // ID unique identifier for this result, 1-64 bytes
  2314. ID string `json:"id"`
  2315. // VoiceID a valid file identifier for the voice message
  2316. VoiceID string `json:"voice_file_id"`
  2317. // Title voice message title
  2318. Title string `json:"title"`
  2319. // Caption 0-1024 characters after entities parsing
  2320. //
  2321. // optional
  2322. Caption string `json:"caption,omitempty"`
  2323. // ParseMode mode for parsing entities in the video caption.
  2324. // See formatting options for more details
  2325. // (https://core.telegram.org/bots/api#formatting-options).
  2326. //
  2327. // optional
  2328. ParseMode string `json:"parse_mode,omitempty"`
  2329. // CaptionEntities is a list of special entities that appear in the caption,
  2330. // which can be specified instead of parse_mode
  2331. //
  2332. // optional
  2333. CaptionEntities []MessageEntity `json:"caption_entities,omitempty"`
  2334. // ReplyMarkup inline keyboard attached to the message
  2335. //
  2336. // optional
  2337. ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"`
  2338. // InputMessageContent content of the message to be sent instead of the voice message
  2339. //
  2340. // optional
  2341. InputMessageContent interface{} `json:"input_message_content,omitempty"`
  2342. }
  2343. // InlineQueryResultArticle represents a link to an article or web page.
  2344. type InlineQueryResultArticle struct {
  2345. // Type of the result, must be article.
  2346. Type string `json:"type"`
  2347. // ID unique identifier for this result, 1-64 Bytes.
  2348. ID string `json:"id"`
  2349. // Title of the result
  2350. Title string `json:"title"`
  2351. // InputMessageContent content of the message to be sent.
  2352. InputMessageContent interface{} `json:"input_message_content,omitempty"`
  2353. // ReplyMarkup Inline keyboard attached to the message.
  2354. //
  2355. // optional
  2356. ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"`
  2357. // URL of the result.
  2358. //
  2359. // optional
  2360. URL string `json:"url,omitempty"`
  2361. // HideURL pass True, if you don't want the URL to be shown in the message.
  2362. //
  2363. // optional
  2364. HideURL bool `json:"hide_url,omitempty"`
  2365. // Description short description of the result.
  2366. //
  2367. // optional
  2368. Description string `json:"description,omitempty"`
  2369. // ThumbURL url of the thumbnail for the result
  2370. //
  2371. // optional
  2372. ThumbURL string `json:"thumb_url,omitempty"`
  2373. // ThumbWidth thumbnail width
  2374. //
  2375. // optional
  2376. ThumbWidth int `json:"thumb_width,omitempty"`
  2377. // ThumbHeight thumbnail height
  2378. //
  2379. // optional
  2380. ThumbHeight int `json:"thumb_height,omitempty"`
  2381. }
  2382. // InlineQueryResultAudio is an inline query response audio.
  2383. type InlineQueryResultAudio struct {
  2384. // Type of the result, must be audio
  2385. Type string `json:"type"`
  2386. // ID unique identifier for this result, 1-64 bytes
  2387. ID string `json:"id"`
  2388. // URL a valid url for the audio file
  2389. URL string `json:"audio_url"`
  2390. // Title is a title
  2391. Title string `json:"title"`
  2392. // Caption 0-1024 characters after entities parsing
  2393. //
  2394. // optional
  2395. Caption string `json:"caption,omitempty"`
  2396. // ParseMode mode for parsing entities in the video caption.
  2397. // See formatting options for more details
  2398. // (https://core.telegram.org/bots/api#formatting-options).
  2399. //
  2400. // optional
  2401. ParseMode string `json:"parse_mode,omitempty"`
  2402. // CaptionEntities is a list of special entities that appear in the caption,
  2403. // which can be specified instead of parse_mode
  2404. //
  2405. // optional
  2406. CaptionEntities []MessageEntity `json:"caption_entities,omitempty"`
  2407. // Performer is a performer
  2408. //
  2409. // optional
  2410. Performer string `json:"performer,omitempty"`
  2411. // Duration audio duration in seconds
  2412. //
  2413. // optional
  2414. Duration int `json:"audio_duration,omitempty"`
  2415. // ReplyMarkup inline keyboard attached to the message
  2416. //
  2417. // optional
  2418. ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"`
  2419. // InputMessageContent content of the message to be sent instead of the audio
  2420. //
  2421. // optional
  2422. InputMessageContent interface{} `json:"input_message_content,omitempty"`
  2423. }
  2424. // InlineQueryResultContact is an inline query response contact.
  2425. type InlineQueryResultContact struct {
  2426. Type string `json:"type"` // required
  2427. ID string `json:"id"` // required
  2428. PhoneNumber string `json:"phone_number"` // required
  2429. FirstName string `json:"first_name"` // required
  2430. LastName string `json:"last_name"`
  2431. VCard string `json:"vcard"`
  2432. ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"`
  2433. InputMessageContent interface{} `json:"input_message_content,omitempty"`
  2434. ThumbURL string `json:"thumb_url"`
  2435. ThumbWidth int `json:"thumb_width"`
  2436. ThumbHeight int `json:"thumb_height"`
  2437. }
  2438. // InlineQueryResultGame is an inline query response game.
  2439. type InlineQueryResultGame struct {
  2440. // Type of the result, must be game
  2441. Type string `json:"type"`
  2442. // ID unique identifier for this result, 1-64 bytes
  2443. ID string `json:"id"`
  2444. // GameShortName short name of the game
  2445. GameShortName string `json:"game_short_name"`
  2446. // ReplyMarkup inline keyboard attached to the message
  2447. //
  2448. // optional
  2449. ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"`
  2450. }
  2451. // InlineQueryResultDocument is an inline query response document.
  2452. type InlineQueryResultDocument struct {
  2453. // Type of the result, must be a document
  2454. Type string `json:"type"`
  2455. // ID unique identifier for this result, 1-64 bytes
  2456. ID string `json:"id"`
  2457. // Title for the result
  2458. Title string `json:"title"`
  2459. // Caption of the document to be sent, 0-1024 characters after entities parsing
  2460. //
  2461. // optional
  2462. Caption string `json:"caption,omitempty"`
  2463. // URL a valid url for the file
  2464. URL string `json:"document_url"`
  2465. // MimeType of the content of the file, either “application/pdf” or “application/zip”
  2466. MimeType string `json:"mime_type"`
  2467. // Description short description of the result
  2468. //
  2469. // optional
  2470. Description string `json:"description,omitempty"`
  2471. // ReplyMarkup inline keyboard attached to the message
  2472. //
  2473. // optional
  2474. ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"`
  2475. // InputMessageContent content of the message to be sent instead of the file
  2476. //
  2477. // optional
  2478. InputMessageContent interface{} `json:"input_message_content,omitempty"`
  2479. // ThumbURL url of the thumbnail (jpeg only) for the file
  2480. //
  2481. // optional
  2482. ThumbURL string `json:"thumb_url,omitempty"`
  2483. // ThumbWidth thumbnail width
  2484. //
  2485. // optional
  2486. ThumbWidth int `json:"thumb_width,omitempty"`
  2487. // ThumbHeight thumbnail height
  2488. //
  2489. // optional
  2490. ThumbHeight int `json:"thumb_height,omitempty"`
  2491. }
  2492. // InlineQueryResultGIF is an inline query response GIF.
  2493. type InlineQueryResultGIF struct {
  2494. // Type of the result, must be gif.
  2495. Type string `json:"type"`
  2496. // ID unique identifier for this result, 1-64 bytes.
  2497. ID string `json:"id"`
  2498. // URL a valid URL for the GIF file. File size must not exceed 1MB.
  2499. URL string `json:"gif_url"`
  2500. // ThumbURL url of the static (JPEG or GIF) or animated (MPEG4) thumbnail for the result.
  2501. ThumbURL string `json:"thumb_url"`
  2502. // Width of the GIF
  2503. //
  2504. // optional
  2505. Width int `json:"gif_width,omitempty"`
  2506. // Height of the GIF
  2507. //
  2508. // optional
  2509. Height int `json:"gif_height,omitempty"`
  2510. // Duration of the GIF
  2511. //
  2512. // optional
  2513. Duration int `json:"gif_duration,omitempty"`
  2514. // Title for the result
  2515. //
  2516. // optional
  2517. Title string `json:"title,omitempty"`
  2518. // Caption of the GIF file to be sent, 0-1024 characters after entities parsing.
  2519. //
  2520. // optional
  2521. Caption string `json:"caption,omitempty"`
  2522. // ParseMode mode for parsing entities in the video caption.
  2523. // See formatting options for more details
  2524. // (https://core.telegram.org/bots/api#formatting-options).
  2525. //
  2526. // optional
  2527. ParseMode string `json:"parse_mode,omitempty"`
  2528. // CaptionEntities is a list of special entities that appear in the caption,
  2529. // which can be specified instead of parse_mode
  2530. //
  2531. // optional
  2532. CaptionEntities []MessageEntity `json:"caption_entities,omitempty"`
  2533. // ReplyMarkup inline keyboard attached to the message
  2534. //
  2535. // optional
  2536. ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"`
  2537. // InputMessageContent content of the message to be sent instead of the GIF animation.
  2538. //
  2539. // optional
  2540. InputMessageContent interface{} `json:"input_message_content,omitempty"`
  2541. }
  2542. // InlineQueryResultLocation is an inline query response location.
  2543. type InlineQueryResultLocation struct {
  2544. // Type of the result, must be location
  2545. Type string `json:"type"`
  2546. // ID unique identifier for this result, 1-64 Bytes
  2547. ID string `json:"id"`
  2548. // Latitude of the location in degrees
  2549. Latitude float64 `json:"latitude"`
  2550. // Longitude of the location in degrees
  2551. Longitude float64 `json:"longitude"`
  2552. // Title of the location
  2553. Title string `json:"title"`
  2554. // HorizontalAccuracy is the radius of uncertainty for the location,
  2555. // measured in meters; 0-1500
  2556. //
  2557. // optional
  2558. HorizontalAccuracy float64 `json:"horizontal_accuracy,omitempty"`
  2559. // LivePeriod is the period in seconds for which the location can be
  2560. // updated, should be between 60 and 86400.
  2561. //
  2562. // optional
  2563. LivePeriod int `json:"live_period,omitempty"`
  2564. // Heading is for live locations, a direction in which the user is moving,
  2565. // in degrees. Must be between 1 and 360 if specified.
  2566. //
  2567. // optional
  2568. Heading int `json:"heading,omitempty"`
  2569. // ProximityAlertRadius is for live locations, a maximum distance for
  2570. // proximity alerts about approaching another chat member, in meters. Must
  2571. // be between 1 and 100000 if specified.
  2572. //
  2573. // optional
  2574. ProximityAlertRadius int `json:"proximity_alert_radius,omitempty"`
  2575. // ReplyMarkup inline keyboard attached to the message
  2576. //
  2577. // optional
  2578. ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"`
  2579. // InputMessageContent content of the message to be sent instead of the location
  2580. //
  2581. // optional
  2582. InputMessageContent interface{} `json:"input_message_content,omitempty"`
  2583. // ThumbURL url of the thumbnail for the result
  2584. //
  2585. // optional
  2586. ThumbURL string `json:"thumb_url,omitempty"`
  2587. // ThumbWidth thumbnail width
  2588. //
  2589. // optional
  2590. ThumbWidth int `json:"thumb_width,omitempty"`
  2591. // ThumbHeight thumbnail height
  2592. //
  2593. // optional
  2594. ThumbHeight int `json:"thumb_height,omitempty"`
  2595. }
  2596. // InlineQueryResultMPEG4GIF is an inline query response MPEG4 GIF.
  2597. type InlineQueryResultMPEG4GIF struct {
  2598. // Type of the result, must be mpeg4_gif
  2599. Type string `json:"type"`
  2600. // ID unique identifier for this result, 1-64 bytes
  2601. ID string `json:"id"`
  2602. // URL a valid URL for the MP4 file. File size must not exceed 1MB
  2603. URL string `json:"mpeg4_url"`
  2604. // Width video width
  2605. //
  2606. // optional
  2607. Width int `json:"mpeg4_width,omitempty"`
  2608. // Height vVideo height
  2609. //
  2610. // optional
  2611. Height int `json:"mpeg4_height,omitempty"`
  2612. // Duration video duration
  2613. //
  2614. // optional
  2615. Duration int `json:"mpeg4_duration,omitempty"`
  2616. // ThumbURL url of the static (JPEG or GIF) or animated (MPEG4) thumbnail for the result.
  2617. ThumbURL string `json:"thumb_url"`
  2618. // Title for the result
  2619. //
  2620. // optional
  2621. Title string `json:"title,omitempty"`
  2622. // Caption of the MPEG-4 file to be sent, 0-1024 characters after entities parsing.
  2623. //
  2624. // optional
  2625. Caption string `json:"caption,omitempty"`
  2626. // ParseMode mode for parsing entities in the video caption.
  2627. // See formatting options for more details
  2628. // (https://core.telegram.org/bots/api#formatting-options).
  2629. //
  2630. // optional
  2631. ParseMode string `json:"parse_mode,omitempty"`
  2632. // CaptionEntities is a list of special entities that appear in the caption,
  2633. // which can be specified instead of parse_mode
  2634. //
  2635. // optional
  2636. CaptionEntities []MessageEntity `json:"caption_entities,omitempty"`
  2637. // ReplyMarkup inline keyboard attached to the message
  2638. //
  2639. // optional
  2640. ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"`
  2641. // InputMessageContent content of the message to be sent instead of the video animation
  2642. //
  2643. // optional
  2644. InputMessageContent interface{} `json:"input_message_content,omitempty"`
  2645. }
  2646. // InlineQueryResultPhoto is an inline query response photo.
  2647. type InlineQueryResultPhoto struct {
  2648. // Type of the result, must be article.
  2649. Type string `json:"type"`
  2650. // ID unique identifier for this result, 1-64 Bytes.
  2651. ID string `json:"id"`
  2652. // URL a valid URL of the photo. Photo must be in jpeg format.
  2653. // Photo size must not exceed 5MB.
  2654. URL string `json:"photo_url"`
  2655. // MimeType
  2656. MimeType string `json:"mime_type"`
  2657. // Width of the photo
  2658. //
  2659. // optional
  2660. Width int `json:"photo_width,omitempty"`
  2661. // Height of the photo
  2662. //
  2663. // optional
  2664. Height int `json:"photo_height,omitempty"`
  2665. // ThumbURL url of the thumbnail for the photo.
  2666. //
  2667. // optional
  2668. ThumbURL string `json:"thumb_url,omitempty"`
  2669. // Title for the result
  2670. //
  2671. // optional
  2672. Title string `json:"title,omitempty"`
  2673. // Description short description of the result
  2674. //
  2675. // optional
  2676. Description string `json:"description,omitempty"`
  2677. // Caption of the photo to be sent, 0-1024 characters after entities parsing.
  2678. //
  2679. // optional
  2680. Caption string `json:"caption,omitempty"`
  2681. // ParseMode mode for parsing entities in the photo caption.
  2682. // See formatting options for more details
  2683. // (https://core.telegram.org/bots/api#formatting-options).
  2684. //
  2685. // optional
  2686. ParseMode string `json:"parse_mode,omitempty"`
  2687. // ReplyMarkup inline keyboard attached to the message.
  2688. //
  2689. // optional
  2690. ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"`
  2691. // CaptionEntities is a list of special entities that appear in the caption,
  2692. // which can be specified instead of parse_mode
  2693. //
  2694. // optional
  2695. CaptionEntities []MessageEntity `json:"caption_entities,omitempty"`
  2696. // InputMessageContent content of the message to be sent instead of the photo.
  2697. //
  2698. // optional
  2699. InputMessageContent interface{} `json:"input_message_content,omitempty"`
  2700. }
  2701. // InlineQueryResultVenue is an inline query response venue.
  2702. type InlineQueryResultVenue struct {
  2703. // Type of the result, must be venue
  2704. Type string `json:"type"`
  2705. // ID unique identifier for this result, 1-64 Bytes
  2706. ID string `json:"id"`
  2707. // Latitude of the venue location in degrees
  2708. Latitude float64 `json:"latitude"`
  2709. // Longitude of the venue location in degrees
  2710. Longitude float64 `json:"longitude"`
  2711. // Title of the venue
  2712. Title string `json:"title"`
  2713. // Address of the venue
  2714. Address string `json:"address"`
  2715. // FoursquareID foursquare identifier of the venue if known
  2716. //
  2717. // optional
  2718. FoursquareID string `json:"foursquare_id,omitempty"`
  2719. // FoursquareType foursquare type of the venue, if known.
  2720. // (For example, “arts_entertainment/default”, “arts_entertainment/aquarium” or “food/icecream”.)
  2721. //
  2722. // optional
  2723. FoursquareType string `json:"foursquare_type,omitempty"`
  2724. // GooglePlaceID is the Google Places identifier of the venue
  2725. //
  2726. // optional
  2727. GooglePlaceID string `json:"google_place_id,omitempty"`
  2728. // GooglePlaceType is the Google Places type of the venue
  2729. //
  2730. // optional
  2731. GooglePlaceType string `json:"google_place_type,omitempty"`
  2732. // ReplyMarkup inline keyboard attached to the message
  2733. //
  2734. // optional
  2735. ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"`
  2736. // InputMessageContent content of the message to be sent instead of the venue
  2737. //
  2738. // optional
  2739. InputMessageContent interface{} `json:"input_message_content,omitempty"`
  2740. // ThumbURL url of the thumbnail for the result
  2741. //
  2742. // optional
  2743. ThumbURL string `json:"thumb_url,omitempty"`
  2744. // ThumbWidth thumbnail width
  2745. //
  2746. // optional
  2747. ThumbWidth int `json:"thumb_width,omitempty"`
  2748. // ThumbHeight thumbnail height
  2749. //
  2750. // optional
  2751. ThumbHeight int `json:"thumb_height,omitempty"`
  2752. }
  2753. // InlineQueryResultVideo is an inline query response video.
  2754. type InlineQueryResultVideo struct {
  2755. // Type of the result, must be video
  2756. Type string `json:"type"`
  2757. // ID unique identifier for this result, 1-64 bytes
  2758. ID string `json:"id"`
  2759. // URL a valid url for the embedded video player or video file
  2760. URL string `json:"video_url"`
  2761. // MimeType of the content of video url, “text/html” or “video/mp4”
  2762. MimeType string `json:"mime_type"`
  2763. //
  2764. // ThumbURL url of the thumbnail (jpeg only) for the video
  2765. // optional
  2766. ThumbURL string `json:"thumb_url,omitempty"`
  2767. // Title for the result
  2768. Title string `json:"title"`
  2769. // Caption of the video to be sent, 0-1024 characters after entities parsing
  2770. //
  2771. // optional
  2772. Caption string `json:"caption,omitempty"`
  2773. // Width video width
  2774. //
  2775. // optional
  2776. Width int `json:"video_width,omitempty"`
  2777. // Height video height
  2778. //
  2779. // optional
  2780. Height int `json:"video_height,omitempty"`
  2781. // Duration video duration in seconds
  2782. //
  2783. // optional
  2784. Duration int `json:"video_duration,omitempty"`
  2785. // Description short description of the result
  2786. //
  2787. // optional
  2788. Description string `json:"description,omitempty"`
  2789. // ReplyMarkup inline keyboard attached to the message
  2790. //
  2791. // optional
  2792. ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"`
  2793. // InputMessageContent content of the message to be sent instead of the video.
  2794. // This field is required if InlineQueryResultVideo is used to send
  2795. // an HTML-page as a result (e.g., a YouTube video).
  2796. //
  2797. // optional
  2798. InputMessageContent interface{} `json:"input_message_content,omitempty"`
  2799. }
  2800. // InlineQueryResultVoice is an inline query response voice.
  2801. type InlineQueryResultVoice struct {
  2802. // Type of the result, must be voice
  2803. Type string `json:"type"`
  2804. // ID unique identifier for this result, 1-64 bytes
  2805. ID string `json:"id"`
  2806. // URL a valid URL for the voice recording
  2807. URL string `json:"voice_url"`
  2808. // Title recording title
  2809. Title string `json:"title"`
  2810. // Caption 0-1024 characters after entities parsing
  2811. //
  2812. // optional
  2813. Caption string `json:"caption,omitempty"`
  2814. // ParseMode mode for parsing entities in the video caption.
  2815. // See formatting options for more details
  2816. // (https://core.telegram.org/bots/api#formatting-options).
  2817. //
  2818. // optional
  2819. ParseMode string `json:"parse_mode,omitempty"`
  2820. // CaptionEntities is a list of special entities that appear in the caption,
  2821. // which can be specified instead of parse_mode
  2822. //
  2823. // optional
  2824. CaptionEntities []MessageEntity `json:"caption_entities,omitempty"`
  2825. // Duration recording duration in seconds
  2826. //
  2827. // optional
  2828. Duration int `json:"voice_duration,omitempty"`
  2829. // ReplyMarkup inline keyboard attached to the message
  2830. //
  2831. // optional
  2832. ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"`
  2833. // InputMessageContent content of the message to be sent instead of the voice recording
  2834. //
  2835. // optional
  2836. InputMessageContent interface{} `json:"input_message_content,omitempty"`
  2837. }
  2838. // ChosenInlineResult is an inline query result chosen by a User
  2839. type ChosenInlineResult struct {
  2840. // ResultID the unique identifier for the result that was chosen
  2841. ResultID string `json:"result_id"`
  2842. // From the user that chose the result
  2843. From *User `json:"from"`
  2844. // Location sender location, only for bots that require user location
  2845. //
  2846. // optional
  2847. Location *Location `json:"location,omitempty"`
  2848. // InlineMessageID identifier of the sent inline message.
  2849. // Available only if there is an inline keyboard attached to the message.
  2850. // Will be also received in callback queries and can be used to edit the message.
  2851. //
  2852. // optional
  2853. InlineMessageID string `json:"inline_message_id,omitempty"`
  2854. // Query the query that was used to obtain the result
  2855. Query string `json:"query"`
  2856. }
  2857. // SentWebAppMessage contains information about an inline message sent by a Web App
  2858. // on behalf of a user.
  2859. type SentWebAppMessage struct {
  2860. // Identifier of the sent inline message. Available only if there is an inline
  2861. // keyboard attached to the message.
  2862. //
  2863. // optional
  2864. InlineMessageID string `json:"inline_message_id,omitempty"`
  2865. }
  2866. // InputTextMessageContent contains text for displaying
  2867. // as an inline query result.
  2868. type InputTextMessageContent struct {
  2869. // Text of the message to be sent, 1-4096 characters
  2870. Text string `json:"message_text"`
  2871. // ParseMode mode for parsing entities in the message text.
  2872. // See formatting options for more details
  2873. // (https://core.telegram.org/bots/api#formatting-options).
  2874. //
  2875. // optional
  2876. ParseMode string `json:"parse_mode,omitempty"`
  2877. // Entities is a list of special entities that appear in message text, which
  2878. // can be specified instead of parse_mode
  2879. //
  2880. // optional
  2881. Entities []MessageEntity `json:"entities,omitempty"`
  2882. // DisableWebPagePreview disables link previews for links in the sent message
  2883. //
  2884. // optional
  2885. DisableWebPagePreview bool `json:"disable_web_page_preview,omitempty"`
  2886. }
  2887. // InputLocationMessageContent contains a location for displaying
  2888. // as an inline query result.
  2889. type InputLocationMessageContent struct {
  2890. // Latitude of the location in degrees
  2891. Latitude float64 `json:"latitude"`
  2892. // Longitude of the location in degrees
  2893. Longitude float64 `json:"longitude"`
  2894. // HorizontalAccuracy is the radius of uncertainty for the location,
  2895. // measured in meters; 0-1500
  2896. //
  2897. // optional
  2898. HorizontalAccuracy float64 `json:"horizontal_accuracy,omitempty"`
  2899. // LivePeriod is the period in seconds for which the location can be
  2900. // updated, should be between 60 and 86400
  2901. //
  2902. // optional
  2903. LivePeriod int `json:"live_period,omitempty"`
  2904. // Heading is for live locations, a direction in which the user is moving,
  2905. // in degrees. Must be between 1 and 360 if specified.
  2906. //
  2907. // optional
  2908. Heading int `json:"heading,omitempty"`
  2909. // ProximityAlertRadius is for live locations, a maximum distance for
  2910. // proximity alerts about approaching another chat member, in meters. Must
  2911. // be between 1 and 100000 if specified.
  2912. //
  2913. // optional
  2914. ProximityAlertRadius int `json:"proximity_alert_radius,omitempty"`
  2915. }
  2916. // InputVenueMessageContent contains a venue for displaying
  2917. // as an inline query result.
  2918. type InputVenueMessageContent struct {
  2919. // Latitude of the venue in degrees
  2920. Latitude float64 `json:"latitude"`
  2921. // Longitude of the venue in degrees
  2922. Longitude float64 `json:"longitude"`
  2923. // Title name of the venue
  2924. Title string `json:"title"`
  2925. // Address of the venue
  2926. Address string `json:"address"`
  2927. // FoursquareID foursquare identifier of the venue, if known
  2928. //
  2929. // optional
  2930. FoursquareID string `json:"foursquare_id,omitempty"`
  2931. // FoursquareType Foursquare type of the venue, if known
  2932. //
  2933. // optional
  2934. FoursquareType string `json:"foursquare_type,omitempty"`
  2935. // GooglePlaceID is the Google Places identifier of the venue
  2936. //
  2937. // optional
  2938. GooglePlaceID string `json:"google_place_id,omitempty"`
  2939. // GooglePlaceType is the Google Places type of the venue
  2940. //
  2941. // optional
  2942. GooglePlaceType string `json:"google_place_type,omitempty"`
  2943. }
  2944. // InputContactMessageContent contains a contact for displaying
  2945. // as an inline query result.
  2946. type InputContactMessageContent struct {
  2947. // PhoneNumber contact's phone number
  2948. PhoneNumber string `json:"phone_number"`
  2949. // FirstName contact's first name
  2950. FirstName string `json:"first_name"`
  2951. // LastName contact's last name
  2952. //
  2953. // optional
  2954. LastName string `json:"last_name,omitempty"`
  2955. // Additional data about the contact in the form of a vCard
  2956. //
  2957. // optional
  2958. VCard string `json:"vcard,omitempty"`
  2959. }
  2960. // InputInvoiceMessageContent represents the content of an invoice message to be
  2961. // sent as the result of an inline query.
  2962. type InputInvoiceMessageContent struct {
  2963. // Product name, 1-32 characters
  2964. Title string `json:"title"`
  2965. // Product description, 1-255 characters
  2966. Description string `json:"description"`
  2967. // Bot-defined invoice payload, 1-128 bytes. This will not be displayed to
  2968. // the user, use for your internal processes.
  2969. Payload string `json:"payload"`
  2970. // Payment provider token, obtained via Botfather
  2971. ProviderToken string `json:"provider_token"`
  2972. // Three-letter ISO 4217 currency code
  2973. Currency string `json:"currency"`
  2974. // Price breakdown, a JSON-serialized list of components (e.g. product
  2975. // price, tax, discount, delivery cost, delivery tax, bonus, etc.)
  2976. Prices []LabeledPrice `json:"prices"`
  2977. // The maximum accepted amount for tips in the smallest units of the
  2978. // currency (integer, not float/double).
  2979. //
  2980. // optional
  2981. MaxTipAmount int `json:"max_tip_amount,omitempty"`
  2982. // An array of suggested amounts of tip in the smallest units of the
  2983. // currency (integer, not float/double). At most 4 suggested tip amounts can
  2984. // be specified. The suggested tip amounts must be positive, passed in a
  2985. // strictly increased order and must not exceed max_tip_amount.
  2986. //
  2987. // optional
  2988. SuggestedTipAmounts []int `json:"suggested_tip_amounts,omitempty"`
  2989. // A JSON-serialized object for data about the invoice, which will be shared
  2990. // with the payment provider. A detailed description of the required fields
  2991. // should be provided by the payment provider.
  2992. //
  2993. // optional
  2994. ProviderData string `json:"provider_data,omitempty"`
  2995. // URL of the product photo for the invoice. Can be a photo of the goods or
  2996. // a marketing image for a service. People like it better when they see what
  2997. // they are paying for.
  2998. //
  2999. // optional
  3000. PhotoURL string `json:"photo_url,omitempty"`
  3001. // Photo size
  3002. //
  3003. // optional
  3004. PhotoSize int `json:"photo_size,omitempty"`
  3005. // Photo width
  3006. //
  3007. // optional
  3008. PhotoWidth int `json:"photo_width,omitempty"`
  3009. // Photo height
  3010. //
  3011. // optional
  3012. PhotoHeight int `json:"photo_height,omitempty"`
  3013. // Pass True, if you require the user's full name to complete the order
  3014. //
  3015. // optional
  3016. NeedName bool `json:"need_name,omitempty"`
  3017. // Pass True, if you require the user's phone number to complete the order
  3018. //
  3019. // optional
  3020. NeedPhoneNumber bool `json:"need_phone_number,omitempty"`
  3021. // Pass True, if you require the user's email address to complete the order
  3022. //
  3023. // optional
  3024. NeedEmail bool `json:"need_email,omitempty"`
  3025. // Pass True, if you require the user's shipping address to complete the order
  3026. //
  3027. // optional
  3028. NeedShippingAddress bool `json:"need_shipping_address,omitempty"`
  3029. // Pass True, if user's phone number should be sent to provider
  3030. //
  3031. // optional
  3032. SendPhoneNumberToProvider bool `json:"send_phone_number_to_provider,omitempty"`
  3033. // Pass True, if user's email address should be sent to provider
  3034. //
  3035. // optional
  3036. SendEmailToProvider bool `json:"send_email_to_provider,omitempty"`
  3037. // Pass True, if the final price depends on the shipping method
  3038. //
  3039. // optional
  3040. IsFlexible bool `json:"is_flexible,omitempty"`
  3041. }
  3042. // LabeledPrice represents a portion of the price for goods or services.
  3043. type LabeledPrice struct {
  3044. // Label portion label
  3045. Label string `json:"label"`
  3046. // Amount price of the product in the smallest units of the currency (integer, not float/double).
  3047. // For example, for a price of US$ 1.45 pass amount = 145.
  3048. // See the exp parameter in currencies.json
  3049. // (https://core.telegram.org/bots/payments/currencies.json),
  3050. // it shows the number of digits past the decimal point
  3051. // for each currency (2 for the majority of currencies).
  3052. Amount int `json:"amount"`
  3053. }
  3054. // Invoice contains basic information about an invoice.
  3055. type Invoice struct {
  3056. // Title product name
  3057. Title string `json:"title"`
  3058. // Description product description
  3059. Description string `json:"description"`
  3060. // StartParameter unique bot deep-linking parameter that can be used to generate this invoice
  3061. StartParameter string `json:"start_parameter"`
  3062. // Currency three-letter ISO 4217 currency code
  3063. // (see https://core.telegram.org/bots/payments#supported-currencies)
  3064. Currency string `json:"currency"`
  3065. // TotalAmount total price in the smallest units of the currency (integer, not float/double).
  3066. // For example, for a price of US$ 1.45 pass amount = 145.
  3067. // See the exp parameter in currencies.json
  3068. // (https://core.telegram.org/bots/payments/currencies.json),
  3069. // it shows the number of digits past the decimal point
  3070. // for each currency (2 for the majority of currencies).
  3071. TotalAmount int `json:"total_amount"`
  3072. }
  3073. // ShippingAddress represents a shipping address.
  3074. type ShippingAddress struct {
  3075. // CountryCode ISO 3166-1 alpha-2 country code
  3076. CountryCode string `json:"country_code"`
  3077. // State if applicable
  3078. State string `json:"state"`
  3079. // City city
  3080. City string `json:"city"`
  3081. // StreetLine1 first line for the address
  3082. StreetLine1 string `json:"street_line1"`
  3083. // StreetLine2 second line for the address
  3084. StreetLine2 string `json:"street_line2"`
  3085. // PostCode address post code
  3086. PostCode string `json:"post_code"`
  3087. }
  3088. // OrderInfo represents information about an order.
  3089. type OrderInfo struct {
  3090. // Name user name
  3091. //
  3092. // optional
  3093. Name string `json:"name,omitempty"`
  3094. // PhoneNumber user's phone number
  3095. //
  3096. // optional
  3097. PhoneNumber string `json:"phone_number,omitempty"`
  3098. // Email user email
  3099. //
  3100. // optional
  3101. Email string `json:"email,omitempty"`
  3102. // ShippingAddress user shipping address
  3103. //
  3104. // optional
  3105. ShippingAddress *ShippingAddress `json:"shipping_address,omitempty"`
  3106. }
  3107. // ShippingOption represents one shipping option.
  3108. type ShippingOption struct {
  3109. // ID shipping option identifier
  3110. ID string `json:"id"`
  3111. // Title option title
  3112. Title string `json:"title"`
  3113. // Prices list of price portions
  3114. Prices []LabeledPrice `json:"prices"`
  3115. }
  3116. // SuccessfulPayment contains basic information about a successful payment.
  3117. type SuccessfulPayment struct {
  3118. // Currency three-letter ISO 4217 currency code
  3119. // (see https://core.telegram.org/bots/payments#supported-currencies)
  3120. Currency string `json:"currency"`
  3121. // TotalAmount total price in the smallest units of the currency (integer, not float/double).
  3122. // For example, for a price of US$ 1.45 pass amount = 145.
  3123. // See the exp parameter in currencies.json,
  3124. // (https://core.telegram.org/bots/payments/currencies.json)
  3125. // it shows the number of digits past the decimal point
  3126. // for each currency (2 for the majority of currencies).
  3127. TotalAmount int `json:"total_amount"`
  3128. // InvoicePayload bot specified invoice payload
  3129. InvoicePayload string `json:"invoice_payload"`
  3130. // ShippingOptionID identifier of the shipping option chosen by the user
  3131. //
  3132. // optional
  3133. ShippingOptionID string `json:"shipping_option_id,omitempty"`
  3134. // OrderInfo order info provided by the user
  3135. //
  3136. // optional
  3137. OrderInfo *OrderInfo `json:"order_info,omitempty"`
  3138. // TelegramPaymentChargeID telegram payment identifier
  3139. TelegramPaymentChargeID string `json:"telegram_payment_charge_id"`
  3140. // ProviderPaymentChargeID provider payment identifier
  3141. ProviderPaymentChargeID string `json:"provider_payment_charge_id"`
  3142. }
  3143. // ShippingQuery contains information about an incoming shipping query.
  3144. type ShippingQuery struct {
  3145. // ID unique query identifier
  3146. ID string `json:"id"`
  3147. // From user who sent the query
  3148. From *User `json:"from"`
  3149. // InvoicePayload bot specified invoice payload
  3150. InvoicePayload string `json:"invoice_payload"`
  3151. // ShippingAddress user specified shipping address
  3152. ShippingAddress *ShippingAddress `json:"shipping_address"`
  3153. }
  3154. // PreCheckoutQuery contains information about an incoming pre-checkout query.
  3155. type PreCheckoutQuery struct {
  3156. // ID unique query identifier
  3157. ID string `json:"id"`
  3158. // From user who sent the query
  3159. From *User `json:"from"`
  3160. // Currency three-letter ISO 4217 currency code
  3161. // // (see https://core.telegram.org/bots/payments#supported-currencies)
  3162. Currency string `json:"currency"`
  3163. // TotalAmount total price in the smallest units of the currency (integer, not float/double).
  3164. // // For example, for a price of US$ 1.45 pass amount = 145.
  3165. // // See the exp parameter in currencies.json,
  3166. // // (https://core.telegram.org/bots/payments/currencies.json)
  3167. // // it shows the number of digits past the decimal point
  3168. // // for each currency (2 for the majority of currencies).
  3169. TotalAmount int `json:"total_amount"`
  3170. // InvoicePayload bot specified invoice payload
  3171. InvoicePayload string `json:"invoice_payload"`
  3172. // ShippingOptionID identifier of the shipping option chosen by the user
  3173. //
  3174. // optional
  3175. ShippingOptionID string `json:"shipping_option_id,omitempty"`
  3176. // OrderInfo order info provided by the user
  3177. //
  3178. // optional
  3179. OrderInfo *OrderInfo `json:"order_info,omitempty"`
  3180. }