rhul-attendance-bot 0.1.48__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- rhul_attendance_bot-0.1.48/LICENSE +22 -0
- rhul_attendance_bot-0.1.48/MANIFEST.in +10 -0
- rhul_attendance_bot-0.1.48/PKG-INFO +234 -0
- rhul_attendance_bot-0.1.48/README.md +189 -0
- rhul_attendance_bot-0.1.48/README_CN.md +189 -0
- rhul_attendance_bot-0.1.48/RHUL_attendance_bot.py +580 -0
- rhul_attendance_bot-0.1.48/app_paths.py +74 -0
- rhul_attendance_bot-0.1.48/assets/discord_bot_screenshot.png +0 -0
- rhul_attendance_bot-0.1.48/assets/ui_screenshot.png +0 -0
- rhul_attendance_bot-0.1.48/auto_login.py +739 -0
- rhul_attendance_bot-0.1.48/discord_broadcast.py +70 -0
- rhul_attendance_bot-0.1.48/display_manager.py +274 -0
- rhul_attendance_bot-0.1.48/fetch_ics.py +103 -0
- rhul_attendance_bot-0.1.48/local_2fa.py +31 -0
- rhul_attendance_bot-0.1.48/pyproject.toml +45 -0
- rhul_attendance_bot-0.1.48/rhul_attendance_bot.egg-info/PKG-INFO +234 -0
- rhul_attendance_bot-0.1.48/rhul_attendance_bot.egg-info/SOURCES.txt +21 -0
- rhul_attendance_bot-0.1.48/rhul_attendance_bot.egg-info/dependency_links.txt +1 -0
- rhul_attendance_bot-0.1.48/rhul_attendance_bot.egg-info/entry_points.txt +2 -0
- rhul_attendance_bot-0.1.48/rhul_attendance_bot.egg-info/requires.txt +7 -0
- rhul_attendance_bot-0.1.48/rhul_attendance_bot.egg-info/top_level.txt +8 -0
- rhul_attendance_bot-0.1.48/setup.cfg +4 -0
- rhul_attendance_bot-0.1.48/update.py +67 -0
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
|
|
2
|
+
MIT License
|
|
3
|
+
|
|
4
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
5
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
6
|
+
in the Software without restriction, including without limitation the rights
|
|
7
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
8
|
+
copies of the Software, subject to the following conditions:
|
|
9
|
+
|
|
10
|
+
The above copyright notice and this permission notice shall be included in all
|
|
11
|
+
copies or substantial portions of the Software.
|
|
12
|
+
|
|
13
|
+
[Additional Clause]
|
|
14
|
+
For any commercial use, attribution to the original author (PandaQuQ) is required.
|
|
15
|
+
|
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
17
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
18
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
19
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
20
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
21
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
|
+
SOFTWARE.
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
include README.md
|
|
2
|
+
include README_CN.md
|
|
3
|
+
include LICENSE
|
|
4
|
+
recursive-include assets *.png *.jpg *.jpeg *.gif
|
|
5
|
+
exclude credentials.json
|
|
6
|
+
exclude 2fa_config.json
|
|
7
|
+
exclude automation.log
|
|
8
|
+
recursive-exclude chrome_user_data *
|
|
9
|
+
recursive-exclude ics *
|
|
10
|
+
global-exclude *.pyc
|
|
@@ -0,0 +1,234 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: rhul-attendance-bot
|
|
3
|
+
Version: 0.1.48
|
|
4
|
+
Summary: RHUL attendance automation bot
|
|
5
|
+
Author: PandaQuQ
|
|
6
|
+
License:
|
|
7
|
+
MIT License
|
|
8
|
+
|
|
9
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
10
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
11
|
+
in the Software without restriction, including without limitation the rights
|
|
12
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
13
|
+
copies of the Software, subject to the following conditions:
|
|
14
|
+
|
|
15
|
+
The above copyright notice and this permission notice shall be included in all
|
|
16
|
+
copies or substantial portions of the Software.
|
|
17
|
+
|
|
18
|
+
[Additional Clause]
|
|
19
|
+
For any commercial use, attribution to the original author (PandaQuQ) is required.
|
|
20
|
+
|
|
21
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
22
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
23
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
24
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
25
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
26
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
27
|
+
SOFTWARE.
|
|
28
|
+
|
|
29
|
+
Project-URL: Repository, https://github.com/PandaQuQ/RHUL_attendance_bot
|
|
30
|
+
Keywords: automation,attendance,selenium,rhul
|
|
31
|
+
Classifier: Programming Language :: Python :: 3
|
|
32
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
33
|
+
Classifier: Operating System :: OS Independent
|
|
34
|
+
Requires-Python: >=3.9
|
|
35
|
+
Description-Content-Type: text/markdown
|
|
36
|
+
License-File: LICENSE
|
|
37
|
+
Requires-Dist: ics
|
|
38
|
+
Requires-Dist: rich
|
|
39
|
+
Requires-Dist: selenium
|
|
40
|
+
Requires-Dist: webdriver-manager
|
|
41
|
+
Requires-Dist: pynput
|
|
42
|
+
Requires-Dist: ntplib
|
|
43
|
+
Requires-Dist: pyotp
|
|
44
|
+
Dynamic: license-file
|
|
45
|
+
|
|
46
|
+
# RHUL Attendance Bot
|
|
47
|
+
[中文](https://github.com/PandaQuQ/RHUL_attendance_bot/blob/main/README_CN.md)
|
|
48
|
+
---
|
|
49
|
+

|
|
50
|
+

|
|
51
|
+

|
|
52
|
+

|
|
53
|
+

|
|
54
|
+
|
|
55
|
+
The RHUL Attendance Bot automates attendance marking for Royal Holloway students by using web automation. The script checks your calendar events, triggers attendance based on specified conditions, and provides real-time logging using Rich library for better visualization.
|
|
56
|
+

|
|
57
|
+

|
|
58
|
+
## Features
|
|
59
|
+
|
|
60
|
+
- **Automated Attendance**: Automatically opens the attendance page and marks your attendance based on your calendar events.
|
|
61
|
+
- **Manual Trigger**: Allows manual attendance marking via keyboard shortcuts.
|
|
62
|
+
- **Real-Time Logging**: Displays logs using Rich library for a better visual experience.
|
|
63
|
+
- **Environment and Dependency Checks**: Ensures the script is run in the proper environment and all dependencies are installed.
|
|
64
|
+
- **System Time Synchronization Check**: Checks if the system time is synchronized with the NTP server.
|
|
65
|
+
- **Auto-Update Feature**: Detects script updates and prompts the user to update.
|
|
66
|
+
- **Auto Login with 2FA**: Handles Microsoft login, switches to verification code, and auto-fills TOTP from your saved secret.
|
|
67
|
+
- **Automatic Timetable Download**: On first run, automatically fetches your ICS timetable into the `ics/` folder—no manual download needed.
|
|
68
|
+
- **Discord Webhook Notifications (optional)**: Sends start/stop, login success, and attendance success messages with your profile name when a webhook URL is configured.
|
|
69
|
+
|
|
70
|
+
## Prerequisites
|
|
71
|
+
|
|
72
|
+
1. **Python 3.9 or above**: Ensure that Python is installed. If not, download and install it from [python.org](https://www.python.org/downloads/).
|
|
73
|
+
2. **Google Chrome Browser**: The script uses Chrome for web automation. Make sure it is installed.
|
|
74
|
+
3. **Virtual Environment (Recommended)**: Run the script inside a Python virtual environment to avoid dependency conflicts.
|
|
75
|
+
|
|
76
|
+
## Installation
|
|
77
|
+
|
|
78
|
+
Install Google Chrome if you don't have it yet: [download page](https://www.google.com/chrome/) (macOS users can also `brew install --cask google-chrome`).
|
|
79
|
+
|
|
80
|
+
### Step 1: Clone the Repository
|
|
81
|
+
|
|
82
|
+
```bash
|
|
83
|
+
git clone https://github.com/PandaQuQ/RHUL_attendance_bot.git
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
### Step 2: Navigate to the Project Directory
|
|
87
|
+
|
|
88
|
+
```bash
|
|
89
|
+
cd RHUL_attendance_bot
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
### Step 3: Set Up a Virtual Environment (Recommended)
|
|
93
|
+
|
|
94
|
+
#### On Windows:
|
|
95
|
+
```bash
|
|
96
|
+
python -m venv venv
|
|
97
|
+
venv\Scripts\activate
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
#### On macOS/Linux:
|
|
101
|
+
```bash
|
|
102
|
+
python3 -m venv venv
|
|
103
|
+
source venv/bin/activate
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
### Step 4: Install Dependencies
|
|
107
|
+
|
|
108
|
+
#### Option A: Install from PyPI (recommended)
|
|
109
|
+
|
|
110
|
+
```bash
|
|
111
|
+
pip install rhul-attendance-bot
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
#### Option B: Install from source
|
|
115
|
+
|
|
116
|
+
```bash
|
|
117
|
+
pip install -r requirements.txt
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
### Step 5: (Optional) Prepare ICS Manually
|
|
121
|
+
|
|
122
|
+
The bot now auto-downloads your timetable on first run and stores it in `ics/`. You only need manual prep if the auto download fails:
|
|
123
|
+
|
|
124
|
+
- Go to [Royal Holloway Timetable](https://intranet.royalholloway.ac.uk/students/study/timetable/your-timetable.aspx) and log in.
|
|
125
|
+
- Choose `Calendar Download`, click `View Timetable`, then `Android™ and others` to get the `.ics` link.
|
|
126
|
+
- Download the `.ics` and place it into the `ics` folder at the project root (create it if missing).
|
|
127
|
+
|
|
128
|
+
## Usage
|
|
129
|
+
|
|
130
|
+
1. **Navigate to the Script Directory**:
|
|
131
|
+
|
|
132
|
+
```bash
|
|
133
|
+
cd RHUL_attendance_bot
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
2. **Activate the Virtual Environment**:
|
|
137
|
+
|
|
138
|
+
#### On Windows:
|
|
139
|
+
```bash
|
|
140
|
+
venv\Scripts\activate
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
#### On macOS/Linux:
|
|
144
|
+
```bash
|
|
145
|
+
source venv/bin/activate
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
3. **Run the Script**:
|
|
149
|
+
|
|
150
|
+
#### From PyPI install:
|
|
151
|
+
```bash
|
|
152
|
+
rhul-attendance-bot
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
#### From source:
|
|
156
|
+
```bash
|
|
157
|
+
python RHUL_attendance_bot.py
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
> **✅ Auto Login + 2FA**
|
|
161
|
+
>
|
|
162
|
+
> The bot now handles Microsoft login and the verification-code MFA flow automatically using your stored credentials and local TOTP secret. On first run, complete onboarding (credentials/secret); the timetable is downloaded automatically.
|
|
163
|
+
|
|
164
|
+
4. **Profile Selection**:
|
|
165
|
+
|
|
166
|
+
- Use `-user <profile_name>` to pick a specific profile, e.g.:
|
|
167
|
+
```bash
|
|
168
|
+
rhul-attendance-bot -user Alice
|
|
169
|
+
```
|
|
170
|
+
- If `-user` is not provided, the app will list existing profiles and ask you to choose (or create a new one).
|
|
171
|
+
|
|
172
|
+
5. **Keyboard Shortcuts**:
|
|
173
|
+
|
|
174
|
+
- **Manually Trigger the Next Event**: Press `[`, then `]`
|
|
175
|
+
- **Exit the Script**: Press `[`, then `q`
|
|
176
|
+
|
|
177
|
+
## Important Notes
|
|
178
|
+
|
|
179
|
+
- **Dependencies**: Make sure all required dependencies are installed by following the instructions in the `requirements.txt` file.
|
|
180
|
+
- **Virtual Environment**: Using a virtual environment is highly recommended to avoid conflicts with global packages.
|
|
181
|
+
- **System Time**: If the system time is not synchronized with the NTP server, the script will prompt you to synchronize your system clock.
|
|
182
|
+
- **Supported Platforms**: The script supports Windows, macOS, and Linux.
|
|
183
|
+
|
|
184
|
+
### Multi-Profile Usage
|
|
185
|
+
|
|
186
|
+
Profiles are stored under `~/.rhul_attendance_bot/profiles/<profile_name>`. Each profile has its own:
|
|
187
|
+
|
|
188
|
+
- `credentials.json`
|
|
189
|
+
- `2fa_config.json`
|
|
190
|
+
- `ics/`
|
|
191
|
+
- `chrome_user_data/`
|
|
192
|
+
- `automation.log`
|
|
193
|
+
|
|
194
|
+
Use `-user` to switch profiles at runtime.
|
|
195
|
+
|
|
196
|
+
> **🔐 Security Note - Login Session Duration**
|
|
197
|
+
>
|
|
198
|
+
> ~~A session typically lasts about one week; you may need to manually re-login after it expires.~~
|
|
199
|
+
> The bot now auto-renews login with stored credentials + TOTP. Sessions are refreshed automatically; monitor occasionally in case the institution changes its 2FA policy.
|
|
200
|
+
|
|
201
|
+
## Configuration
|
|
202
|
+
|
|
203
|
+
To configure the script, modify the relevant parameters inside the code or create a configuration file (not provided in this version). Future versions may include more flexible configuration options.
|
|
204
|
+
|
|
205
|
+
## Updating
|
|
206
|
+
|
|
207
|
+
If an update is detected, the script will prompt you to update. You can choose to update by typing `y` or skip it by typing `n`.
|
|
208
|
+
|
|
209
|
+
## Troubleshooting
|
|
210
|
+
|
|
211
|
+
1. **Chrome WebDriver Issues**: Make sure that the correct version of the ChromeDriver is being used. The script uses `webdriver-manager` to automatically manage ChromeDriver versions.
|
|
212
|
+
2. **Dependency Issues**: If you encounter errors related to missing modules, reinstall via `pip install rhul-attendance-bot` or use `pip install -r requirements.txt` from source.
|
|
213
|
+
3. **Virtual Environment Issues**: If you face issues while running the script, try setting up a fresh virtual environment and reinstalling the dependencies.
|
|
214
|
+
|
|
215
|
+
## TODO
|
|
216
|
+
|
|
217
|
+
Current focus / future ideas:
|
|
218
|
+
|
|
219
|
+
- ✅ **2FA Integration**: Microsoft verification-code path with TOTP auto-fill is implemented.
|
|
220
|
+
- ✅ **Automatic Login**: Stored credentials + TOTP drive a fully automatic login flow.
|
|
221
|
+
- ✅ **2FA Code Reading**: OTP is generated locally from your saved secret.
|
|
222
|
+
- ✅ **Discord Webhook Bot**: Discord webhook notifications for attendance status, login, and lifecycle (optional; disable by leaving webhook URL empty)
|
|
223
|
+
|
|
224
|
+
## License
|
|
225
|
+
|
|
226
|
+
This project is licensed under the MIT License with an additional clause. See the [LICENSE](LICENSE) file for details.
|
|
227
|
+
|
|
228
|
+
## Acknowledgments
|
|
229
|
+
|
|
230
|
+
- Thanks to the developers of [Rich](https://github.com/Textualize/rich), [Selenium](https://www.selenium.dev/), and [ics.py](https://github.com/C4ptainCrunch/ics.py) for their amazing libraries.
|
|
231
|
+
|
|
232
|
+
## Contact
|
|
233
|
+
|
|
234
|
+
For questions or suggestions, please feel free to reach out via the [GitHub repository](https://github.com/PandaQuQ/RHUL_attendance_bot). Feedback and contributions are welcome!
|
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
# RHUL Attendance Bot
|
|
2
|
+
[中文](https://github.com/PandaQuQ/RHUL_attendance_bot/blob/main/README_CN.md)
|
|
3
|
+
---
|
|
4
|
+

|
|
5
|
+

|
|
6
|
+

|
|
7
|
+

|
|
8
|
+

|
|
9
|
+
|
|
10
|
+
The RHUL Attendance Bot automates attendance marking for Royal Holloway students by using web automation. The script checks your calendar events, triggers attendance based on specified conditions, and provides real-time logging using Rich library for better visualization.
|
|
11
|
+

|
|
12
|
+

|
|
13
|
+
## Features
|
|
14
|
+
|
|
15
|
+
- **Automated Attendance**: Automatically opens the attendance page and marks your attendance based on your calendar events.
|
|
16
|
+
- **Manual Trigger**: Allows manual attendance marking via keyboard shortcuts.
|
|
17
|
+
- **Real-Time Logging**: Displays logs using Rich library for a better visual experience.
|
|
18
|
+
- **Environment and Dependency Checks**: Ensures the script is run in the proper environment and all dependencies are installed.
|
|
19
|
+
- **System Time Synchronization Check**: Checks if the system time is synchronized with the NTP server.
|
|
20
|
+
- **Auto-Update Feature**: Detects script updates and prompts the user to update.
|
|
21
|
+
- **Auto Login with 2FA**: Handles Microsoft login, switches to verification code, and auto-fills TOTP from your saved secret.
|
|
22
|
+
- **Automatic Timetable Download**: On first run, automatically fetches your ICS timetable into the `ics/` folder—no manual download needed.
|
|
23
|
+
- **Discord Webhook Notifications (optional)**: Sends start/stop, login success, and attendance success messages with your profile name when a webhook URL is configured.
|
|
24
|
+
|
|
25
|
+
## Prerequisites
|
|
26
|
+
|
|
27
|
+
1. **Python 3.9 or above**: Ensure that Python is installed. If not, download and install it from [python.org](https://www.python.org/downloads/).
|
|
28
|
+
2. **Google Chrome Browser**: The script uses Chrome for web automation. Make sure it is installed.
|
|
29
|
+
3. **Virtual Environment (Recommended)**: Run the script inside a Python virtual environment to avoid dependency conflicts.
|
|
30
|
+
|
|
31
|
+
## Installation
|
|
32
|
+
|
|
33
|
+
Install Google Chrome if you don't have it yet: [download page](https://www.google.com/chrome/) (macOS users can also `brew install --cask google-chrome`).
|
|
34
|
+
|
|
35
|
+
### Step 1: Clone the Repository
|
|
36
|
+
|
|
37
|
+
```bash
|
|
38
|
+
git clone https://github.com/PandaQuQ/RHUL_attendance_bot.git
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
### Step 2: Navigate to the Project Directory
|
|
42
|
+
|
|
43
|
+
```bash
|
|
44
|
+
cd RHUL_attendance_bot
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
### Step 3: Set Up a Virtual Environment (Recommended)
|
|
48
|
+
|
|
49
|
+
#### On Windows:
|
|
50
|
+
```bash
|
|
51
|
+
python -m venv venv
|
|
52
|
+
venv\Scripts\activate
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
#### On macOS/Linux:
|
|
56
|
+
```bash
|
|
57
|
+
python3 -m venv venv
|
|
58
|
+
source venv/bin/activate
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
### Step 4: Install Dependencies
|
|
62
|
+
|
|
63
|
+
#### Option A: Install from PyPI (recommended)
|
|
64
|
+
|
|
65
|
+
```bash
|
|
66
|
+
pip install rhul-attendance-bot
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
#### Option B: Install from source
|
|
70
|
+
|
|
71
|
+
```bash
|
|
72
|
+
pip install -r requirements.txt
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
### Step 5: (Optional) Prepare ICS Manually
|
|
76
|
+
|
|
77
|
+
The bot now auto-downloads your timetable on first run and stores it in `ics/`. You only need manual prep if the auto download fails:
|
|
78
|
+
|
|
79
|
+
- Go to [Royal Holloway Timetable](https://intranet.royalholloway.ac.uk/students/study/timetable/your-timetable.aspx) and log in.
|
|
80
|
+
- Choose `Calendar Download`, click `View Timetable`, then `Android™ and others` to get the `.ics` link.
|
|
81
|
+
- Download the `.ics` and place it into the `ics` folder at the project root (create it if missing).
|
|
82
|
+
|
|
83
|
+
## Usage
|
|
84
|
+
|
|
85
|
+
1. **Navigate to the Script Directory**:
|
|
86
|
+
|
|
87
|
+
```bash
|
|
88
|
+
cd RHUL_attendance_bot
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
2. **Activate the Virtual Environment**:
|
|
92
|
+
|
|
93
|
+
#### On Windows:
|
|
94
|
+
```bash
|
|
95
|
+
venv\Scripts\activate
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
#### On macOS/Linux:
|
|
99
|
+
```bash
|
|
100
|
+
source venv/bin/activate
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
3. **Run the Script**:
|
|
104
|
+
|
|
105
|
+
#### From PyPI install:
|
|
106
|
+
```bash
|
|
107
|
+
rhul-attendance-bot
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
#### From source:
|
|
111
|
+
```bash
|
|
112
|
+
python RHUL_attendance_bot.py
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
> **✅ Auto Login + 2FA**
|
|
116
|
+
>
|
|
117
|
+
> The bot now handles Microsoft login and the verification-code MFA flow automatically using your stored credentials and local TOTP secret. On first run, complete onboarding (credentials/secret); the timetable is downloaded automatically.
|
|
118
|
+
|
|
119
|
+
4. **Profile Selection**:
|
|
120
|
+
|
|
121
|
+
- Use `-user <profile_name>` to pick a specific profile, e.g.:
|
|
122
|
+
```bash
|
|
123
|
+
rhul-attendance-bot -user Alice
|
|
124
|
+
```
|
|
125
|
+
- If `-user` is not provided, the app will list existing profiles and ask you to choose (or create a new one).
|
|
126
|
+
|
|
127
|
+
5. **Keyboard Shortcuts**:
|
|
128
|
+
|
|
129
|
+
- **Manually Trigger the Next Event**: Press `[`, then `]`
|
|
130
|
+
- **Exit the Script**: Press `[`, then `q`
|
|
131
|
+
|
|
132
|
+
## Important Notes
|
|
133
|
+
|
|
134
|
+
- **Dependencies**: Make sure all required dependencies are installed by following the instructions in the `requirements.txt` file.
|
|
135
|
+
- **Virtual Environment**: Using a virtual environment is highly recommended to avoid conflicts with global packages.
|
|
136
|
+
- **System Time**: If the system time is not synchronized with the NTP server, the script will prompt you to synchronize your system clock.
|
|
137
|
+
- **Supported Platforms**: The script supports Windows, macOS, and Linux.
|
|
138
|
+
|
|
139
|
+
### Multi-Profile Usage
|
|
140
|
+
|
|
141
|
+
Profiles are stored under `~/.rhul_attendance_bot/profiles/<profile_name>`. Each profile has its own:
|
|
142
|
+
|
|
143
|
+
- `credentials.json`
|
|
144
|
+
- `2fa_config.json`
|
|
145
|
+
- `ics/`
|
|
146
|
+
- `chrome_user_data/`
|
|
147
|
+
- `automation.log`
|
|
148
|
+
|
|
149
|
+
Use `-user` to switch profiles at runtime.
|
|
150
|
+
|
|
151
|
+
> **🔐 Security Note - Login Session Duration**
|
|
152
|
+
>
|
|
153
|
+
> ~~A session typically lasts about one week; you may need to manually re-login after it expires.~~
|
|
154
|
+
> The bot now auto-renews login with stored credentials + TOTP. Sessions are refreshed automatically; monitor occasionally in case the institution changes its 2FA policy.
|
|
155
|
+
|
|
156
|
+
## Configuration
|
|
157
|
+
|
|
158
|
+
To configure the script, modify the relevant parameters inside the code or create a configuration file (not provided in this version). Future versions may include more flexible configuration options.
|
|
159
|
+
|
|
160
|
+
## Updating
|
|
161
|
+
|
|
162
|
+
If an update is detected, the script will prompt you to update. You can choose to update by typing `y` or skip it by typing `n`.
|
|
163
|
+
|
|
164
|
+
## Troubleshooting
|
|
165
|
+
|
|
166
|
+
1. **Chrome WebDriver Issues**: Make sure that the correct version of the ChromeDriver is being used. The script uses `webdriver-manager` to automatically manage ChromeDriver versions.
|
|
167
|
+
2. **Dependency Issues**: If you encounter errors related to missing modules, reinstall via `pip install rhul-attendance-bot` or use `pip install -r requirements.txt` from source.
|
|
168
|
+
3. **Virtual Environment Issues**: If you face issues while running the script, try setting up a fresh virtual environment and reinstalling the dependencies.
|
|
169
|
+
|
|
170
|
+
## TODO
|
|
171
|
+
|
|
172
|
+
Current focus / future ideas:
|
|
173
|
+
|
|
174
|
+
- ✅ **2FA Integration**: Microsoft verification-code path with TOTP auto-fill is implemented.
|
|
175
|
+
- ✅ **Automatic Login**: Stored credentials + TOTP drive a fully automatic login flow.
|
|
176
|
+
- ✅ **2FA Code Reading**: OTP is generated locally from your saved secret.
|
|
177
|
+
- ✅ **Discord Webhook Bot**: Discord webhook notifications for attendance status, login, and lifecycle (optional; disable by leaving webhook URL empty)
|
|
178
|
+
|
|
179
|
+
## License
|
|
180
|
+
|
|
181
|
+
This project is licensed under the MIT License with an additional clause. See the [LICENSE](LICENSE) file for details.
|
|
182
|
+
|
|
183
|
+
## Acknowledgments
|
|
184
|
+
|
|
185
|
+
- Thanks to the developers of [Rich](https://github.com/Textualize/rich), [Selenium](https://www.selenium.dev/), and [ics.py](https://github.com/C4ptainCrunch/ics.py) for their amazing libraries.
|
|
186
|
+
|
|
187
|
+
## Contact
|
|
188
|
+
|
|
189
|
+
For questions or suggestions, please feel free to reach out via the [GitHub repository](https://github.com/PandaQuQ/RHUL_attendance_bot). Feedback and contributions are welcome!
|
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
# RHUL 自动签到脚本
|
|
2
|
+
[English](https://github.com/PandaQuQ/RHUL_attendance_bot/blob/main/README.md)
|
|
3
|
+
---
|
|
4
|
+

|
|
5
|
+

|
|
6
|
+

|
|
7
|
+

|
|
8
|
+

|
|
9
|
+
|
|
10
|
+
RHUL 自动签到脚本通过使用网页自动化来为 Royal Holloway 学生自动签到。该脚本根据日历事件检查并触发签到操作,并使用 Rich 库进行实时日志记录,提供更好的可视化体验。
|
|
11
|
+

|
|
12
|
+

|
|
13
|
+
## 功能
|
|
14
|
+
|
|
15
|
+
- **自动签到**:根据日历事件自动打开签到页面并进行签到。
|
|
16
|
+
- **手动触发**:允许通过快捷键手动触发签到操作。
|
|
17
|
+
- **实时日志记录**:使用 Rich 库显示日志,提供更好的视觉效果。
|
|
18
|
+
- **环境和依赖检查**:确保脚本在正确的环境中运行并安装了所有依赖项。
|
|
19
|
+
- **系统时间同步检查**:检查系统时间是否与 NTP 服务器同步。
|
|
20
|
+
- **自动更新功能**:检测脚本更新并提示用户更新。
|
|
21
|
+
- **自动登录 + 2FA**:自动处理微软登录,选择“验证码”方式,并用本地保存的 TOTP 秘钥自动填充验证码。
|
|
22
|
+
- **自动下载课表**:首次运行自动下载课表到 `ics/` 目录,无需手动获取 `.ics` 文件。
|
|
23
|
+
- **Discord Webhook 通知(可选)**:配置 Webhook 后推送启动/停止、登录成功、签到成功等消息,并附带个人昵称。
|
|
24
|
+
|
|
25
|
+
## 前提条件
|
|
26
|
+
|
|
27
|
+
1. **Python 3.9 或以上**:确保已安装 Python。如果没有,请从 [python.org](https://www.python.org/downloads/) 下载并安装。
|
|
28
|
+
2. **Google Chrome 浏览器**:脚本使用 Chrome 进行网页自动化,请确保已安装 Chrome 浏览器。
|
|
29
|
+
3. **虚拟环境(推荐)**:在 Python 虚拟环境中运行脚本以避免依赖冲突。
|
|
30
|
+
|
|
31
|
+
## 安装
|
|
32
|
+
|
|
33
|
+
在安装前请先确保已安装 Google Chrome:可前往 [下载页面](https://www.google.com/chrome/)(macOS 也可使用 `brew install --cask google-chrome`)。
|
|
34
|
+
|
|
35
|
+
### 步骤 1:克隆代码仓库
|
|
36
|
+
|
|
37
|
+
```bash
|
|
38
|
+
git clone https://github.com/PandaQuQ/RHUL_attendance_bot.git
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
### 步骤 2:进入项目目录
|
|
42
|
+
|
|
43
|
+
```bash
|
|
44
|
+
cd RHUL_attendance_bot
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
### 步骤 3:设置虚拟环境(推荐)
|
|
48
|
+
|
|
49
|
+
#### Windows 系统:
|
|
50
|
+
```bash
|
|
51
|
+
python -m venv venv
|
|
52
|
+
venv\Scripts\activate
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
#### macOS/Linux 系统:
|
|
56
|
+
```bash
|
|
57
|
+
python3 -m venv venv
|
|
58
|
+
source venv/bin/activate
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
### 步骤 4:安装依赖项
|
|
62
|
+
|
|
63
|
+
#### 方式 A:通过 PyPI 安装(推荐)
|
|
64
|
+
|
|
65
|
+
```bash
|
|
66
|
+
pip install rhul-attendance-bot
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
#### 方式 B:从源码安装
|
|
70
|
+
|
|
71
|
+
```bash
|
|
72
|
+
pip install -r requirements.txt
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
### 步骤 5:(可选)手动准备课表
|
|
76
|
+
|
|
77
|
+
脚本现已在首次运行时自动下载课表到 `ics/`。仅当自动下载失败时,才需要手动准备:
|
|
78
|
+
|
|
79
|
+
- 访问 [Royal Holloway 课表系统](https://intranet.royalholloway.ac.uk/students/study/timetable/your-timetable.aspx) 并登录。
|
|
80
|
+
- 选择 `Calendar Download`,点击 `View Timetable`,然后点击 `Android™ and others` 获取 `.ics` 链接。
|
|
81
|
+
- 下载 `.ics` 文件,并放入项目根目录的 `ics` 文件夹(如无则新建)。
|
|
82
|
+
|
|
83
|
+
## 使用说明
|
|
84
|
+
|
|
85
|
+
1. **进入脚本根目录**:
|
|
86
|
+
|
|
87
|
+
```bash
|
|
88
|
+
cd RHUL_attendance_bot
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
2. **激活虚拟环境**:
|
|
92
|
+
|
|
93
|
+
#### Windows 系统:
|
|
94
|
+
```bash
|
|
95
|
+
venv\Scripts\activate
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
#### macOS/Linux 系统:
|
|
99
|
+
```bash
|
|
100
|
+
source venv/bin/activate
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
3. **运行脚本**:
|
|
104
|
+
|
|
105
|
+
#### PyPI 安装:
|
|
106
|
+
```bash
|
|
107
|
+
rhul-attendance-bot
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
#### 源码运行:
|
|
111
|
+
```bash
|
|
112
|
+
python RHUL_attendance_bot.py
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
> **✅ 自动登录 + 2FA 已完成**
|
|
116
|
+
>
|
|
117
|
+
> 现在脚本会自动处理微软登录和“验证码” MFA 流程,使用已保存的账号、密码和本地 TOTP 秘钥生成验证码。首次运行按引导完成账号/秘钥绑定;课表将自动下载。
|
|
118
|
+
|
|
119
|
+
4. **Profile 选择**:
|
|
120
|
+
|
|
121
|
+
- 用 `-user <profile_name>` 指定 Profile,例如:
|
|
122
|
+
```bash
|
|
123
|
+
rhul-attendance-bot -user 用户1
|
|
124
|
+
```
|
|
125
|
+
- 不传 `-user` 会列出已有 Profile 并让你选择/创建。
|
|
126
|
+
|
|
127
|
+
5. **快捷键说明**:
|
|
128
|
+
|
|
129
|
+
- **手动触发下一个事件**:按下 `[` 然后按 `]`
|
|
130
|
+
- **退出脚本**:按下 `[` 然后按 `q`
|
|
131
|
+
|
|
132
|
+
## 注意事项
|
|
133
|
+
|
|
134
|
+
- **依赖项**:确保已根据 `requirements.txt` 文件的说明安装所有必需的依赖项。
|
|
135
|
+
- **虚拟环境**:强烈建议使用虚拟环境,以避免与全局包产生冲突。
|
|
136
|
+
- **系统时间**:如果系统时间与 NTP 服务器不同步,脚本会提示您同步系统时钟。
|
|
137
|
+
- **支持平台**:脚本支持 Windows、macOS 和 Linux 系统。
|
|
138
|
+
|
|
139
|
+
### 多 Profile 使用
|
|
140
|
+
|
|
141
|
+
Profile 数据存放在 `~/.rhul_attendance_bot/profiles/<profile_name>` 下,每个 Profile 独立保存:
|
|
142
|
+
|
|
143
|
+
- `credentials.json`
|
|
144
|
+
- `2fa_config.json`
|
|
145
|
+
- `ics/`
|
|
146
|
+
- `chrome_user_data/`
|
|
147
|
+
- `automation.log`
|
|
148
|
+
|
|
149
|
+
运行时用 `-user` 切换 Profile。
|
|
150
|
+
|
|
151
|
+
> **🔐 安全提示 - 登录会话时长**
|
|
152
|
+
>
|
|
153
|
+
> ~~一次登录周期大约为一周,过期可能需要手动重新登录。~~
|
|
154
|
+
> 现在已支持使用存储的账号 + TOTP 自动续期登录。会话会自动刷新;如学校调整 2FA 策略,请偶尔检查运行状态。
|
|
155
|
+
|
|
156
|
+
## 配置
|
|
157
|
+
|
|
158
|
+
要配置脚本,可以修改代码中的相关参数,或者创建配置文件(当前版本不提供)。未来版本可能会增加更灵活的配置选项。
|
|
159
|
+
|
|
160
|
+
## 更新
|
|
161
|
+
|
|
162
|
+
如果检测到更新,脚本会提示您是否更新。可以输入 `y` 更新,也可以输入 `n` 跳过更新。
|
|
163
|
+
|
|
164
|
+
## 常见问题
|
|
165
|
+
|
|
166
|
+
1. **Chrome WebDriver 问题**:确保使用的是正确版本的 ChromeDriver。脚本使用 `webdriver-manager` 自动管理 ChromeDriver 版本。
|
|
167
|
+
2. **依赖问题**:如果遇到缺少模块的错误,请使用 `pip install rhul-attendance-bot` 或从源码执行 `pip install -r requirements.txt`。
|
|
168
|
+
3. **虚拟环境问题**:如果运行脚本时出现问题,请尝试重新设置虚拟环境并重新安装依赖项。
|
|
169
|
+
|
|
170
|
+
## TODO
|
|
171
|
+
|
|
172
|
+
当前进展 / 后续想法:
|
|
173
|
+
|
|
174
|
+
- ✅ **集成 2FA**:已实现微软验证码通道,自动填充 TOTP。
|
|
175
|
+
- ✅ **读取 2FA 验证码**:使用本地秘钥生成 OTP 并自动填写。
|
|
176
|
+
- ✅ **自动登录**:已实现全自动登录流程。
|
|
177
|
+
- ✅ **Discord Hook Bot**:已支持 Discord Webhook 通知(可选,Webhook 置空即禁用),推送签到状态、登录和生命周期事件
|
|
178
|
+
|
|
179
|
+
## 许可证
|
|
180
|
+
|
|
181
|
+
本项目采用 MIT 许可证并附加额外条款。有关详细信息,请参阅 [LICENSE](LICENSE) 文件。
|
|
182
|
+
|
|
183
|
+
## 鸣谢
|
|
184
|
+
|
|
185
|
+
- 感谢 [Rich](https://github.com/Textualize/rich)、[Selenium](https://www.selenium.dev/) 和 [ics.py](https://github.com/C4ptainCrunch/ics.py) 库的开发者。
|
|
186
|
+
|
|
187
|
+
## 联系方式
|
|
188
|
+
|
|
189
|
+
如有问题或建议,请通过 [GitHub 仓库](https://github.com/PandaQuQ/RHUL_attendance_bot) 联系我。欢迎反馈和贡献!
|