标签: telegraf

Telegram Bot与Telegraf.js-发送消息进行聊天

我想用Node.js创建一个Telegram Bot,并且正在使用Telegraf。我知道我可以回答这样的消息:

app.hears('hi', (ctx) => ctx.reply('Hey there!'))
Run Code Online (Sandbox Code Playgroud)

但是,如何在没有收到消息的情况下发送消息?我想读取文件,并且总是在文件更改后才想发送消息。

const Telegraf = require('telegraf');
var fs = require('fs');

const app = new Telegraf(process.env.BOT_TOKEN);

var filePath = "C:\\path\\to\\my\\file.txt";

fs.watchFile(filePath, function() {
    file = fs.readFileSync(filePath);

    // Send message to chat or group with the file content here

    console.log("File content at: " + new Date() + " is: \n" + file);
})
Run Code Online (Sandbox Code Playgroud)

如果有人可以帮助我会很好。

node.js telegram telegram-bot telegraf

6
推荐指数
1
解决办法
6080
查看次数

如何设置telegraf statsd(Influxdb)的时间精度?

我使用的是telegrafinfluxdb,并且在telegraf我使用statsd_input插件.

statsd_input.conf:

[[inputs.statsd]]
  ## Address and port to host UDP listener on
  service_address = ":8126"

  ## The following configuration options control when telegraf clears it's cache
  ## of previous values. If set to false, then telegraf will only clear it's
  ## cache when the daemon is restarted.
  ## Reset gauges every interval (default=true)
  delete_gauges = true
  ## Reset counters every interval (default=true)
  delete_counters = true
  ## Reset sets every interval (default=true)
  delete_sets …
Run Code Online (Sandbox Code Playgroud)

statsd influxdb telegraf

6
推荐指数
1
解决办法
328
查看次数

Stage.enter无法启动向导

我创建了一个向用户显示调查向导的应用程序。当用户启动/ start命令时,我将调用AddProject

const Telegraf = require('telegraf');
const bot = new Telegraf(process.env.BOT_TOKEN);
const session = require('telegraf/session');
bot.use(session());

const main = new TelegrafInlineMenu("Welcome.");
main.setCommand('start');
main.simpleButton('Start Survey', 'START_SURVEY', {
  doFunc: async ctx => surveyController.AddProject(ctx, bot)
});
Run Code Online (Sandbox Code Playgroud)

基本上,以上代码创建了一个菜单,其中显示了标签Welcome(欢迎)和一个按钮以启动调查。当用户单击按钮时,从SurveyController调用方法AddProject:

const Composer = require('telegraf/composer');
const stepHandler = new Composer();
const Stage = require('telegraf/stage');
const WizardScene = require('telegraf/scenes/wizard');
const userController = require('../controllers/user.controller');

