All Projects → tamtam-chat → tamtam-bot-api

tamtam-chat / tamtam-bot-api

Licence: Apache-2.0 License
Java Client for TamTam Bot API

Programming Languages

java
68154 projects - #9 most used programming language
HTML
75241 projects

Projects that are alternatives of or similar to tamtam-bot-api

telegram
📚 Golang bindings for Telegram API
Stars: ✭ 15 (-25%)
Mutual labels:  bots
test-infra
Falco workflow & testing infrastructure
Stars: ✭ 18 (-10%)
Mutual labels:  bots
Rubicon
Dead yo!
Stars: ✭ 14 (-30%)
Mutual labels:  bots
YouTube-Viewer
A multithreaded view bot for YouTube
Stars: ✭ 529 (+2545%)
Mutual labels:  bots
iam
💚 Introduction Bot for slack teams:
Stars: ✭ 12 (-40%)
Mutual labels:  bots
intelligo-generator
🛠️ Chatbot generator for Intelligo Framework.
Stars: ✭ 31 (+55%)
Mutual labels:  bots
Idle-RPG-Bot
An Idle-RPG bot for Discord
Stars: ✭ 47 (+135%)
Mutual labels:  bots
awesome-twitter-bots
A Curated Collection of the Best Twitter Bots 🤖
Stars: ✭ 99 (+395%)
Mutual labels:  bots
jsrobowar
👾 A port of RoboWar to the web browser using JavaScript and HTML5. (2010)
Stars: ✭ 31 (+55%)
Mutual labels:  bots
Discord-Bot-TypeScript-Template
Discord bot - A discord.js bot template written with TypeScript.
Stars: ✭ 86 (+330%)
Mutual labels:  bots
DM-BOT
📧 DM-BOT is discord bot that can record direct messages. One of us! You can also reply to those messages! DM-BOT is easy to use & understand! I decided to use Discord.js, it's literally the best.
Stars: ✭ 31 (+55%)
Mutual labels:  bots
puppeteer-email
Email automation driven by headless chrome.
Stars: ✭ 135 (+575%)
Mutual labels:  bots
politic-bots
Tools and algorithms to analyze Paraguayan Tweets in times of elections
Stars: ✭ 26 (+30%)
Mutual labels:  bots
cerb-release
For over 20 years, teams of all sizes have used Cerb to manage their email workloads. Whether you're a solo founder replying to a few support messages per day, or a team with hundreds of members replying to thousands of messages per hour, you can serve your audience faster with Cerb's time-tested tools. Development at: https://github.com/jstande…
Stars: ✭ 37 (+85%)
Mutual labels:  bots
Trinity-Bots
NPCBots for TrinityCore 3.3.5
Stars: ✭ 124 (+520%)
Mutual labels:  bots
chatbase-node
Quickly integrate your Node.js chatbot with Chatbase Analytics
Stars: ✭ 74 (+270%)
Mutual labels:  bots
intelligo.js.org
The official website for Intelligo chatbot framework.
Stars: ✭ 18 (-10%)
Mutual labels:  bots
Chat-Bot
Chatbot – is a computer program that simulates a natural human conversation. Users communicate with a chatbot via the chat interface or by voice, like how they would talk to a real person.
Stars: ✭ 26 (+30%)
Mutual labels:  bots
Python-Botnet
This is a simple DDoS python botnet script with remote monitoring & management for education purposes.
Stars: ✭ 119 (+495%)
Mutual labels:  bots
turkce-kufur-karaliste
Türkçe için bir kara liste (blacklist)
Stars: ✭ 117 (+485%)
Mutual labels:  bots

Maven Build Coverage Status Javadocs

TamTam Bot API Java Client

This is Java client for TamTam Bot API. It gives you full access to API in your Java code.

Library has been built based on TamTam Bot API Schema that is OpenAPI-compliant.

Full documentation of API can be found here.

⚠️ This library provides just a thin client to invoke API methods. Take a look at tamtam-bot-sdk framework to build bots.

Requirements

Minimum required version of Java is 8.

To use TamTam Bot API you should obtain ACCESS_TOKEN for each bot you create.

Talk to @PrimeBot. It will helps you to create your first bot.

Dependencies

Usage

To start using this client add it as Maven dependency:

<dependency>
    <groupId>chat.tamtam</groupId>
    <artifactId>tamtam-bot-api</artifactId>
    <version>0.5.0</version>
</dependency>

Initialization

The easiest way to create it is to call:

TamTamBotAPI api = TamTamBotAPI.create("%ACCESS_TOKEN%);

It will create client with default Jackson-based serializer and OkHttp-based HTTP client. If you want to use your own implementation you can implement TamTamTransportClient and TamTamSerializer and initialize TamTamClient with it:

TamTamTransportClient transportClient = …;
TamTamSerializer serializer = …;
TamTamClient client = new TamTamClient("%ACCESS_TOKEN%", transportClient, serializer);
TamTamBotAPI botAPI = new TamTamBotAPI(client);

Making requests

TamTamBotAPI provides access to all methods supported by the API. All methods return TamTamQuery object that can be executed synchronous or asynchronous.

For example:

String fileToken = …;
Long userId = …;

AttachmentRequest fileAttachment = new FileAttachmentRequest(new UploadedInfo(fileToken));
List<AttachmentRequest> attachments = Collections.singletonList(fileAttachment);
NewMessageBody body = new NewMessageBody("hello world!", attachments, null);
SendMessageQuery sendMessageQuery = botAPI.sendMessage(body).userId(userId);

// Sync
SendMessageResult result = sendMessageQuery.execute();

// Async
Future<SendMessageResult> futureResult = sendMessageQuery.enqueue();

Uploading media

Your bot is able to attach some media content to messages. It could be image, video, audio or file.

To attach media to message you should follow two steps:

  1. Obtain URL to upload:
UploadEndpoint endpoint = botAPI.getUploadUrl(UploadType.VIDEO).execute();
String uploadUrl = endpoint.getUrl();
  1. Upload binary data to this url. You can manually execute HTTP-request to send binary data to this url, or use built-in TamTamUploadAPI:
TamTamUploadAPI uploadAPI = new TamTamUploadAPI(client);
UploadedInfo uploadedInfo = uploadAPI.uploadFile(uploadUrl, new File("%FILE_PATH%")).execute();

Important notice

It may take a time for server to process you file (audio/video or binary file). While file is not processed you can't attach it and will get AttachmentNotReadyException when calling sendMessage method. Try again until you'll get successful result.

Handling exceptions

All methods can throw two type of exceptions:

  1. ClientException: general exception type wrapping all kinds of IO/serialization exceptions.

  2. APIException: exception you will get if API was used incorrectly. For example, some arguments are missing or access to requested resource is denied.

Logging

No logging is performed by default. This project uses SLF4J, so you should bring adapter for logging framework you prefer. For example, add slf4j-log4j12 as dependency:

<dependency>
    <groupId>org.slf4j</groupId>
    <artifactId>slf4j-log4j12</artifactId>
    <version>1.7.25</version>
</dependency>

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

Please make sure to update tests as appropriate.

License

This project is licensed under the Apache 2.0.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].