Skip to content
Renat Suleymanov edited this page Mar 26, 2025 · 11 revisions

fp-telegram

fp-telegram is a framework for creating Telegram bots using FreePascal/Lazarus. It provides a convenient API for working with the Telegram Bot API, allowing developers to create bots quickly and efficiently.

Features

  • Sending and receiving messages
  • Handling commands and inline buttons
  • Working with attachments (photos, videos, files)
  • Support for both webhook and long polling
  • Easy integration with other modules

Installation

See the Installation Guide.

Quick Start

A simple bot example:

program QuickStart;

{$mode objfpc}{$H+}

uses
  {$IFDEF UNIX}
  cthreads,
  {$ENDIF}
  Classes, fptelegram, SysUtils, tgsendertypes;

const
  { You will receive a token when you create your bot using @BotFather.
    See the section: Creating a Telegram bot in Lazarus (Longpolling) (Guides & Tutorials)}
  BOT_TOKEN = 'YOUR_TOKEN';
  CHAT_ID = 123456789; // Replace it with the real recipient's chat_id

var
  Reply: String;
begin
  if TgBotSendMessage(BOT_TOKEN, CHAT_ID, 'Hello from fp-telegram!', Reply) then
    WriteLn('Message sent successfully')
  else
    WriteLn('Error sending message: ', Reply);
end.    

Guides & Tutorials

Networking & Security

Clone this wiki locally