Pogo Bot

node v10.24.1
version: 0.0.3
endpointsharetweet
https://stackoverflow.com/questions/65814918/cant-create-telegram-bot-using-telegraf-package <= Helped to make telegraf works
const {Telegraf} = require("telegraf-ts") const Koa = require("koa"); const koaBody = require("koa-body"); const bot = new Telegraf(process.env.BOT_TOKEN); bot.on('text',({ reply }) => reply('The time here is ::' + new Date()) ); bot.telegram.setWebhook(''); const app = new Koa(); app.use(koaBody()); app.use((ctx,next) => ctx.method == 'POST' || ctx.url === '/secret-path' ? bot.handleUpdate(ctx.request.body, ctx.response) : next() ); // app.use(async ctx =>{ // ctx.body = "ciao mondo koa"; // }); // console.log('telegram bot start 🆙'); app.listen(3000);
It's call the api's pokemon and receive the list of all pokemon
var Pokedex = require('pokedex-promise-v2'); var P = new Pokedex(); P.getPokemonByName("eevee") .then(function(response) { console.log(response); }) .catch(function(error) { console.log('There was an ERROR: ', error); }); var listPokemon = null; P.getPokemonsList() .then(function(response) { listpokemon = response; console.log(listpokemon); }) .catch(function(error) { console.log('There was an ERROR: ', error); }); P.getPokemonByName(34, function(response, error) { // with callback if(!error) { console.log(response); } else { console.log(error) } });
Check if the methods are called in the right way --> https://core.telegram.org/bots/api#message https://duckduckgo.com/?q=node+js+how+use+telegraf&ia=web&iai=r1-0&page=1&sexp=%7B%22cdrexp%22%3A%22b%22%2C%22artexp%22%3A%22b%22%2C%22prodexp%22%3A%22b%22%2C%22prdsdexp%22%3A%22c%22%2C%22biaexp%22%3A%22b%22%2C%22msvrtexp%22%3A%22b%22%7D
Loading…

no comments

    sign in to comment