This repository was archived by the owner on Mar 7, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathentryPoint.example.js
More file actions
43 lines (37 loc) · 1.46 KB
/
entryPoint.example.js
File metadata and controls
43 lines (37 loc) · 1.46 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
import Ayzek from './';
import XBotApiVk from '@meteor-it/xbot/api/vk';
import XBotApiTg from '@meteor-it/xbot/api/tg';
import Logger from '@meteor-it/logger';
import NodeLogger from '@meteor-it/logger/receivers/node';
import {createClient} from 'then-redis';
import ClassicPluginSystem from './pluginSystems/ClassicPluginSystem';
import HubotPluginSystem from './pluginSystems/HubotPluginSystem';
let redis = createClient();
const ayzek = new Ayzek();
// Everything in "ayzek.shared" is shared between other plugins
ayzek.shared.redis = redis;
async function start() {
// Initialize apis
const vkApi = new XBotApiVk();
await vkApi.auth([
'VK TOKEN 1',
'VK TOKEN 2',
'VK TOKEN 3',
'VK TOKEN 4',
'VK TOKEN 5'
]);
const tgApi = new XBotApiTg();
await tgApi.auth('TG TOKEN 1');
// To make bot receive messages from these apis
ayzek.attachApi(vkApi);
ayzek.attachApi(tgApi);
// From "publicPlugins"
ayzek.addPluginLoader(new ClassicPluginSystem('openPlugins',
() => require.context(__dirname + '/publicPlugins', false, /Plugin\/index\.js$/),
(acceptor, getContext) => module.hot.accept(getContext().id, acceptor)));
// Hubot plugins from "hubotPlugins"
ayzek.addPluginLoader(new HubotPluginSystem('hubotPlugins',
() => require.context(__dirname + '/hubotPlugins', false, /\.js$/),
(acceptor, getContext) => module.hot.accept(getContext().id, acceptor)));
}
start();