- Saved searches
- Use saved searches to filter your results more quickly
- License
- rubenlagus/TelegramBots
- Name already in use
- Sign In Required
- Launching GitHub Desktop
- Launching GitHub Desktop
- Launching Xcode
- Launching Visual Studio Code
- Latest commit
- Git stats
- Files
- README.md
- About
- Saved searches
- Use saved searches to filter your results more quickly
- License
- Telegram4J/Telegram4J
- Name already in use
- Sign In Required
- Launching GitHub Desktop
- Launching GitHub Desktop
- Launching Xcode
- Launching Visual Studio Code
- Latest commit
- Git stats
- Files
- README.md
- Saved searches
- Use saved searches to filter your results more quickly
- License
- rubenlagus/TelegramApi
- Name already in use
- Sign In Required
- Launching GitHub Desktop
- Launching GitHub Desktop
- Launching Xcode
- Launching Visual Studio Code
- Latest commit
- Git stats
- Files
- README.MD
- About
Saved searches
Use saved searches to filter your results more quickly
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session. You switched accounts on another tab or window. Reload to refresh your session.
Java library to create bots using Telegram Bots API
License
rubenlagus/TelegramBots
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Sign In Required
Please sign in to use Codespaces.
Launching GitHub Desktop
If nothing happens, download GitHub Desktop and try again.
Launching GitHub Desktop
If nothing happens, download GitHub Desktop and try again.
Launching Xcode
If nothing happens, download Xcode and try again.
Launching Visual Studio Code
Your codespace will open once ready.
There was a problem preparing your codespace, please try again.
Latest commit
Git stats
Files
Failed to load latest commit information.
README.md
Telegram Bot Java Library
A simple to use library to create Telegram Bots in Java
Feel free to fork this project, work on it and then make a pull request against DEV branch. Most of the times I will accept them if they add something valuable to the code.
Please, DO NOT PUSH ANY TOKEN OR API KEY, I will never accept a pull request with that content.
Both ways are supported, but I recommend long polling method.
Just import add the library to your project with one of these options:
dependency> groupId>org.telegramgroupId> artifactId>telegrambotsartifactId> version>6.7.0version> dependency>
implementation 'org.telegram:telegrambots:6.7.0'
In order to use Long Polling mode, just create your own bot extending org.telegram.telegrambots.bots.TelegramLongPollingBot .
If you like to use Webhook, extend org.telegram.telegrambots.bots.TelegramWebhookBot
Once done, you just need to create a org.telegram.telegrambots.meta.TelegramBotsApi and register your bots:
// Example taken from https://github.com/rubenlagus/TelegramBotsExample public class Main < public static void main(String[] args) < try < TelegramBotsApi telegramBotsApi = new TelegramBotsApi(DefaultBotSession.class); telegramBotsApi.registerBot(new ChannelHandlers()); telegramBotsApi.registerBot(new DirectionsHandlers()); telegramBotsApi.registerBot(new RaeHandlers()); telegramBotsApi.registerBot(new WeatherHandlers()); telegramBotsApi.registerBot(new TransifexHandlers()); telegramBotsApi.registerBot(new FilesHandlers()); > catch (TelegramApiException e) < e.printStackTrace(); > > >
For detailed explanation, visite our How To (thanks Clevero)
Open them and send them /help command to get some information about their capabilities:
You can see code for those bots at TelegramBotsExample project.
This library use Telegram bot API, you can find more information following the link.
Feel free to create issues here as you need or join the chat
Copyright (c) 2016 Ruben Bermudez
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the «Software»), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED «AS IS», WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
About
Java library to create bots using Telegram Bots API
Saved searches
Use saved searches to filter your results more quickly
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session. You switched accounts on another tab or window. Reload to refresh your session.
Reactive Java library for the Telegram API
License
Telegram4J/Telegram4J
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Sign In Required
Please sign in to use Codespaces.
Launching GitHub Desktop
If nothing happens, download GitHub Desktop and try again.
Launching GitHub Desktop
If nothing happens, download GitHub Desktop and try again.
Launching Xcode
If nothing happens, download Xcode and try again.
Launching Visual Studio Code
Your codespace will open once ready.
There was a problem preparing your codespace, please try again.
Latest commit
Git stats
Files
Failed to load latest commit information.
README.md
Reactive Java library for Telegram MTProto API written with Java 17.
repositories < mavenCentral() // This repository is necessary to use the snapshot version maven("https://s01.oss.sonatype.org/content/repositories/snapshots") > dependencies < implementation("com.telegram4j:telegram4j-core:0.1.0-SNAPSHOT") >
repositories> repository> id>s01.oss.sonatype.org-snapshotid> url>https://s01.oss.sonatype.org/content/repositories/snapshotsurl> snapshots> enabled>trueenabled> snapshots> repository> repositories> dependencies> dependency> groupId>com.telegram4jgroupId> artifactId>telegram4j-coreartifactId> version>0.1.0-SNAPSHOTversion> dependency> dependencies>
Example of a bot that will respond to a message with text !ping reply with the text pong!
public class ExampleReplyBot < public static void main(String[] args) < // values from https://core.telegram.org/api/obtaining_api_id#obtaining-api-id int apiId = ""; String apiHash = ""; // value from https://t.me/BotFather DM String botAuthToken = ""; MTProtoTelegramClient client = MTProtoTelegramClient.create(apiId, apiHash, botAuthToken).connect().block(); client.on(SendMessageEvent.class) .filter(e -> e.getMessage().getContent().equals("!ping")) .flatMap(e -> Mono.justOrEmpty(e.getChat()) // telegram api may not deliver chat info and in this situation it's necessary to retrieve chat .switchIfEmpty(e.getMessage().getChat()) .flatMap(c -> c.sendMessage(SendMessageSpec.of("pong!") .withReplyTo(ReplyToMessageSpec.of(e.getMessage()))))) .subscribe(); // wait until the client is stopped through `client.disconnect()` client.onDisconnect().block(); > >
For additional examples, check this packages in the repository
Saved searches
Use saved searches to filter your results more quickly
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session. You switched accounts on another tab or window. Reload to refresh your session.
Java library to create Telegram Clients
License
rubenlagus/TelegramApi
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Sign In Required
Please sign in to use Codespaces.
Launching GitHub Desktop
If nothing happens, download GitHub Desktop and try again.
Launching GitHub Desktop
If nothing happens, download GitHub Desktop and try again.
Launching Xcode
If nothing happens, download Xcode and try again.
Launching Visual Studio Code
Your codespace will open once ready.
There was a problem preparing your codespace, please try again.
Latest commit
Git stats
Files
Failed to load latest commit information.
README.MD
Java library that implements Telegram API to create Telegram Clients
Feel free to fork this project, work on it and then make a pull request to dev branch.
Please, DO NOT PUSH ANY API KEY OR API HASH, I will never accept a pull request with that content.
Just add the library to your project with one of these options:
dependency> groupId>org.telegramgroupId> artifactId>telegramapiartifactId> version>66.2version> dependency>
If you want more information about Telegram API, you can go here. And here you will find extra information about mtproto.
Feel free to create issues here as you need
I know this project still have many things to improve, please be patient or help me with it.
- To ex3ndr, whose code was the base of this bot long, long ago. Not much remains from that point, but still there are a few files.
- To Drklo, whose code was also helpful in this project.
- To Marvin for all the help, testing and programing that he spends in this project.
- To Telegram Team for their help while developing it.
Copyright (c) 2016 Ruben Bermudez
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the «Software»), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED «AS IS», WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
About
Java library to create Telegram Clients