diff --git a/qqBot/likeeveryday.py b/qqBot/likeeveryday.py index 7ce71c2..1f1c3cd 100644 --- a/qqBot/likeeveryday.py +++ b/qqBot/likeeveryday.py @@ -1,12 +1,22 @@ import requests +import sys port = sys.argv[1] # 请求 URL -url = "http://127.0.0.1:port" +url = f"http://127.0.0.1:{port}" # 获取好友列表 response = requests.post(f"{url}/get_friend_list") friend_list = response.json() +data_list = friend_list['data'] + +# 确保列表长度超过 500,否则不会有足够的数据可选 +if len(data_list) > 500: + # 随机选出 500 个对象 + selected_friends = random.sample(data_list, 500) + # 更新 friend_list 数据为选出的 500 个 + friend_list['data'] = selected_friends + if friend_list["status"] == "ok" and friend_list["retcode"] == 0: for friend in friend_list["data"]: user_id = friend["user_id"] diff --git a/qqBot/startd.sh b/qqBot/startd.sh index 0f04ca1..902bf22 100755 --- a/qqBot/startd.sh +++ b/qqBot/startd.sh @@ -50,10 +50,13 @@ fi while true; do # 获取当前小时和分钟 current_time=$(date +"%H:%M") + echo $current_time current_M=$(date +"%M") - if [ "current_M" == "00" ];then + if [ "$current_M" == "00" ];then + echo 'reach :00' #检查是否为早上7点 if [ "$current_time" == "07:00" ]; then + echo 'reach 7:00' source ./venv/bin/activate # 运行 Python 脚本 for qqid in "${runidlist[@]}"; do