{"id":27206894,"url":"https://github.com/init-io/jalegram","last_synced_at":"2025-04-09T23:55:53.347Z","repository":{"id":286259168,"uuid":"960893498","full_name":"Init-io/jalegram","owner":"Init-io","description":"Jalegram is a Java library designed to simplify the development of Telegram bots, offering a more user-friendly approach compared to other existing libraries.","archived":false,"fork":false,"pushed_at":"2025-04-06T07:08:07.000Z","size":23,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-09T23:55:48.592Z","etag":null,"topics":["bot","bots","init","jalegram","java","javalibrary","library","telegram","telegram-api","telegram-bot","telegram-bot-api","telegram-bots","telegrambot","telegramserver"],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Init-io.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2025-04-05T09:46:11.000Z","updated_at":"2025-04-06T07:08:10.000Z","dependencies_parsed_at":"2025-04-05T10:22:01.528Z","dependency_job_id":"83bc584f-751b-42db-af3e-e559ea36fb98","html_url":"https://github.com/Init-io/jalegram","commit_stats":null,"previous_names":["init-io/jalegram"],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Init-io%2Fjalegram","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Init-io%2Fjalegram/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Init-io%2Fjalegram/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Init-io%2Fjalegram/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Init-io","download_url":"https://codeload.github.com/Init-io/jalegram/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248131417,"owners_count":21052819,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["bot","bots","init","jalegram","java","javalibrary","library","telegram","telegram-api","telegram-bot","telegram-bot-api","telegram-bots","telegrambot","telegramserver"],"created_at":"2025-04-09T23:55:52.440Z","updated_at":"2025-04-09T23:55:53.331Z","avatar_url":"https://github.com/Init-io.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Jalegram - A Java Telegram Bot Library\n![Maven Central](https://img.shields.io/maven-central/v/io.github.init-io/jalegram.svg?label=Maven%20Central)\n![GitHub Release](https://img.shields.io/github/v/release/init-io/jalegram?label=release)\n[![License](https://img.shields.io/github/license/init-io/jalegram)](LICENSE)\n![downloads](https://img.shields.io/badge/downloads-1k%2Fmonth-brightgreen)\n\nJalegram is a lightweight, user-friendly Java library designed to simplify the development of Telegram bots. It provides a straightforward interface to interact with the Telegram Bot API, offering a wide range of methods to handle messages, media, chat management, and more—all with minimal boilerplate code compared to other libraries.\n\n## Features\n- Easy-to-use methods for sending messages, photos, videos, and other media.\n- Comprehensive chat and user information retrieval.\n- Support for keyboards, inline keyboards, and polls.\n- Chat management tools like banning, promoting, and restricting users.\n- Built-in JSON parsing for seamless interaction with Telegram's API responses.\n- Extensible and well-documented codebase.\n\n## Prerequisites\n- Java 8 or higher\n- Maven or Gradle (for dependency management)\n- A Telegram Bot Token (obtained from [BotFather](https://t.me/BotFather))\n\n## Installation\n\n### Maven\nAdd the following dependency to your `pom.xml`:\n```xml\n\u003cdependency\u003e\n    \u003cgroupId\u003eio.github.initio\u003c/groupId\u003e\n    \u003cartifactId\u003ejalegram\u003c/artifactId\u003e\n    \u003cversion\u003e1.0.0\u003c/version\u003e \u003c!-- Replace with the actual version --\u003e\n\u003c/dependency\u003e\n```\n\n### Gradle\nAdd this line to your `build.gradle`:\n```gradle\nimplementation 'io.github.initio:jalegram:1.0.0' // Replace with the actual version\n```\n\n*Note:* If Jalegram is not yet published to a Maven repository, you'll need to build it locally from the source and install it to your local Maven repository using:\n```bash\nmvn clean install\n```\n\n## Getting Started\n\n1. **Create a Telegram Bot**: Talk to [BotFather](https://t.me/BotFather) on Telegram to create a bot and get your bot token.\n2. **Initialize Jalegram**: Use your bot token to instantiate the `Jalegram` class.\n\n```java\npackage io.github.initio.testproject;\n\nimport io.github.initio.jalegram.Jalegram;\nimport java.io.IOException;\n\npublic class Testproject {\n    static String CHAT_ID = \"\";\n    // Mutable variable now\n\n    public static void main(String[] args) throws IOException {\n        String token = \"YOUR_BOT_TOKEN_HERE\";  // Replace with your bot token\n        Jalegram bot = new Jalegram(token);\n        System.out.println(\"Bot is running...\");\n\n        Thread thread = new Thread(() -\u003e {\n            int offset = 0;\n            while (true) {\n                try {\n                    String updatesResponse = bot.getUpdates(offset);\n\n                    // Get the latest update ID\n                    long updateId = bot.getUpdateId(updatesResponse);\n\n                    if (updateId != -1) {\n                        offset = (int) (updateId + 1);  // Update offset properly\n\n                        String response = bot.getText(updatesResponse);\n                        System.out.println(bot.getUsername(updatesResponse) + \": \" + response + \" UpdateId: \" + updateId);\n\n                        //here inside this loop ,under this comment you can put any logic or condition to make your bot running forever .\n                        if (\"get device info\".equalsIgnoreCase(response)) {\n                            String reply = getDeviceInfo();\n                            if (!reply.isEmpty()) {\n                                bot.sendMessage(CHAT_ID, reply);\n                                System.out.println(\"Bot: \" + reply);\n                            }\n                        }\n                    }\n\n                    Thread.sleep(1000);\n                } catch (IOException | InterruptedException e) {\n                    e.printStackTrace(); // good to keep this in now\n                }\n            }\n        });\n\n        thread.start();\n    }\n\n    private static String getDeviceInfo() {\n        return \"Device Info: OS = \" + System.getProperty(\"os.name\") +\n               \", Version = \" + System.getProperty(\"os.version\") +\n               \", Architecture = \" + System.getProperty(\"os.arch\");\n    }\n}\n\n```\n\nReplace `\"YOUR_BOT_TOKEN_HERE\"` with your actual bot token and `\"CHAT_ID\"` with the target chat ID.\n\n## Available Methods\n\n### Core Messaging\n- `sendMessage(chatId, text)`: Send a text message.\n- `sendReplyMessage(chatId, text, replyToMessageId)`: Reply to a specific message.\n- `editMessage(chatId, messageId, newText)`: Edit an existing message.\n- `deleteMessage(chatId, messageId)`: Delete a message.\n- `forwardMessage(chatId, fromChatId, messageId)`: Forward a message.\n\n### Media Sending\n- `sendPhoto(chatId, photo, caption)`: Send a photo.\n- `sendVideo(chatId, video, caption)`: Send a video.\n- `sendAudio(chatId, audio, caption)`: Send an audio file.\n- `sendFile(chatId, file, caption)`: Send any document/file.\n- `sendSticker(chatId, sticker)`: Send a sticker.\n- `sendVoice(chatId, voice, caption)`: Send a voice message.\n- `sendAnimation(chatId, animation, caption)`: Send an animation (GIF).\n\n### Updates and Information Retrieval\n- `getUpdates(offset)`: Fetch bot updates.\n- `getText(jsonResponse)`: Extract message text from updates.\n- `getChatId(jsonResponse)`: Get the chat ID from updates.\n- `getUserId(jsonResponse)`: Get the user ID from updates.\n- `getUsername(jsonResponse)`: Get the user's username.\n- `getUserFirstName(jsonResponse)`: Get the user's first name.\n- `getUserLastName(jsonResponse)`: Get the user's last name.\n- `getChatType(jsonResponse)`: Get the chat type (e.g., private, group).\n- `getMessageId(jsonResponse)`: Get the message ID.\n- `getUpdateId(jsonResponse)`: Get the update ID.\n- `getDate(jsonResponse)`: Get the message timestamp.\n\n### Keyboards\n- `sendKeyboard(chatId, text, buttons)`: Send a custom keyboard.\n- `sendInlineKeyboard(chatId, text, buttons, callbackData)`: Send an inline keyboard with callback data.\n\n### Chat Management\n- `banChatMember(chatId, userId)`: Ban a user from a chat.\n- `unbanChatMember(chatId, userId)`: Unban a user.\n- `restrictChatMember(chatId, userId, canSendMessages)`: Restrict a user's permissions.\n- `promoteChatMember(chatId, userId)`: Promote a user to admin.\n- `setChatTitle(chatId, title)`: Set the chat title.\n- `setChatPhoto(chatId, photo)`: Set the chat photo.\n- `leaveChat(chatId)`: Make the bot leave a chat.\n- `pinChatMessage(chatId, messageId)`: Pin a message.\n- `unpinChatMessage(chatId, messageId)`: Unpin a message (or all if `messageId` is null).\n\n### Miscellaneous\n- `sendLocation(chatId, latitude, longitude)`: Send a location.\n- `sendPoll(chatId, question, options)`: Send a poll.\n- `sendDice(chatId)`: Send a dice animation.\n- `getChatMember(chatId, userId)`: Get chat member info.\n- `getChatAdministrators(chatId)`: Get list of chat admins.\n- `getChatMembersCount(chatId)`: Get the number of chat members.\n- `getFile(fileId)`: Get file details by file ID.\n- `setMyCommands(commands)`: Set custom bot commands.\n\n## Example: Simple Echo Bot\n\n```java\nimport io.github.initio.jalegram.Jalegram;\nimport java.io.IOException;\n\npublic class EchoBot {\n    public static void main(String[] args) throws IOException {\n        Jalegram bot = new Jalegram(\"YOUR_BOT_TOKEN_HERE\");\n        int offset = 0;\n\n        while (true) {\n            String updates = bot.getUpdates(offset);\n            long updateId = bot.getUpdateId(updates);\n            if (updateId != -1) {\n                offset = (int) updateId + 1;\n                String text = bot.getText(updates);\n                long chatId = bot.getChatId(updates);\n                if (!text.isEmpty()) {\n                    bot.sendMessage(String.valueOf(chatId), \"You said: \" + text);\n                }\n            }\n            try {\n                Thread.sleep(1000); // Polling delay\n            } catch (InterruptedException e) {\n                e.printStackTrace();\n            }\n        }\n    }\n}\n```\n\n## Contributing\nContributions are welcome! Feel free to submit a pull request or open an issue on the [GitHub repository](https://github.com/init-io/jalegram) (replace with your actual repo link).\n\n## License\nThis project is licensed under the MIT License. See the [LICENSE](LICENSE) file for details.\n\n## Acknowledgements\n- Built with [OkHttp](https://square.github.io/okhttp/) for HTTP requests.\n- Inspired by the Telegram Bot API community.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Finit-io%2Fjalegram","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Finit-io%2Fjalegram","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Finit-io%2Fjalegram/lists"}