forked from FirmianaMarsili/picacomic-Punch
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Program.cs
83 lines (76 loc) · 2.58 KB
/
Program.cs
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using Newtonsoft.Json.Linq;
using picacomic;
using picacomic.Http.Response;
namespace picacomic
{
struct Account
{
public string username;
public string password;
}
class Program
{
static async System.Threading.Tasks.Task Main(string[] args)
{
if (args.Length == 0 || string.IsNullOrEmpty(args[0]))
{
throw new Exception("请查看文档设置账号密码");
}
List<Account> Accounts = new List<Account>();
foreach (var item in args[0].Split('|'))
{
if (!string.IsNullOrEmpty(item))
{
string[] user_pass = item.Split(',');
if (user_pass.Length == 2)
{
Accounts.Add(new Account
{
username = user_pass[0],
password = user_pass[1]
});
}
else
{
throw new Exception("请查看文档设置账号密码");
}
}
}
for (int i = 0; i < Accounts.Count; i++)
{
await PunchAsync(Accounts[i].username, Accounts[i].password, i);
}
}
private static void Log(object o)
{
Console.WriteLine($"[{DateTime.Now.ToString("HH:mm:ss")}]{o.ToString()}");
}
private static async Task PunchAsync(string username,string password,int index)
{
Log("=============================================");
Log($"开始运行第{index + 1}个账号");
Login login = await PicacomicUrl.Login(username, password);
Log("登录成功");
Header.SetAuthorization(login.Authorization);
Log("开始获取人物信息");
Profile profile = await PicacomicUrl.Profile();
Log($"昵称:{profile.User.Name}");
Log("开始签到");
Punch punch = await PicacomicUrl.Punch();
if (punch.PunchSuccess)
{
Log("签到完成");
Profile profile_punch = await PicacomicUrl.Profile();
Log($"等级:{profile_punch.User.Level}");
Log($"当前经验:{profile_punch.User.Exp}");
}
else
{
throw new Exception("签到失败");
}
}
}
}