npm

nextcloud-talk-bot

0.1.5 • Public • Published

Node.js Nextcloud Talk Bot | nctb

This is a Node.js module to interact with the Rest-API provided by Nextcloud.

Install

npm install --save nextcloud-talk-bot

Usage

// Import Class
const NextcloudTalkBot = require('nextlcoud-talk-bot');
 
// Create instance w/ bot login data
const bot = new NextcloudTalkBot({
    server: '<server_url_here>',
    user: '<bot_username_here>',
    pass: '<bot_password_here>',
    autoJoin: true
});
 
// Simple usage; reacts to all channels the bot joined
bot.onText('Somebody in?', x => x.reply('Sure, because you are!'));
 
// Join a channel and react to it's contents
const boppy = bot.getChannel('<channel_id_here>');
 
// Reaction bases on RegExp (simple)
boppy.onText(/^#echo /, msg => msg.reply(msg.text.substr(6), false));
 
// Reaction based on RegExp (anvanced)
boppy.onText(/^#answer ((['"])(?<q1>.*?)(\2)|(?<q2>[^"']\S*)) (?<a>.*)$/, (msg, matches) => {
    bot.onText(matches.groups.q1 || matches.groups.q2, (message) => {
        message.reply(matches.groups.a, false);
    });
});
 
// Need to start polling
bot.startPolling();

See examples directory for some examples on using this module.

Origin

Basically I was trying to replace big-company-based services on my mobile with a fully integrated Nextcloud.

Since Contacts, Calendar, Notes, Office-Apps, etc. are stable enough, I went for the replacement of Telegram/Hangouts/WhatsApp/ with Talk. One massive limitation was that I had chat bots present in my current messaging solution that I didn't want to miss. Their main propose was to notify me in case of infrastructure problems and to help my out with my sieve-based neck attachment.

So I took a look at the available Chat Bots for Telegram and came back to the node module I already used to use - yagop's Telegram Bot API. So I implemented nctb to match some of its behaviour, as being an EventEmitter (based on EventEmitter3) and using .onText() for easy interaction. I also based much of the surroundings on yagop's Repo (like this README and other docs).

Community

The first thank goes out to yagop and contributors for the Telegram Bot API Node.js Module.

We thank all the developers in the Open-Source community who continuously take their time and effort in advancing this project and all underlying projects

As soon as there is one, I'll also be absolutely happy to thank any contributor!

License

The MIT License (MIT)

Copyright © 2020 Henning Bopp henning.bopp@gmail.com

Readme

Keywords

Package Sidebar

Install

npm i nextcloud-talk-bot

Weekly Downloads

1

Version

0.1.5

License

MIT

Unpacked Size

31.3 kB

Total Files

10

Last publish

Collaborators

  • boppy