电报机器人意外结束

时间:2019-01-06 10:18:00

标签: javascript node.js telegram-bot http-proxy

在所有示例和说明中,尝试使我的第一个电报机器人看起来非常简单且易于重复。但是,我的机器人根本无法工作。首先,我来自俄罗斯,而电报api被阻止,因此我需要使用代理。从https://www.socks-proxy.net/中拿了一个。从BotFather获得了代币。现在,当我运行脚本telegraf.js时:

const Telegraf = require('telegraf');
const SocksAgent = require('socks5-https-client/lib/Agent');
const socksAgent = new SocksAgent({
   socksHost: '103.206.97.70',
   socksPort: 4145,
});
const bot = new Telegraf(MY_TOKEN, {
telegram: {
    agent: socksAgent,
}
});
bot.hears('hi', ctx => {
   return ctx.reply('Hey!');
});
bot.startPolling();

什么也没有发生,并且程序已完成enter image description here

enter image description here

我知道问题出在我的代理配置中,但无法理解到底是什么问题。

1 个答案:

答案 0 :(得分:0)

问题出在代理服务器上。我用#placeholder for list of filenames filenames = tf.placeholder(tf.string) # Using tf.data.Dataset to iterate through list filenames dataset = tf.data.Dataset.from_tensor_slices(filenames) # for each filename, open it. dataset = dataset.map( lambda filename: ( tf.io.read_file(filename))) # make iterator (standard practice) itr = dataset.make_initializable_iterator() #used to feed new filenames into dataset init = itr.initializer # get the item from iterator image_raw_data = itr.get_next() # same as your code image = tf.image.decode_jpeg(image_raw_data) with tf.Session() as sess: # initialize the dataset sess.run(init,{filenames:['test_images/demo_images/image1.jpg', 'test_images/demo_images/image2.jpg']}) img1 = sess.run(image) img2 = sess.run(image) # lets display the images from PIL import Image image = Image.fromarray(img1,'RGB') image.show() image = Image.fromarray(img2,'RGB') image.show() 代替了https-proxy-agent

socks5-https-client