Skip to content
This repository was archived by the owner on Feb 7, 2025. It is now read-only.

Commit e7ea0d7

Browse files
committed
Refactoring
1 parent be6637c commit e7ea0d7

13 files changed

+22
-24
lines changed

LICENSE

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,4 @@ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
1818
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
1919
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
2020
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21-
SOFTWARE.
21+
SOFTWARE.

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -447,4 +447,4 @@ Use this method to get current webhook status.
447447

448448
##### `deleteWebhook()`
449449

450-
Use this method to remove webhook integration if you decide to switch back to getUpdates. Returns `True` on success.
450+
Use this method to remove webhook integration if you decide to switch back to getUpdates. Returns `True` on success.

examples/edit-text.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ bot.on('/time', msg => {
1313
function updateTime(chatId, messageId) {
1414

1515
// Update every second
16-
setInterval(x => {
16+
setInterval(() => {
1717
bot.editText(
1818
{chatId, messageId}, `<b>Current time:</b> ${ time() }`,
1919
{parse: 'html'}

examples/ngrok-webhook.js

-1
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,3 @@ ngrok.connect(port, (error, url) => {
1818
bot.start();
1919

2020
});
21-

examples/plugin-reporter.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@ const bot = new TeleBot({
1414
});
1515

1616
// Make an error
17-
bot.on('/error', x => ___REPORT_ERROR_TEST___);
17+
bot.on('/error', (msg) => msg.MAKE_AN_ERROR);
1818

1919
// Stop with message
20-
bot.on('/stop', x => bot.stop('bye!'));
20+
bot.on('/stop', () => bot.stop('bye!'));
2121

2222
bot.start();

examples/webhook.js

-1
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,3 @@ const bot = new TeleBot({
1515
bot.on('text', msg => bot.sendMessage(msg.from.id, msg.text));
1616

1717
bot.start();
18-

lib/telebot.js

+7-7
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ class TeleBot {
147147
this.event('start');
148148

149149
// Global loop function
150-
this.loopFn = setInterval(x => {
150+
this.loopFn = setInterval(() => {
151151

152152
// Stop on false looping flag
153153
if (!f.looping) clearInterval(this.loopFn);
@@ -158,7 +158,7 @@ class TeleBot {
158158
f.poll = false;
159159

160160
// Get updates
161-
this.getUpdates().then(x => {
161+
this.getUpdates().then(() => {
162162

163163
// Retry connecting
164164
if (f.retry) {
@@ -178,7 +178,7 @@ class TeleBot {
178178
// Tick
179179
return this.event('tick');
180180

181-
}).then(x => {
181+
}).then(() => {
182182

183183
// Seems okay for the next poll
184184
f.poll = true;
@@ -193,14 +193,14 @@ class TeleBot {
193193

194194
return Promise.reject();
195195

196-
}).catch(x => {
196+
}).catch(() => {
197197

198198
const seconds = this.retryTimeout / 1000;
199199
console.log(`[bot.info.update] reconnecting in ${ seconds } seconds...`);
200200
this.event('reconnecting');
201201

202202
// Set reconnecting timeout
203-
setTimeout(x => (f.poll = true), this.retryTimeout);
203+
setTimeout(() => (f.poll = true), this.retryTimeout);
204204

205205
});
206206

@@ -269,7 +269,7 @@ class TeleBot {
269269
props = mod.props;
270270

271271
// Process update
272-
promise = promise.then(x => this.processUpdate(update, props));
272+
promise = promise.then(() => this.processUpdate(update, props));
273273

274274
}
275275

@@ -426,7 +426,7 @@ class TeleBot {
426426
let that = this;
427427

428428
details.remove = (function (fn) {
429-
return x => that.removeEvent(type, fn);
429+
return () => that.removeEvent(type, fn);
430430
}(fn));
431431

432432
fn = fn.call(self, data, self, details);

lib/webhook.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ module.exports = (bot, opt) => {
1919
http.createServer(listener);
2020

2121
// Start server
22-
server.listen(port, host, x => {
22+
server.listen(port, host, () => {
2323
console.log(`[bot.webhook] started${ key ? ' secure' : ''} server on "${ host }:${ port }"`);
2424
});
2525

plugins/commandButton.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -50,4 +50,4 @@ module.exports = {
5050

5151
}
5252

53-
};
53+
};

plugins/namedButtons.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ module.exports = {
1717
plugin(bot, cfg) {
1818

1919
const buttons = cfg.buttons || {};
20-
20+
2121
bot.on('text', (msg, props) => {
2222
const text = msg.text;
2323
for (let buttonId in buttons) {

plugins/regExpMessage.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,4 +30,4 @@ module.exports = {
3030

3131
}
3232

33-
};
33+
};

plugins/shortReply.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -70,4 +70,4 @@ module.exports = {
7070

7171
}
7272

73-
};
73+
};

test/index.js

+5-5
Original file line numberDiff line numberDiff line change
@@ -66,20 +66,20 @@ test('events', t => {
6666
return bot.eventList.size;
6767
}
6868

69-
var delMe = x => {
69+
var delMe = () => {
7070
};
7171

7272
t.is(count(), 2);
7373

7474
// Set
75-
bot.on('start', x => {
75+
bot.on('start', () => {
7676
});
7777
bot.on('start', delMe);
78-
bot.on('custom', x => {
78+
bot.on('custom', () => {
7979
});
80-
bot.on('custom', x => {
80+
bot.on('custom', () => {
8181
});
82-
bot.on('custom', x => {
82+
bot.on('custom', () => {
8383
});
8484

8585
// Count

0 commit comments

Comments
 (0)