package telegraml

  1. Overview
  2. Docs
type action =
  1. | Nothing
  2. | GetMe of User.user Result.result -> action
  3. | SendMessage of int * string * ParseMode.parse_mode option * bool * bool * int option * ReplyMarkup.reply_markup option
  4. | ForwardMessage of int * int * bool * int
  5. | SendChatAction of int * ChatAction.action
  6. | SendPhoto of int * string * string option * bool * int option * ReplyMarkup.reply_markup option * string Result.result -> action
  7. | ResendPhoto of int * string * string option * bool * int option * ReplyMarkup.reply_markup option
  8. | SendAudio of int * string * string * string * bool * int option * ReplyMarkup.reply_markup option * string Result.result -> action
  9. | ResendAudio of int * string * string * string * bool * int option * ReplyMarkup.reply_markup option
  10. | SendDocument of int * string * bool * int option * ReplyMarkup.reply_markup option * string Result.result -> action
  11. | ResendDocument of int * string * bool * int option * ReplyMarkup.reply_markup option
  12. | SendSticker of int * string * bool * int option * ReplyMarkup.reply_markup option * string Result.result -> action
  13. | ResendSticker of int * string * bool * int option * ReplyMarkup.reply_markup option
  14. | SendVideo of int * string * int option * string option * bool * int option * ReplyMarkup.reply_markup option * string Result.result -> action
  15. | ResendVideo of int * string * int option * string option * bool * int option * ReplyMarkup.reply_markup option
  16. | SendVoice of int * string * bool * int option * ReplyMarkup.reply_markup option * string Result.result -> action
  17. | ResendVoice of int * string * bool * int option * ReplyMarkup.reply_markup option
  18. | SendLocation of int * float * float * bool * int option * ReplyMarkup.reply_markup option
  19. | SendVenue of int * float * float * string * string * string option * bool * int option * ReplyMarkup.reply_markup option
  20. | SendContact of int * string * string * string option * bool * int option * ReplyMarkup.reply_markup option
  21. | GetUserProfilePhotos of int * int option * int option * UserProfilePhotos.user_profile_photos Result.result -> action
  22. | GetFile of string * File.file Result.result -> action
  23. | GetFile' of string * string option -> action
  24. | DownloadFile of File.file * string option -> action
  25. | KickChatMember of int * int
  26. | LeaveChat of int
  27. | UnbanChatMember of int * int
  28. | GetChat of int * Chat.chat Result.result -> action
  29. | GetChatAdministrators of int * ChatMember.chat_member list Result.result -> action
  30. | GetChatMembersCount of int * int Result.result -> action
  31. | GetChatMember of int * int * ChatMember.chat_member Result.result -> action
  32. | AnswerCallbackQuery of string * string option * bool
  33. | AnswerInlineQuery of string * InlineQuery.Out.inline_query_result list * int option * bool option * string option
  34. | EditMessageText of [ `ChatMessageId of string * int | `InlineMessageId of string ] * string * ParseMode.parse_mode option * bool * ReplyMarkup.reply_markup option
  35. | EditMessageCaption of [ `ChatMessageId of string * int | `InlineMessageId of string ] * string * ReplyMarkup.reply_markup option
  36. | EditMessageReplyMarkup of [ `ChatMessageId of string * int | `InlineMessageId of string ] * ReplyMarkup.reply_markup option
  37. | GetUpdates of Update.update list Result.result -> action
  38. | PeekUpdate of Update.update Result.result -> action
  39. | PopUpdate of bool * Update.update Result.result -> action
  40. | Chain of action * action

The actions that can be used by the bot's commands

type command = {
  1. name : string;
  2. description : string;
  3. mutable enabled : bool;
  4. run : Message.message -> action;
}

This type is used to represent available commands. The name field is the command's name (without a slash) and the description field is the description to be used in the help message. run is the function called when invoking the command.

val is_command : Update.update -> bool

Tests to see whether an update from the update queue invoked a command

val read_command : string option -> Message.message -> command list -> action

Takes an optional postfix for commands (/cmd@bot), a message, known to represent a command, and a list of possible commands. These values are used to find the matching command and return the actions that it should perform

val read_update : string option -> Update.update -> command list -> action

Reads a single update and, given a list of commands, matches it to a correct command that can be invoked. Takes an optional postfix for commands (/cmd@bot) as the first parameter

val tokenize : string -> string list

Turns a string into the args list that a command may choose to work with

val with_auth : command:(Message.message -> action) -> Message.message -> action

with_auth ~command makes a command only run when the caller is an admin in the chat

OCaml

Innovation. Community. Security.