module.exports = {

  AddProject: async function (ctx, bot) {

    const superWizard = new WizardScene('super-wizard',
      (ctx) => {
        ctx.reply('Step 1', Markup.inlineKeyboard([
          Markup.urlButton('??', 'http://telegraf.js.org'),
          Markup.callbackButton('?? …
Run Code Online (Sandbox Code Playgroud)

javascript node.js telegram telegram-bot telegraf

6
推荐指数
1
解决办法
603
查看次数

telegraf 是否可以在网络中断期间将指标数据存储在本地系统上并在稍后转发?

我们拥有的物联网设备大多与互联网连接良好,但网络也有可能出现故障。对于这种情况,设备本身会做正确的事情(虽然它不能再被主动控制)。我们仍然希望获得网络中断期间的指标数据。

这意味着设备本地电报需要收集指标数据、存储数据并检查网络连接。如果网络(再次)启动,则转发到例如 influxDB。

用Telegraf/InfluxDB或者prometheus可以实现这个场景吗?

telegraf

5
推荐指数
1
解决办法
2961
查看次数

Telegraf 文件计数值未显示在 influxdb 中

Telegraf 1.9.0,Influxdb 1.7.4。我正在使用 filecount 输入插件来计算两个目录中的文件数量。这是 telegraf 的相关测试输出:

    $ telegraf --config /etc/telegraf/telegraf.conf --test
    2019-04-08T19:41:42Z I! Starting Telegraf 1.9.0
    > filecount,directory=/var/lib/pgsql/9.6/data/pg_logical/snapshots,host=db02 count=113i 1554752503000000000
    > filecount,directory=/var/lib/pgsql/9.6/data/pg_xlog,host=db02 count=569i 1554752503000000000
Run Code Online (Sandbox Code Playgroud)

当我使用 Chronograf 查找 influxdb 中的值时,根本没有 filecount 条目。我怎样才能找出问题所在?

influxdb telegraf

5
推荐指数
1
解决办法
763
查看次数

如何使用 InlineKeyboardButton 应用“Markdown 样式进行回复”?

如何使用InlineKeyboardButton{ parse_mode: \'Markdown\' }申请回复?

\n\n
const Telegraf = require("telegraf");\nconst Extra = require("telegraf/extra");\nconst Markup = require("telegraf/markup");\n\nconst keyboard = Markup.inlineKeyboard([\n  Markup.urlButton("\xe2\x9d\xa4\xef\xb8\x8f", "http://telegraf.js.org"),\n  Markup.callbackButton("Delete", "delete")\n]);\n\nconst myReply = "Hello *mate*, __where are you ?__"\n\nbot.on("message", ctx =>\n  ctx.telegram.sendMessage(ctx.chat.id, myReply, Extra.markup(keyboard))\n);\n
Run Code Online (Sandbox Code Playgroud)\n\n

是否有任何选项可以使用 InlineKeyboardButton 为消息添加 markdown 样式?

\n

javascript bots node.js telegram-bot telegraf

5
推荐指数
1
解决办法
4673
查看次数

在容器中运行时重新加载 telegraf 配置的最佳方法

我正在 Synology NAS 上的容器中运行 telegraf。\n只是询问当我在 telegraf.conf 中进行一些更改时重新加载配置的最佳方式是什么。

\n\n

我在这里看到了重新启动整个容器的建议:\n https://hub.docker.com/_/telegraf

\n\n

像这样:

\n\n
$ docker restart telegraf\n
Run Code Online (Sandbox Code Playgroud)\n\n

对于容器内的 telegraf 进程,使用 SIGHUP 执行终止命令怎么样?

\n\n

像这样的东西:

\n\n
admin@Docker:~% sudo docker ps | grep telegraf\nPassword:\n4c69a263326d        telegraf:latest                       "/entrypoint.sh tele\xe2\x80\xa6"   3 weeks ago         Up 20 minutes                           telegraf\nadmin@Docker:~% sudo docker exec -it -u 0 4c69a263326d kill -1 1\nadmin@Docker:~% sudo docker ps | grep telegraf\n4c69a263326d        telegraf:latest                       "/entrypoint.sh tele\xe2\x80\xa6"   3 weeks ago         Up 21 minutes                           telegraf\nadmin@Docker:~% sudo docker logs --tail 10 4c69a263326d\n2020-06-09T11:50:37Z I! [agent] Hang on, flushing …
Run Code Online (Sandbox Code Playgroud)

configuration reload docker telegraf

5
推荐指数
1
解决办法
6634
查看次数

使用 InfluxDb 和 Telegraf for Grafana 时出现 Http TLS 握手错误

我使用 OpenSSL 工具生成了证书和密钥 (.crt和) 文件,并将生成的文件路径设置为文件中的这些文件。.keyinfluxdb.conf

当我运行 Telegraf 服务时,Influxd 会记录:

http: TLS handshake error from [::1]:63020: remote error: tls: bad certificate
Run Code Online (Sandbox Code Playgroud)

然后我打开我的telegraf.conf并将 URL 设置为 localhost,并使用该配置文件重新安装该服务。

然后,我使用正确的配置文件 ( influxdb.conf) 运行我的 Influx 恶魔,并将其连接到 Influxdb ,influx.exe没有出现任何问题。我可以正常查询我的数据,但如果我尝试从 Insomnia 或 Postman 发出请求,Influxd 会记录:

http: TLS handshake error from [::1]:63175: local error: tls: bad record MAC
Run Code Online (Sandbox Code Playgroud)

openssl influxdb grafana telegraf insomnia

5
推荐指数
0
解决办法
1602
查看次数

如何查看new_chat_members上的电报群邀请链接参数

我有一个电报机器人,它已添加到该组中,并且正在监听该组中发生的所有事情。实施了一个命令/invite,它显示组的邀请链接(不是机器人,而是组)。此链接包含参数refUserId,以便我稍后可以获取它并计算该组的特定成员邀请了多少人。这就是我想要实现的目标,但看起来无法检索new_chat_members事件上的邀请链接参数。

这是我想要检索参数的一段代码

bot.on('new_chat_members', ctx => {
    // retrieve refUserId param here
})
Run Code Online (Sandbox Code Playgroud)

我愿意接受任何建议,并且非常乐意听到其他解决方案。

这是更大的图片,以备需要时使用

const bot = new Telegraf(process.env.BOT_TOKEN)
bot.start((ctx) => ctx.reply(`${Constants.msg.welcome(ctx.from.first_name)}`))
bot.command('invite', ctx => {
    // reply with invitation link like this:
    // t.me/myGroupIdWillBeHere?refUserId=${ctx.from.id}
})
bot.on('new_chat_members', ctx => {
    // retrieve refUserId param here
})
bot.launch()
Run Code Online (Sandbox Code Playgroud)

bots node.js telegram telegraf

5
推荐指数
0
解决办法
1587
查看次数

如何将 InfluxDb 迁移到 Amazon Timestream?

我一直在尝试将我的 InfluxDb 迁移到 Amazon Timestream。由于它是一项新服务,我无法找到将 Influx 迁移到 Timestream 的确切文档。我发现 Telegraf 可用于将 InfluxDB 连接到 Timestream,但找不到太多有关迁移的信息。谁能分享一下迁移步骤吗?非常感谢任何文档。

database-migration amazon-web-services influxdb telegraf amazon-timestream

5
推荐指数
0
解决办法
684
查看次数