@ingestkorea/client-telegram
v1.2.0
Published
INGESTKOREA SDK Telegram Client for Node.js.
Downloads
26
Maintainers
Readme
@ingestkorea/client-telegram
Description
INGESTKOREA SDK Telegram Client for Node.js.
Installing
npm install @ingestkorea/client-telegram
Getting Started
Pre-requisites
- Use TypeScript v5.x
- Includes the TypeScript definitions for node.
npm install -D @types/node # save dev mode
Support Commands
- SendMessage
Import
import {
TelegramClient,
SendMessageCommand,
SendMessageCommandInput,
} from "@ingestkorea/client-telegram";
Usage
To send a request, you:
- Initiate client with configuration.
- Initiate command with input parameters.
- Call
send
operation on client with command object as input.
// a client can be shared by different commands.
const client = new TelegramClient({
credentials: {
token: TOKEN, // 0123456789:ABCDEFG
chatId: CHAT_ID, // 9876543210 (string | number)
},
});
const input: SendMessageCommandInput = {
text: "hello client-telegram",
chatId: CHAT_ID, // optional // this chatId override TelegramClient config
};
const command = new SendMessageCommand(input);
Async/await
(async () => {
try {
const data = await client.send(command);
console.dir(data, { depth: 4 });
} catch (err) {
console.log(err);
}
})();
Promises
client
.send(command)
.then((data) => console.dir(data, { depth: 4 }))
.catch((err) => console.log(err));
License
This SDK is distributed under the MIT License, see LICENSE for more information.