Did you know ... Search Documentation:
Pack telegrambot -- prolog/telegrambot.pl
PublicShow source

Predicates to use the Telegram Bot API.

The following example sends a "Message Received" text in response to the /start command from any client:

:- use_module(library(telegrambot)).

use_token('the bot Token from the BotFather here').

get_chat_id(json(Lst), Id) :-
  member(message=json(A), Lst),
  member(chat=json(B), A),
  member(id=Id, B).

start_handler(Message, Params) :-
  write('start received'),
  get_chat_id(Message, ChatId),
  send_message(ChatId, 'Message Received', [], _).

command_handler(start, start_handler).

main_pred :-

:- initialization(main_pred, main).
- Gimenez, Christian
- GPLv3
Set the token. This is needed for authenticating the bot with Telegram.
 send_message(+Chat_id:number, +Text:term, +Options:list, -Return:term)
Instruct the bot to send a message.


send_message(12345, 'Hello *world*', [parse_mode='Markdown'], Return).
Chat_id- A term or number.
Text- A term with the text to send.
Options- A list of a=b elements.
Return- A json/1 term with the answer parsed.
 command_handler(+Command:term, +Pred:term)
Register a command handler.
Command- The command name (without /).
Pred- The predicate name to be executed. It must posses two parameters, the command name term and the parameters.
Start the loop. Gathers the last messages and process them.

Undocumented predicates

The following predicates are exported, but not or incorrectly documented.

 get_chat(Arg1, Arg2)
 get_updates(Arg1, Arg2)