我正在使用 Telegram-cli 制作一个简单的 bash 脚本,在其中我发送 2 个参数(目标和消息),它应该向目标(Name_FamilyName)发送一条 Telegram 消息。
该脚本如下所示:
#!/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, 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]
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 时未加载联系人列表,因此它什么也不发送(在控制台中,如果您向虚构的用户发送消息,它不会做任何事情就像在脚本中一样)。
有没有人经历过类似的事情?有什么解决办法吗?感谢您的帮助。