-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathget_GPA.rb
More file actions
41 lines (38 loc) · 924 Bytes
/
Copy pathget_GPA.rb
File metadata and controls
41 lines (38 loc) · 924 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
require 'yaml'
require './lib/request.rb'
require './lib/score.rb'
require './lib/email.rb'
begin
# Load accounts and password.
profiles = YAML.load_file('public/account.yml')
rescue
puts '未找到账号密码,请新建account.yml并存入账号密码'
exit
end
mailer = Email.new
profiles.each do |pro|
account = pro['account'].to_s
password = pro['password'].to_s
subs_email = pro['subs_email'].to_s
subs_name = pro['subs_name'].to_s
begin
req = Request.new(account, password)
req.download_score
score = Score.new
rescue => e
# Just print the error message for running constanly.
p e
next
end
scores = score.score_list
gpas = score.gpas
unless subs_email.nil?
begin
mailer.send_GPA(subs_email, scores, gpas, subs_name)
rescue => e
p e
puts "\033[31;1m邮件发送失败,请检查邮箱是否正确!\033[0m"
next
end
end
end