max hai 5 meses
achega
dbbdc100cf
Modificáronse 3 ficheiros con 57 adicións e 0 borrados
  1. 2 0
      .gitignore
  2. 37 0
      app.js
  3. 18 0
      package.json

+ 2 - 0
.gitignore

@@ -0,0 +1,2 @@
+node_modules
+yarn.lock

+ 37 - 0
app.js

@@ -0,0 +1,37 @@
+const TelegramBot = require("node-telegram-bot-api");
+
+// replace the value below with the Telegram token you receive from @BotFather
+const TOKEN = "AAHk_qlAnVQX2xjUUUFMnKzSuX3knHOidYY";
+
+/* 
+Use this token to access the HTTP API:
+7542722102:AAHk_qlAnVQX2xjUUUFMnKzSuX3knHOidYY
+
+*/
+// Create a bot that uses 'polling' to fetch new updates
+// const bot = new TelegramBot(token, { polling: true });
+
+const options = {
+  webHook: {
+    // Just use 443 directly
+    port: 443,
+  },
+};
+
+// You can use 'now alias <your deployment url> <custom url>' to assign fixed
+// domain.
+// See: https://zeit.co/blog/now-alias
+// Or just use NOW_URL to get deployment url from env.
+const url = 'https://bot.10adyp.top/webHook' || process.env.NOW_URL;
+const bot = new TelegramBot(TOKEN, options);
+
+
+// This informs the Telegram servers of the new webhook.
+// Note: we do not need to pass in the cert, as it already provided
+bot.setWebHook(`${url}/bot${TOKEN}`);
+
+
+// Just to ping!
+bot.on('message', function onMessage(msg) {
+  bot.sendMessage(msg.chat.id, 'I am alive on Zeit Now!');
+});

+ 18 - 0
package.json

@@ -0,0 +1,18 @@
+{
+  "name": "tg_bot",
+  "version": "1.0.0",
+  "description": "",
+  "main": "app.js",
+  "scripts": {
+    "test": "echo \"Error: no test specified\" && exit 1"
+  },
+  "keywords": [],
+  "author": "",
+  "license": "ISC",
+  "volta": {
+    "node": "22.12.0"
+  },
+  "dependencies": {
+    "node-telegram-bot-api": "^0.66.0"
+  }
+}