Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
micro-teaching-assistant-fucker
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Recolic
micro-teaching-assistant-fucker
Commits
16150d2b
There was an error fetching the commit references. Please try again later.
Unverified
Commit
16150d2b
authored
6 years ago
by
Recolic Keghart
Browse files
Options
Downloads
Patches
Plain Diff
deal with teachermate update. use better notify
parent
aafd551e
No related branches found
No related tags found
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
config.fish
+8
-1
8 additions, 1 deletion
config.fish
daemon.sh
+1
-1
1 addition, 1 deletion
daemon.sh
impl/daemon-answer.fish
+4
-3
4 additions, 3 deletions
impl/daemon-answer.fish
impl/daemon-signin.fish
+20
-4
20 additions, 4 deletions
impl/daemon-signin.fish
with
33 additions
and
9 deletions
config.fish
+
8
−
1
View file @
16150d2b
...
...
@@ -3,11 +3,18 @@ set _audio_player "mpg123"
#set _audio_player "cvlc --play-and-exit"
# Where should I signin ?
# West XII
set _NorthLatitude "30.508914"
set _EastLongitude "114.40718"
# South I
#set _NorthLatitude "30.509595"
#set _EastLongitude "114.41374"
# How many seconds should I sleep after every check ?
set _monitor_interval "10"
# How many seconds should I delay before autosign ?
set _autosign_delay "10"
set _autosign_delay "1"
# Notifier. Call Format: $notifier "Title" "Message"
set _notify "notify-send"
This diff is collapsed.
Click to expand it.
daemon.sh
+
1
−
1
View file @
16150d2b
...
...
@@ -3,7 +3,7 @@
[[
$1
==
''
]]
&&
echo
"usage:
$0
sign/ans/all"
&&
exit
1
[[
$_openid
==
""
]]
&&
echo
'Give openid or url please:'
&&
read
_openid
_openid
=
$(
echo
"
$_openid
"
|
sed
's/^.*openid=//g'
)
_openid
=
$(
echo
"
$_openid
"
|
sed
's/^.*openid=//g'
|
sed
's/&.*$//g'
)
echo
"Set openid to
$_openid
"
function
_segfault_detected
()
{
...
...
This diff is collapsed.
Click to expand it.
impl/daemon-answer.fish
+
4
−
3
View file @
16150d2b
...
...
@@ -12,19 +12,20 @@ function _check_and_warn
return 0
end
eval $_audio_player answer.mp3 > /dev/null 2>&1
notify-send "Warning: Question opened!" "Question opened!"
echo "test"
eval $_notify "'Teachermate answer'" "'Question opened!'"
echo "LOG> Detected!"
end
function _on_unknown_error
eval $_audio_player error.mp3 > /dev/null 2>&1
notify-send "Warning: Error occurred!
" "Error occurred!"
eval $_notify "'Teachermate answer'
" "
'
Error occurred!
'
"
echo "LOG> Error occurred!"
end
function _on_openid_error
eval $_audio_player badid.mp3 > /dev/null 2>&1
notify-send "Warning: Invalid openid!
" "Error: Invalid openid."
eval $_notify "'Teachermate answer'
" "
'
Error: Invalid openid.
'
"
echo "LOG> Invalid openid."
end
...
...
This diff is collapsed.
Click to expand it.
impl/daemon-signin.fish
+
20
−
4
View file @
16150d2b
...
...
@@ -6,8 +6,8 @@ set _url "https://www.teachermate.com.cn/wechat/wechat/guide/signin?openid=$_ope
source ../config.fish
# Where should I signin ?
test -z $_NorthLatitude; and
set _NorthLatitude "30.509604"
test -z $_EastLongitude; and
set _EastLongitude "114.41374"
test -z $_NorthLatitude; and
echo "Warning: signin location _NorthLatitude not set. Rejecting dangerous operation..."; and exit 4
test -z $_EastLongitude; and
echo "Warning: signin location _EastLongitude not set. Rejecting dangerous operation..."; and exit 4
# How many seconds should I delay before autosign ?
test -z $_autosign_delay; and set _autosign_delay "10"
...
...
@@ -19,6 +19,22 @@ rm $tmpfl
set signed_in false
function on_signin_success
eval $_audio_player autosignin-success.mp3
eval $_notify "'Teachermate signin'" "'Signin success'"
end
function on_signin_fail
# will retry automatically
eval $_audio_player signin.mp3
eval $_notify "'Teachermate signin'" "'Signin failed'"
end
function on_badid
eval $_audio_player badid.mp3
eval $_notify "'Teachermate signin'" "'OpenID expired. Please restart the program with new openID'"
end
function do_signin
if test $signed_in = true
return
...
...
@@ -29,7 +45,7 @@ function do_signin
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 auto
signin
-
success
.mp3
; or
eval $_audio_player
signin
.mp3
grep -F '":["OK",' $cookiefl; and set signed_in true; and
on_
signin
_
success; or
on_
signin
_fail
end
while true
...
...
@@ -37,7 +53,7 @@ while true
date
curl -L "$_url" -v 2>$cookiefl > $tmpfl
if grep '{"data":\[\],"msg":"unauthorized"}' $tmpfl
eval $_audio_player badid.mp3
on_signin_fail
continue
end
if grep '签到中...' $tmpfl
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment