Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 5 additions & 6 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
{
"plugins": [
"transform-strict-mode",
"transform-object-rest-spread",
"transform-class-properties"
],
"presets": [
"babel-preset-es2015"
["@babel/preset-env", {
"targets": {
"node": "0.12"
}
}]
]
}
2 changes: 0 additions & 2 deletions .eslintignore

This file was deleted.

4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
node_modules
.nyc_output/
coverage/
npm-debug.log
.package.json
Expand All @@ -7,4 +8,5 @@ output.md
output/
lib/
lib-doc/
.DS_Store
.DS_Store
.env
76 changes: 76 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
import js from '@eslint/js';
import babelParser from '@babel/eslint-parser';
import mochaPlugin from 'eslint-plugin-mocha';

export default [
{
ignores: ['node_modules/**', 'lib/**', 'bin/**', '*.md']
},
{
files: ['**/*.js'],
languageOptions: {
parser: babelParser,
parserOptions: {
requireConfigFile: false,
babelOptions: {
presets: ['@babel/preset-env']
}
},
globals: {
console: 'readonly',
process: 'readonly',
Buffer: 'readonly',
__dirname: 'readonly',
__filename: 'readonly',
require: 'readonly',
module: 'readonly',
exports: 'readonly',
global: 'readonly',
setImmediate: 'readonly',
clearImmediate: 'readonly',
setInterval: 'readonly',
clearInterval: 'readonly',
setTimeout: 'readonly',
clearTimeout: 'readonly'
}
},
rules: {
...js.configs.recommended.rules,
'new-cap': 0,
'prefer-arrow-callback': 0,
'no-param-reassign': [2, { props: false }],
'max-len': [2, 200],
'arrow-body-style': 0,
'comma-dangle': 0,
'indent': ['error', 2],
'no-console': 0,
'func-names': 0,
'object-shorthand': 0,
'no-use-before-define': 0,
'no-underscore-dangle': 0
}
},
{
files: ['test/**/*.js'],
languageOptions: {
globals: {
describe: 'readonly',
it: 'readonly',
before: 'readonly',
after: 'readonly',
beforeEach: 'readonly',
afterEach: 'readonly'
}
},
plugins: {
mocha: mochaPlugin
},
rules: {
'mocha/no-top-level-hooks': 0,
'mocha/consistent-spacing-between-blocks': 0,
'mocha/no-setup-in-describe': 0,
'mocha/max-top-level-suites': 0,
'mocha/no-pending-tests': 0
}
}
];
2 changes: 1 addition & 1 deletion examples/game/game.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* This example demonstrates using HTML5 games with Telegram.
*/
/* eslint-disable no-console */

const TOKEN = process.env.TELEGRAM_TOKEN || 'YOUR_TELEGRAM_BOT_TOKEN';
const gameName = process.env.TELEGRAM_GAMENAME || 'YOUR_TELEGRAM_GAMENAME';
Expand Down
13 changes: 9 additions & 4 deletions examples/polling.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

const TOKEN = process.env.TELEGRAM_TOKEN || 'YOUR_TELEGRAM_BOT_TOKEN';
const TelegramBot = require('..');
const request = require('@cypress/request');
const fetch = require('node-fetch');
const options = {
polling: true
};
Expand All @@ -25,10 +25,15 @@ bot.onText(/\/photo/, function onPhotoText(msg) {

// Matches /audio
bot.onText(/\/audio/, function onAudioText(msg) {
// From HTTP request
// From HTTP request - convert response to stream
const url = 'https://upload.wikimedia.org/wikipedia/commons/c/c8/Example.ogg';
const audio = request(url);
bot.sendAudio(msg.chat.id, audio);
fetch(url)
.then(response => {
bot.sendAudio(msg.chat.id, response.body);
})
.catch(err => {
console.error('Error fetching audio:', err);
});
});


Expand Down
2 changes: 1 addition & 1 deletion examples/webhook/express.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* This example demonstrates setting up a webook, and receiving
* updates in your express app
*/
/* eslint-disable no-console */

const TOKEN = process.env.TELEGRAM_TOKEN || 'YOUR_TELEGRAM_BOT_TOKEN';
const url = 'https://<PUBLIC-URL>';
Expand Down
2 changes: 1 addition & 1 deletion examples/webhook/now.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const options = {
// domain.
// See: https://zeit.co/blog/now-alias
// Or just use NOW_URL to get deployment url from env.
const url = 'YOUR_DOMAIN_ALIAS' || process.env.NOW_URL;
const url = process.env.NOW_URL || 'YOUR_DOMAIN_ALIAS';
const bot = new TelegramBot(TOKEN, options);


Expand Down
49 changes: 20 additions & 29 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,47 +21,38 @@
"eslint": "eslint ./src ./test ./examples",
"mocha": "mocha",
"pretest": "npm run build",
"test": "npm run eslint && istanbul cover ./node_modules/mocha/bin/_mocha"
"test": "npm run eslint && nyc mocha"
},
"author": "Yago Pérez <yagoperezs@gmail.com>",
"license": "MIT",
"engines": {
"node": ">=0.12"
},
"dependencies": {
"@cypress/request": "^3.0.10",
"@cypress/request-promise": "^5.0.0",
"array.prototype.findindex": "^2.2.4",
"bl": "^1.2.3",
"debug": "^3.2.7",
"eventemitter3": "^3.0.0",
"file-type": "^3.9.0",
"mime": "^1.6.0",
"pump": "^2.0.0"
"bl": "^6.1.6",
"debug": "^4.4.3",
"eventemitter3": "^5.0.4",
"file-type": "^12.4.2",
"form-data": "^4.0.5",
"mime": "^4.1.0",
"node-fetch": "^2.6.12",
"pump": "^3.0.4"
},
"devDependencies": {
"babel-cli": "^6.26.0",
"babel-eslint": "^8.0.3",
"babel-plugin-transform-class-properties": "^6.24.1",
"babel-plugin-transform-es2015-destructuring": "^6.23.0",
"babel-plugin-transform-es2015-parameters": "^6.24.1",
"babel-plugin-transform-es2015-shorthand-properties": "^6.24.1",
"babel-plugin-transform-es2015-spread": "^6.22.0",
"babel-plugin-transform-object-rest-spread": "^6.26.0",
"babel-plugin-transform-strict-mode": "^6.24.1",
"babel-preset-es2015": "^6.24.1",
"babel-register": "^6.26.0",
"concat-stream": "^1.6.0",
"eslint": "^2.13.1",
"eslint-config-airbnb": "^6.2.0",
"eslint-plugin-mocha": "^4.11.0",
"is": "^3.2.1",
"is-ci": "^1.0.10",
"istanbul": "^1.1.0-alpha.1",
"@babel/cli": "^7.23.0",
"@babel/core": "^7.23.0",
"@babel/eslint-parser": "^7.23.0",
"@babel/preset-env": "^7.23.0",
"concat-stream": "^2.0.0",
"eslint": "^9.0.0",
"eslint-plugin-mocha": "^11.2.0",
"is": "^3.3.2",
"is-ci": "^4.1.0",
"jsdoc-to-markdown": "^9.1.3",
"mocha": "^3.5.3",
"mocha": "^12.0.0-beta-10",
"mocha-lcov-reporter": "^1.3.0",
"node-static": "^0.7.10"
"nyc": "^15.1.0"
},
"repository": {
"type": "git",
Expand Down
Loading