Skip to content
This repository has been archived by the owner on Dec 26, 2021. It is now read-only.

Is there a method to send a message to all used messengers? #29

Open
tenorok opened this issue Jan 8, 2018 · 1 comment
Open

Is there a method to send a message to all used messengers? #29

tenorok opened this issue Jan 8, 2018 · 1 comment

Comments

@tenorok
Copy link
Contributor

tenorok commented Jan 8, 2018

For example we registered a few messengers via use-method:

const bot = new Bot({
  logLevel: "info"
});

bot.use(new BroidDiscord({...options}));
bot.use(new BroidMessenger({...options}));
bot.use(new BroidSlack({...options}));

And now we need to send message for all of these messengers:

bot.on('Person').subscribe(); // For execute `.connect()` on every integration (1)
bot.sendText('Hello World!', {
    '@context': 'https://www.w3.org/ns/activitystreams',
    generator: { ... }, // Discord
    published: 1515442064,
    type: 'Note',
    target: { id: '635580', name: 'Artem Kurbatov', type: 'Person' }
});
// And two more times for Messenger and Slack.

How we can send message to all registered messengers at one time?

P.S.: Why published property is reduced by a thousand?

(1) https://github.com/broidHQ/broid-kit/blob/master/src/core/Bot.ts#L111

@tenorok tenorok changed the title Is there a method to send a message to all used messengers Is there a method to send a message to all used messengers? Jan 8, 2018
@tenorok
Copy link
Contributor Author

tenorok commented Jan 10, 2018

I understood that in this approach we have a problem to pass the different target.id for each messenger.
By the way, after this pull request we can pass only really needed parameters:

this.bot.sendText('Hello!', {
    generator: {
        id: ???, // ← id is a hard to search
        name: 'telegram',
    },
    target: {
        id: '49328423',
        type: 'Person',
    },
});

But generator.id is hard to search and for simplification I offer to create a getIntegration()-method:

this.bot.sendText('Hello!', {
    generator: {
        id: bot.getIntegration('telegram'),
        name: 'telegram',
    },
    target: {
        id: '49328423',
        type: 'Person',
    },
});

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant