Skip to content

Commit

Permalink
improve
Browse files Browse the repository at this point in the history
  • Loading branch information
gfhdhytghd committed Sep 15, 2024
1 parent 07df889 commit 4e5da8a
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 4 deletions.
5 changes: 4 additions & 1 deletion getmsgserv/serv.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,10 @@ def handle_request(self):
except json.JSONDecodeError:
self.send_error(400, 'Invalid JSON')
return

if data.get('message_type') == 'private' and 'raw_message' in data and '[自动回复&#93' in data['raw_message']:
# 忽略此消息
print("收到自动回复消息,已忽略。")
return
# 处理不同类型的通知
if data.get('notice_type') == 'friend_recall':
self.handle_friend_recall(data)
Expand Down
46 changes: 43 additions & 3 deletions qqBot/startd.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,46 @@ LLonebot=$(grep 'use_LLOnebot' oqqwall.config | cut -d'=' -f2 | tr -d '"')
#mainqqid=$(grep 'mainqq-id' oqqwall.config | cut -d'=' -f2 | tr -d '"')
json_content=$(cat ./AcountGroupcfg.json)
runidlist=($(echo "$json_content" | jq -r '.[] | .mainqqid, .minorqqid[]'))


getinfo(input_id){
json_file="./AcountGroupcfg.json"
# 检查输入是否为空
if [ -z "$input_id" ]; then
echo "请提供mainqqid或minorqqid。"
exit 1
fi
# 使用 jq 查找输入ID所属的组信息
group_info=$(jq -r --arg id "$input_id" '
to_entries[] | select(.value.mainqqid == $id or (.value.minorqqid[]? == $id))
' "$json_file")
# 检查是否找到了匹配的组
if [ -z "$group_info" ]; then
echo "未找到ID为 $input_id 的相关信息。"
exit 1
fi
# 提取各项信息并存入变量
groupname=$(echo "$group_info" | jq -r '.key')
groupid=$(echo "$group_info" | jq -r '.value.mangroupid')
mainqqid=$(echo "$group_info" | jq -r '.value.mainqqid')
minorqqid=$(echo "$group_info" | jq -r '.value.minorqqid[]')
mainqq_http_port=$(echo "$group_info" | jq -r '.value.mainqq_http_port')
minorqq_http_ports=$(echo "$group_info" | jq -r '.value.minorqq_http_port[]')
# 初始化端口变量
port=""
# 检查输入ID是否为mainqqid
if [ "$input_id" == "$mainqqid" ]; then
port=$mainqq_http_port
else
# 遍历 minorqqid 数组并找到对应的端口
i=0
for minorqqid in $minorqqid; do
if [ "$input_id" == "$minorqqid" ]; then
port=$(echo "$minorqq_http_ports" | sed -n "$((i+1))p")
break
fi
((i++))
done
fi
}
if pgrep -f "python3 ./getmsgserv/serv.py" > /dev/null
then
echo "serv.py is already running"
Expand Down Expand Up @@ -60,8 +98,10 @@ while true; do
source ./venv/bin/activate
# 运行 Python 脚本
for qqid in "${runidlist[@]}"; do

echo "Like everyone with ID: $qqid"
python3 ./qqBot/likeeveryday.py $qqid
getinfo $qqid
python3 ./qqBot/likeeveryday.py $port
done
fi
pgrep -f "python3 ./getmsgserv/serv.py" | xargs kill -15
Expand Down

0 comments on commit 4e5da8a

Please sign in to comment.