package telegraml

  1. Overview
  2. Docs
Telegram Bot API for OCaml

Install

dune-project
 Dependency

Authors

Maintainers

Sources

v2.2.0.tar.gz
sha256=b07ec61353d3a245f81c4c510a41b58b75c5ea17f0b1bf3df22b1c3601bd45c4
md5=2fdd7c68eec4b7b904d9c4e536395a70

doc/src/telegraml/telegramActions.ml.html

Source file telegramActions.ml

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
open TelegramApi.Command

(* Action combinators *)

(** Chains two commands together (do one, then the other) *)
let (/+) c1 c2 = Chain (c1, c2)

(** Pipes one command into the next (do one, and use its result) *)
let (/>) c1 f = c1 ~and_then:f

(** Finish a sequence of commands using [(/>)] *)
let finish = fun _ -> Nothing

(** Sequence a list of commands in the provided order *)
let sequence cmds =
  List.fold_right (/+) cmds Nothing
(** Examples:
    - [command /> fun _ -> command2 /> finish]
    - [command /+ command2]
    - [sequence [
        command;
        command2
      ]] *)

(* Normal actions *)

let nothing = Nothing

let get_me ~and_then = GetMe and_then

let send_message ~chat_id ?parse_mode ?(disable_web_page_preview=false) ?(disable_notification=false) ?reply_to ?reply_markup =
  Printf.ksprintf
    (fun s ->
       SendMessage (chat_id, s, parse_mode, disable_web_page_preview, disable_notification, reply_to, reply_markup))

let forward_message ~chat_id ~from_chat_id ?(disable_notification=false) ~message_id =
  ForwardMessage (chat_id, from_chat_id, disable_notification, message_id)

let send_chat_action ~chat_id action =
  SendChatAction (chat_id, action)

let send_photo ~chat_id ?caption ?(disable_notification=false) ?reply_to ?reply_markup photo ~and_then =
  SendPhoto (chat_id, photo, caption, disable_notification, reply_to, reply_markup, and_then)

let resend_photo ~chat_id ?caption ?(disable_notification=false) ?reply_to ?reply_markup photo =
  ResendPhoto (chat_id, photo, caption, disable_notification, reply_to, reply_markup)

let send_audio ~chat_id ~performer ~title ?(disable_notification=false) ?reply_to ?reply_markup audio ~and_then =
  SendAudio (chat_id, audio, performer, title, disable_notification, reply_to, reply_markup, and_then)

let resend_audio ~chat_id ~performer ~title ?(disable_notification=false) ?reply_to ?reply_markup audio =
  ResendAudio (chat_id, audio, performer, title, disable_notification, reply_to, reply_markup)

let send_document ~chat_id ?(disable_notification=false) ?reply_to ?reply_markup document ~and_then =
  SendDocument (chat_id, document, disable_notification, reply_to, reply_markup, and_then)

let resend_document ~chat_id ?(disable_notification=false) ?reply_to ?reply_markup document =
  ResendDocument (chat_id, document, disable_notification, reply_to, reply_markup)

let send_sticker ~chat_id ?(disable_notification=false) ?reply_to ?reply_markup sticker ~and_then =
  SendSticker (chat_id, sticker, disable_notification, reply_to, reply_markup, and_then)

let resend_sticker ~chat_id ?(disable_notification=false) ?reply_to ?reply_markup sticker =
  ResendSticker (chat_id, sticker, disable_notification, reply_to, reply_markup)

let send_video ~chat_id ?duration ?caption ?(disable_notification=false) ?reply_to ?reply_markup video ~and_then =
  SendVideo (chat_id, video, duration, caption, disable_notification, reply_to, reply_markup, and_then)

let resend_video ~chat_id ?duration ?caption ?(disable_notification=false) ?reply_to ?reply_markup video =
  ResendVideo (chat_id, video, duration, caption, disable_notification, reply_to, reply_markup)

let send_voice ~chat_id ?(disable_notification=false) ?reply_to ?reply_markup voice ~and_then =
  SendVoice (chat_id, voice, disable_notification, reply_to, reply_markup, and_then)

let resend_voice ~chat_id ?(disable_notification=false) ?reply_to ?reply_markup voice =
  ResendVoice (chat_id, voice, disable_notification, reply_to, reply_markup)

let send_location ~chat_id ?(disable_notification=false) ?reply_to ?reply_markup ~latitude ~longitude =
  SendLocation (chat_id, latitude, longitude, disable_notification, reply_to, reply_markup)

let send_venue ~chat_id ?(disable_notification=false) ?reply_to ?reply_markup ~latitude ~longitude ~title ~address ~foursquare_id =
  SendVenue (chat_id, latitude, longitude, title, address, foursquare_id, disable_notification, reply_to, reply_markup)

let send_contact ~chat_id ?(disable_notification=false) ?reply_to ?reply_markup ~phone_number ~first_name ~last_name =
  SendContact (chat_id, phone_number, first_name, last_name, disable_notification, reply_to, reply_markup)

let get_user_profile_photos ?offset ?limit user_id ~and_then =
  GetUserProfilePhotos (user_id, offset, limit, and_then)

let get_file file_id ~and_then =
  GetFile (file_id, and_then)

let get_file' file_id ~and_then =
  GetFile' (file_id, and_then)

let download_file file ~and_then =
  DownloadFile (file, and_then)

let kick_chat_member ~chat_id ~user_id =
  KickChatMember (chat_id, user_id)

let leave_chat ~chat_id =
  LeaveChat chat_id

let unban_chat_member ~chat_id ~user_id =
  UnbanChatMember (chat_id, user_id)

let get_chat ~chat_id ~and_then =
  GetChat (chat_id, and_then)

let get_chat_administrators ~chat_id ~and_then =
  GetChatAdministrators (chat_id, and_then)

let get_chat_members_count ~chat_id ~and_then =
  GetChatMembersCount (chat_id, and_then)

let get_chat_member ~chat_id ~user_id ~and_then =
  GetChatMember (chat_id, user_id, and_then)

let answer_callback_query ?text ?(show_alert=false) id =
  AnswerCallbackQuery (id, text, show_alert)

let answer_inline_query ?cache_time ?is_personal ?next_offset id results =
  AnswerInlineQuery (id, results, cache_time, is_personal, next_offset)

let edit_message_text ~id ?parse_mode ?(disable_web_page_preview=false) ?reply_markup =
  Printf.ksprintf (fun s ->
      EditMessageText (id, s, parse_mode, disable_web_page_preview, reply_markup))

let edit_message_caption ~id ?reply_markup =
  Printf.ksprintf (fun s ->
      EditMessageCaption (id, s, reply_markup))

let edit_message_reply_markup ~id ~reply_markup =
  EditMessageReplyMarkup (id, Some reply_markup)

let get_updates ~and_then =
  GetUpdates and_then

let peek_update ~and_then =
  PeekUpdate and_then

(** @param run_commands: true by default. States whether to evaluate commands, inline queries, chat events, and callback queries *)
let pop_update ?(run_commands=true) ~and_then =
  PopUpdate (run_commands, and_then)
OCaml

Innovation. Community. Security.