catto.js 0.4.7 → 0.4.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/TelegramBot.js +23 -2
- package/package.json +1 -1
package/TelegramBot.js
CHANGED
|
@@ -24,6 +24,7 @@ module.exports = class extends EventEmitter {
|
|
|
24
24
|
}
|
|
25
25
|
this.commands = new Map();
|
|
26
26
|
this.slashCommands = new Map();
|
|
27
|
+
this.menubtn = "commands";
|
|
27
28
|
if (this.options.debug) {
|
|
28
29
|
this.client.on("polling_error", console.log);
|
|
29
30
|
this.client.on("webhook_error", console.log);
|
|
@@ -31,7 +32,6 @@ module.exports = class extends EventEmitter {
|
|
|
31
32
|
} else {
|
|
32
33
|
this.client.on("polling_error", () => {});
|
|
33
34
|
this.client.on("webhook_error", () => {});
|
|
34
|
-
this.client.on("error", () => {});
|
|
35
35
|
}
|
|
36
36
|
this.client.on("message", message => {
|
|
37
37
|
message = new TelegramMessage(message, this);
|
|
@@ -42,7 +42,7 @@ module.exports = class extends EventEmitter {
|
|
|
42
42
|
try {
|
|
43
43
|
command.execute({
|
|
44
44
|
message,
|
|
45
|
-
|
|
45
|
+
command,
|
|
46
46
|
args,
|
|
47
47
|
"bot": this
|
|
48
48
|
});
|
|
@@ -73,6 +73,10 @@ module.exports = class extends EventEmitter {
|
|
|
73
73
|
}));
|
|
74
74
|
return this;
|
|
75
75
|
}
|
|
76
|
+
menuButton(target, label, link) {
|
|
77
|
+
this.menubtn = { target, label, link };
|
|
78
|
+
return this;
|
|
79
|
+
}
|
|
76
80
|
async run() {
|
|
77
81
|
await this.client.startPolling();
|
|
78
82
|
var commands = [];
|
|
@@ -83,6 +87,23 @@ module.exports = class extends EventEmitter {
|
|
|
83
87
|
});
|
|
84
88
|
}
|
|
85
89
|
this.client.setMyCommands(commands);
|
|
90
|
+
if (this.menubtn.target == "web") {
|
|
91
|
+
this.client.setChatMenuButton({
|
|
92
|
+
"menu_button": JSON.stringify({
|
|
93
|
+
"type": "web_app",
|
|
94
|
+
"text": this.menubtn.label,
|
|
95
|
+
"web_app": {
|
|
96
|
+
"url": this.menubtn.link
|
|
97
|
+
}
|
|
98
|
+
})
|
|
99
|
+
});
|
|
100
|
+
} else {
|
|
101
|
+
this.client.setChatMenuButton({
|
|
102
|
+
"menu_button": JSON.stringify({
|
|
103
|
+
"type": "commands"
|
|
104
|
+
})
|
|
105
|
+
});
|
|
106
|
+
}
|
|
86
107
|
return this;
|
|
87
108
|
}
|
|
88
109
|
async stop() {
|