如何编写脚本以通过电报 cli 发送消息?

Lui*_*ali 3 command-line bash scripts schedule telegram

我不知道如何解释自己,但我需要通过电报发送预定的消息,所以我下载了电报客户端以通过终端发送消息。我写了一个打开客户端的 bash 脚本,这里的一切都按计划进行,然后它打开电报命令行,我的脚本没有相应地运行。我怎样才能工作?

这是电报命令行

这是脚本,没什么难的:

#!/bin/bash
cd /home/ospite/tg
bin/telegram-cli -k tg-server.pub //opening telegram client
sleep 30
chat_with_peer Antonio //it doesn't work because it's not the debian shell anymore
done
Run Code Online (Sandbox Code Playgroud)

M. *_*rra 6

要编写脚本以通过电报 cli 发送消息,您需要执行以下操作:

  1. 移动到telegram-cli所在的目录:

  2. 用你的钥匙打开电报cli

  3. 加载您的联系人列表 -W

  4. 将消息发送给之前加载的联系人列表中的任何人

为了实现这一点:

cd /path/to/tg && bin/telegram-cli -W server.pub -e "msg contact message"
Run Code Online (Sandbox Code Playgroud)

或者

cd /path/to/tg && (sleep 1; echo "contact_list"; sleep 1; echo "msg contact message") | bin/telegram-cli -W -k server.pub
Run Code Online (Sandbox Code Playgroud)

更多信息在这里:https : //github.com/vysheng/tg