|
| 1 | +-- Trigger - Telegram FFI Bindings Specification |
| 2 | +-- |
| 3 | +-- Ada bindings for Telegram API via Zig FFI (unified-hexadeca-api) |
| 4 | +-- |
| 5 | +-- This package provides the interface for calling Telegram functions |
| 6 | +-- implemented in Zig through C-exported symbols. |
| 7 | +-- |
| 8 | +-- Author: hyperpolymath |
| 9 | +-- Architecture: Ada/SPARK <- Idris2 <- Zig (FFI) |
| 10 | +-- License: MPL-2.0 |
| 11 | +-- SPDX-License-Identifier: MPL-2.0 |
| 12 | + |
| 13 | +package Trigger.FFI.Telegram is |
| 14 | + |
| 15 | + -- Telegram client handle (opaque pointer from Zig) |
| 16 | + type Telegram_Client_Ptr is access all Integer; |
| 17 | + |
| 18 | + -- Telegram message handle |
| 19 | + type Telegram_Message_Ptr is access all Integer; |
| 20 | + |
| 21 | + -- Telegram user handle |
| 22 | + type Telegram_User_Ptr is access all Integer; |
| 23 | + |
| 24 | + -- Telegram chat/channel handle |
| 25 | + type Telegram_Chat_Ptr is access all Integer; |
| 26 | + |
| 27 | + -- Maximum string lengths |
| 28 | + Max_Phone_Length : constant := 20; |
| 29 | + Max_Username_Length : constant := 64; |
| 30 | + Max_Message_Length : constant := 4096; |
| 31 | + |
| 32 | + -- Create a Telegram client |
| 33 | + function Create_Client ( |
| 34 | + Api_Id : Integer; |
| 35 | + Api_Hash : String; |
| 36 | + Session_Dir : String |
| 37 | + ) return Telegram_Client_Ptr |
| 38 | + with Import, Convention => C, External_Name => "create_telegram_client"; |
| 39 | + |
| 40 | + -- Destroy a Telegram client |
| 41 | + procedure Destroy_Client (Client : Telegram_Client_Ptr) |
| 42 | + with Import, Convention => C, External_Name => "destroy_telegram_client"; |
| 43 | + |
| 44 | + -- Connect to Telegram |
| 45 | + function Connect (Client : Telegram_Client_Ptr) return Integer |
| 46 | + with Import, Convention => C, External_Name => "telegram_client_connect"; |
| 47 | + |
| 48 | + -- Disconnect from Telegram |
| 49 | + procedure Disconnect (Client : Telegram_Client_Ptr) |
| 50 | + with Import, Convention => C, External_Name => "telegram_client_disconnect"; |
| 51 | + |
| 52 | + -- Check if connected |
| 53 | + function Is_Connected (Client : Telegram_Client_Ptr) return Integer |
| 54 | + with Import, Convention => C, External_Name => "telegram_client_is_connected"; |
| 55 | + |
| 56 | + -- Check if authorized |
| 57 | + function Is_Authorized (Client : Telegram_Client_Ptr) return Integer |
| 58 | + with Import, Convention => C, External_Name => "telegram_client_is_authorized"; |
| 59 | + |
| 60 | + -- Get current user |
| 61 | + function Get_Me (Client : Telegram_Client_Ptr) return Telegram_User_Ptr |
| 62 | + with Import, Convention => C, External_Name => "telegram_client_get_me"; |
| 63 | + |
| 64 | + -- Get messages from a chat/channel |
| 65 | + function Get_Messages ( |
| 66 | + Client : Telegram_Client_Ptr; |
| 67 | + Chat_Identifier : String; |
| 68 | + Limit : Integer |
| 69 | + ) return Telegram_Message_Ptr |
| 70 | + with Import, Convention => C, External_Name => "telegram_client_get_messages"; |
| 71 | + |
| 72 | + -- Report a message |
| 73 | + procedure Report_Message ( |
| 74 | + Client : Telegram_Client_Ptr; |
| 75 | + Chat_Identifier : String; |
| 76 | + Message_Id : Integer; |
| 77 | + Reason : Integer |
| 78 | + ) |
| 79 | + with Import, Convention => C, External_Name => "telegram_client_report_message"; |
| 80 | + |
| 81 | + -- Send a message |
| 82 | + function Send_Message ( |
| 83 | + Client : Telegram_Client_Ptr; |
| 84 | + Chat_Identifier : String; |
| 85 | + Content : String |
| 86 | + ) return Telegram_Message_Ptr |
| 87 | + with Import, Convention => C, External_Name => "telegram_client_send_message"; |
| 88 | + |
| 89 | + -- Ping the Telegram API |
| 90 | + function Ping (Client : Telegram_Client_Ptr) return Integer |
| 91 | + with Import, Convention => C, External_Name => "telegram_client_ping"; |
| 92 | + |
| 93 | +end Trigger.FFI.Telegram; |
0 commit comments