Skip to content
Snippets Groups Projects
Unverified Commit 1a2f7259 authored by Recolic Keghart's avatar Recolic Keghart
Browse files

answer bug fix. Reconstruct configurations. autosign added. rewrite readme

parent 187e2885
No related branches found
No related tags found
No related merge requests found
# micro-teaching-assistant-fucker
微助教工具箱
自动检测是否有老师在微助教发布了新的题 并在特殊情况下及时提醒答题
自动检测是否有老师在微助教发布了新的签到 并在特殊情况下及时提醒签到
自动检测是否有老师在微助教发布了新的签到 并延时自动签到
## Hard PreRequirements
Non-Windows OS. curl. bash. fish. awk. One mp3 player available on command line.
Non-Windows OS. curl. bash. fish. awk. grep. One mp3 player available on command line.
## Configuration
编辑config.fish,设置自动签到的经纬度和延时,设置你想使用的mp3播放器然后保存。
## Usage
打开微信 微助教 学生 答题/签到,在页面加载完成之前迅速按下右上角...,然后复制这个页面的url。
- 获得openid
运行你想要的daemon.sh 输入openid或含有openid的完整URL 它会每5秒检查一次并判断是否需要答题/签到。你也可以将openid直接写进daemon.sh
打开微信 微助教 学生 答题/签到,在*页面加载完成之前*迅速按下右上角的`...`,然后复制链接(copy url)
daemon.sh使用了notify-send,其他用户请根据自己的情况选择修改或删除气泡提醒。
- 自动签到
daemonx.sh默认使用mpg123/cvlc来播放mp3,其他播放器用户请根据自己情况进行修改。**请将电脑声音调大**
运行`./daemon.sh sign`并填写openid(或含有openid的url),它会监视你的所有课堂并自动签到。注意,如果有多个课堂同时发起签到请求,其行为是未定义的。
- 监视答题
运行`./daemon.sh ans`(或含有openid的url),它会监视你的所有课堂是否有答题。注意,如果有多个课堂同时发起答题,其行为是未定义的。
## Tips
根据经验,url一般会在约1080次请求后失效。这意味着,如果你只开一个脚本,5秒请求一次,它可以使用约90分钟。同时使用签到和答题监测时,时间会减半。
daemon.sh使用了notify-send,其他用户请根据自己的情况选择修改或删除气泡提醒。
daemonx.sh默认使用mpg123/cvlc来播放mp3,其他播放器用户请根据自己情况进行修改。**请将电脑声音调大**
根据经验,url一般会在约1080次请求后失效。这意味着,如果你只开一个脚本,5秒请求一次,它可以自动运行约90分钟。
# What mp3 player do you want? (Tip, you can write a wrapper here to set player to highest volume)
#set _audio_player="mpg123"
set _audio_player "cvlc --play-and-exit"
# Where should I signin ?
set _NorthLatitude "30.509604"
set _EastLongitude "114.41374"
# How many seconds should I sleep after every check ?
set _monitor_interval "5"
# How many seconds should I delay before autosign ?
set _autosign_delay "10"
......@@ -6,9 +6,6 @@
_openid=$(echo "$_openid" | sed 's/^.*openid=//g')
echo "Set openid to $_openid"
#_audio_player="mpg123"
_audio_player="cvlc --play-and-exit"
function _segfault_detected () {
echo "WARNING: segfault captured!"
while true; do
......@@ -27,12 +24,12 @@ fi
cd impl
if [[ $1 == sign ]]; then
_openid="$_openid" _audio_player="$_audio_player" ./daemon-signin.fish
_openid="$_openid" ./daemon-signin.fish
[[ $? == 127 ]] && exit 127
_segfault_detected
fi
if [[ $1 == ans ]]; then
_openid="$_openid" _audio_player="$_audio_player" ./daemon-answer.fish
_openid="$_openid" ./daemon-answer.fish
[[ $? == 127 ]] && exit 127
_segfault_detected
fi
......
File added
#!/usr/bin/fish
#Usage: fill _openid with openid from url of the page "学生->答题".
_url="https://www.teachermate.com.cn/wechat/wechat/guide/answer?openid=$_openid"
test -z $_openid; and echo 'openid is unset.' ; and exit 1
set _url "https://www.teachermate.com.cn/wechat/wechat/guide/answer?openid=$_openid"
source ../config.fish
function _check_and_warn
if _all_answered
......@@ -74,7 +77,7 @@ while true
else if test "$_status" = "OPENED"
_check_and_warn
end
sleep 5
sleep $_monitor_interval
end
#!/usr/bin/fish
_url="https://www.teachermate.com.cn/wechat/wechat/guide/signin?openid=$_openid"
test -z $_openid; and echo 'openid is unset.' ; and exit 1
set _url "https://www.teachermate.com.cn/wechat/wechat/guide/signin?openid=$_openid"
source ../config.fish
# Where should I signin ?
test -z $_NorthLatitude; and set _NorthLatitude "30.509604"
test -z $_EastLongitude; and set _EastLongitude "114.41374"
# How many seconds should I delay before autosign ?
test -z $_autosign_delay; and set _autosign_delay "10"
set tmpfl (mktemp)
set cookiefl (mktemp)
# Just to skip first sleep
rm $tmpfl
set signed_in false
function do_signin
if test $signed_in = true
return
end
echo "sleep for $_autosign_delay seconds..."
sleep $_autosign_delay
set _courseid (curl "$_url" -v 2>&1 | grep '^< Location: ' | sed 's/^.*course_id=//')
set _wx_csrf (grep 'Set-Cookie' $cookiefl | sed 's/^.*wx_csrf_cookie=//' | sed 's/;.*$//')
curl "https://www.teachermate.com.cn/wechat-api/v1/class-attendance/student-sign-in" --data "openid=$_openid&course_id=$_courseid&lon=$_EastLongitude&lat=$_NorthLatitude&wx_csrf_name=$_wx_csrf" > $cookiefl
grep -F 'repeat sign in' $cookiefl; and set signed_in true; and return
grep -F '":["OK",' $cookiefl; and set signed_in true; and eval $_audio_player autosignin-success.mp3; or eval $_audio_player signin.mp3
end
while true
test -f $tmpfl; and sleep 5
test -f $tmpfl; and sleep $_monitor_interval
date
curl -L "$_url" 2>/dev/null > $tmpfl
curl -L "$_url" -v 2>$cookiefl > $tmpfl
if grep '{"data":\[\],"msg":"unauthorized"}' $tmpfl
mpg123 badid.mp3
eval $_audio_player badid.mp3
continue
end
if grep '签到中...' $tmpfl
echo 'got'
mpg123 signin.mp3
do_signin
continue
end
if grep "<p class='success-tip'>暂无签到开启</p>" $tmpfl
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment