加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > Linux > 正文

linux – Telegram-cli:脚本不发送消息

发布时间:2020-12-13 23:54:02 所属栏目:Linux 来源:网络整理
导读:我正在使用Telegram-cli创建一个简单的bash脚本,我在其中发送2个参数(目标和消息),它应该向目的地发送Telegram消息(Name_FamilyName). 该脚本如下所示: #!/bin/bashdestination=$1;message=$2; (echo "msg $destination $message"; echo "safe_quit") | bin
我正在使用Telegram-cli创建一个简单的bash脚本,我在其中发送2个参数(目标和消息),它应该向目的地发送Telegram消息(Name_FamilyName).

该脚本如下所示:

#!/bin/bash
destination=$1;
message=$2;
  (echo "msg $destination $message"; echo "safe_quit") | bin/telegram-cli -k tg-server.pub -W

有了这个,理论上应该发送消息.我更改了脚本的权限,我以下一种方式调用它:

./script_send_message.sh Max_Musterman "Hola qute tal estas"

这就是我得到的输出:

Telegram-cli version 1.2.0,Copyright (C) 2013-2015 Vitaly Valtman
Telegram-cli comes with ABSOLUTELY NO WARRANTY; for details type `show_license'.
This is free software,and you are welcome to redistribute it
under certain conditions; type `show_license' for details.
Telegram-cli uses libtgl version 1.2.0
I: config dir=[/home/machine/.telegram-cli]
> msg Max_Musterman Hola qute tal estas
> safe_quit
User Max_Musterman updated username
User Max_Musterman online (was online [2015/04/09 06:56:04])
User Test Phone offline (was online [2015/04/09 06:51:42])
> > All done. Exit
halt

根本没有发送任何消息. Insted,如果我从控制台发送完全相同的消息,它工作正常.这是我做的:

bin/telegram-cli -k server.pub -W
Telegram-cli version 1.2.0,and you are welcome to redistribute it
under certain conditions; type `show_license' for details.
Telegram-cli uses libtgl version 1.2.0
I: config dir=[/home/machine/.telegram-cli]
User Max_Musterman updated username
User Max_Musterman online (was online [2015/04/09 06:59:46])
User Max_Musterman offline (was online [2015/04/09 06:51:42])
> msg Max_Musterman Hola qute tal estas
[06:57]  Max_Musterman <<< Hola qute tal estas
User Max_Musterman marked read 1 outbox and 0 inbox messages
User Max_Musterman offline (was online [2015/04/09 06:57:29])
>

我的想法已经不多了.我开始认为,在脚本中发送命令msg时,不会加载联系人列表,所以它什么都不发送(在控制台中,如果你向一个组成的用户发送消息,它就不会做任何事情喜欢在剧本中).

有没有人经历类似的事情?有解决方案吗谢谢您的帮助.

解决方法

你还有其他选择:

而不是管道命令到telegram-cli你可以使用“-e”选项和user_id,这样:

telegram-cli -RD -e "msg user#nnnnnnn Hola caracola"

其中nnnnn是user_id.您可以通过“user_info …..”命令找到它.

这样你就不需要睡觉,只需让telegram-cli完成所有工作,而不使用-W命令,电报不需要获取所有联系人.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读