~脚本拆分后bug修复
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
#!/bin/sh
|
||||
# Copyright (C) Juewuy
|
||||
#工具脚本
|
||||
|
||||
#工具与优化
|
||||
tools() {
|
||||
ssh_tools() {
|
||||
@@ -250,51 +250,8 @@ log_pusher() {
|
||||
}
|
||||
else
|
||||
#echo -e "\033[33m详细设置指南请参考 https://juewuy.github.io/ \033[0m"
|
||||
private_bot() {
|
||||
echo -e "请先通过 \033[32;4mhttps://t.me/BotFather\033[0m 申请TG机器人并获取其\033[36mAPI TOKEN\033[0m"
|
||||
echo "-----------------------------------------------"
|
||||
read -p "请输入你获取到的API TOKEN > " TOKEN
|
||||
echo "-----------------------------------------------"
|
||||
echo -e "请向\033[32m你申请的机器人\033[33m而不是BotFather!\033[0m"
|
||||
url_tg=https://api.telegram.org/bot${TOKEN}/getUpdates
|
||||
}
|
||||
public_bot() {
|
||||
echo -e "请向机器人:\033[32;4mhttps://t.me/ShellCrashtg_bot\033[0m"
|
||||
TOKEN=publictoken
|
||||
url_tg=https://tgbot.jwsc.eu.org/publictoken/getUpdates
|
||||
}
|
||||
set_bot() {
|
||||
echo -e "发送此秘钥: \033[30;46m$public_key\033[0m"
|
||||
echo "-----------------------------------------------"
|
||||
read -p "我已经发送完成(1/0) > " res
|
||||
if [ "$res" = 1 ]; then
|
||||
[ -n "$authentication" ] && auth="$authentication@"
|
||||
export https_proxy="http://${auth}127.0.0.1:$mix_port"
|
||||
if curl --version >/dev/null 2>&1; then
|
||||
chat=$(curl -kfsSl $url_tg 2>/dev/null)
|
||||
else
|
||||
chat=$(wget -Y on -q -O - $url_tg)
|
||||
fi
|
||||
[ -n "$chat" ] && chat_ID=$(echo $chat | sed 's/"update_id":/{\n"update_id":/g' | grep "$public_key" | head -n1 | grep -oE '"id":.*,"is_bot' | sed s'/"id"://' | sed s'/,"is_bot//')
|
||||
[ -z "$chat_ID" ] && [ "$TOKEN" != 'publictoken' ] && {
|
||||
echo -e "\033[31m无法获取对话ID,请返回重新设置或手动输入ChatID!\033[0m"
|
||||
echo -e "通常访问 \033[32;4m$url_tg\033[0m \n\033[36m即可看到ChatID\033[0m"
|
||||
read -p "请手动输入ChatID > " chat_ID
|
||||
}
|
||||
if echo "$chat_ID" | grep -qE '^[0-9]{8,}$'; then
|
||||
push_TG=$TOKEN
|
||||
setconfig push_TG $TOKEN
|
||||
setconfig chat_ID $chat_ID
|
||||
"$CRASHDIR"/start.sh logger "已完成Telegram日志推送设置!" 32
|
||||
else
|
||||
echo -e "\033[31m无法获取对话ID,请重新配置!\033[0m"
|
||||
sleep 1
|
||||
chose_bot
|
||||
fi
|
||||
fi
|
||||
}
|
||||
. "$CRASHDIR"/menus/bot_tg_bind.sh
|
||||
chose_bot() {
|
||||
public_key=$(cat /proc/sys/kernel/random/boot_id | sed 's/.*-//')
|
||||
echo "-----------------------------------------------"
|
||||
echo -e " 1 使用公共机器人 ——不依赖内核服务"
|
||||
echo -e " 2 使用私人机器人 ——需要额外申请"
|
||||
@@ -303,11 +260,11 @@ log_pusher() {
|
||||
case $num in
|
||||
1)
|
||||
public_bot
|
||||
set_bot
|
||||
set_bot && tg_push_token || chose_bot
|
||||
;;
|
||||
2)
|
||||
private_bot
|
||||
set_bot
|
||||
set_bot && tg_push_token || chose_bot
|
||||
;;
|
||||
*)
|
||||
errornum
|
||||
|
||||
Reference in New Issue
Block a user