35 lines
940 B
Text
35 lines
940 B
Text
|
matrixserver="<matrix domain>"
|
||
|
|
||
|
generate_post_data()
|
||
|
{
|
||
|
cat <<EOF
|
||
|
{
|
||
|
"user_id":"@$D:$matrixserver"
|
||
|
}
|
||
|
EOF
|
||
|
}
|
||
|
|
||
|
roomID=( 'room_ID1' 'zroom_ID2' 'room_ID3' )
|
||
|
errcode="M_LIMIT_EXCEEDED"
|
||
|
for rm_id in ${roomID[*]}
|
||
|
do
|
||
|
while read A B C D E
|
||
|
do
|
||
|
echo $rm_id
|
||
|
res2=""
|
||
|
res=$(curl -XPOST -d "$(generate_post_data)" "http://localhost:8008/_matrix/client/r0/rooms/%21$rm_id%3A<matrix domain>/invite?access_token=<ACCESS_TOKEN>")
|
||
|
echo $res
|
||
|
#avoid error { "errcode": "M_LIMIT_EXCEEDED", "error": "Too Many Requests", "retry_after_ms": 2895 }
|
||
|
if [[ $res =~ $errcode ]];then
|
||
|
sleep 5
|
||
|
res2=$(curl -XPOST -d "$(generate_post_data)" "http://localhost:8008/_matrix/client/r0/rooms/%21$rm_id%3A<matrix domain>/invite?access_token=<ACCESS_TOKEN>")
|
||
|
fi
|
||
|
|
||
|
if [[ $res2 =~ $errcode ]];then
|
||
|
echo "===error==="
|
||
|
echo $res2
|
||
|
exit 1
|
||
|
fi
|
||
|
sleep 1
|
||
|
done < info.txt
|
||
|
done
|