UNPKG

1.86 kBJavaScriptView Raw
1'use strict'
2
3const BaseTelegramDataSource = require('./BaseTelegramDataSource')
4
5class TelegramDataSource extends BaseTelegramDataSource {
6 /**
7 *
8 * @param {TelegramApi} api
9 * @param {TelegramRouter} router
10 * @param {BaseLogger} logger
11 * @param {TelegramSessionStorage} sessionStorage
12 * @param {Ivan} localization
13 * @param {TelegramIPC} ipc
14 */
15 constructor(api, router, logger, sessionStorage, localization, ipc) {
16 super()
17
18 this._api = api
19 this._router = router
20 this._logger = logger
21 this._scopeExtensions = []
22 this._sessionStorage = sessionStorage
23 this._localization = localization
24 this._ipc = ipc
25 }
26
27 /**
28 *
29 * @returns {TelegramApi}
30 */
31 get api() {
32 return this._api
33 }
34
35 /**
36 *
37 * @returns {TelegramRouter}
38 */
39 get router() {
40 return this._router
41 }
42
43 /**
44 *
45 * @returns {BaseLogger}
46 */
47 get logger() {
48 return this._logger
49 }
50
51 /**
52 *
53 * @returns {BaseScopeExtension[]}
54 */
55 get scopeExtensions() {
56 return this._scopeExtensions
57 }
58
59 /**
60 *
61 * @returns {TelegramSessionStorage}
62 */
63 get sessionStorage() {
64 return this._sessionStorage
65 }
66
67 /**
68 *
69 * @returns {Ivan}
70 */
71 get localization() {
72 return this._localization
73 }
74
75 /**
76 * @returns {TelegramIPC}
77 */
78 get ipc() {
79 return this._ipc
80 }
81
82 /**
83 *
84 * @param {BaseScopeExtension|BaseScopeExtension[]} extension
85 */
86 addScopeExtension(extension) {
87 if (Array.isArray(extension)) {
88 extension.forEach(this._scopeExtensions.push)
89
90 return
91 }
92
93 this._scopeExtensions.push(extension)
94 }
95}
96
97module.exports = TelegramDataSource
\No newline at end of file