icq-bot
Pure NodeJS/TypeScript interface for Bot API.
Table of contents
Introduction
This library provides complete Bot API 1.0 interface and compatible with Node.js v13.10.1
Getting started
Create your own bot by sending the /newbot command to Metabot and follow the instructions.
Note a bot can only reply after the user has added it to his contact list, or if the user was the first to start a dialogue.
Installing
Install using npm:
npm install icq-bot
Using
initialization
const ICQ = requier("icq-bot").default;
const TOKEN = "XXX.XXX.XXX:XXX"
const bot = new ICQ.Bot(TOKEN);
send message
const chatId = "XXX";
bot.sendText(charID,"TEXT HERE..").then( response =>{ console.log( response.ok ) });
How using pooling
You can using handlers: ICQ.Handler.* :
- HelpCommand
- Message
- NewChatMembers
- LeftChatMembers
- PinnedMessage
- UnPinnedMessage
- EditedMessage
- DeletedMessage
- Command
- StartCommand
- FeedbackCommand
- UnknownCommand
let handler = new ICQ.Handler.Message(null, (bot, event) => { });
bot.getDispatcher().addHandler(handler);
bot.startPolling();
How using filter
You can using handlers: ICQ.Filters.* :
- message
- command - only comman where message start on "/" or "."
- file
- image
- video
- audio
- media
- sticker
- url
- regexp
- mention
- forward
- reply
- sender
let handler = new ICQ.Handler.Message(new ICQ.Filter.url(), (bot, event) => {
// code here
});
bot.getDispatcher().addHandler(handler);
bot.startPolling();
API description