This project automates the login process and point registration for an intranet system using Selenium.
- Python 3.x
- Google Chrome
- Chromedriver
- Clone the repository:
git clone https://github.com/yourusername/automatic-clockin.git cd automatic-clockin
- Create a virtual environment:
python3 -m venv myenv source myenv/bin/activate # On Windows use `myenv\Scripts\activate`
- Install the dependencies:
pip install -r requirements.txt
This project can also send a confirmation message to your Telegram bot before executing the point registration script. Follow these steps to set it up:
- Open Telegram and search for
BotFather
. - Start a chat with
BotFather
and use the command/newbot
to create a new bot. - Follow the instructions to set up your bot and get the bot token.
- Run the script to get the
chat_id
:python get_chat_id_and_update_env.py
- Open a chat with your bot on Telegram and send
/start
. The bot will reply with yourchat_id
and update the.env
file automatically.
Ensure your .env
file contains the following variables:
TELEGRAM_TOKEN=your_telegram_bot_token CHAT_ID=your_obtained_chat_id_here LOGIN=your_login_value PASSWORD=your_password_value URL=your_url_here SCREENSHOT_PATH=/path/to/screenshot/directory SCRIPT_PATH=/path/to/point/registration/script
Run the script to send a message and handle responses:
sh python send_telegram_message.py
You can schedule the script to run at specific times using cron jobs on Unix systems or Task Scheduler on Windows.
For example, to run the script every weekday at specific times, add the following lines to your crontab:
sh 50 7 * * 1-5 python3 /path/to/send_telegram_message.py 00 12 * * 1-5 python3 /path/to/send_telegram_message.py 30 13 * * 1-5 python3 /path/to/send_telegram_message.py 05 18 * * 1-5 python3 /path/to/send_telegram_message.py
This will send a message to your Telegram bot at 7:50 AM, 12:00 PM, 1:30 PM, and 6:05 PM every weekday.
-
Obtain the
chat_id
:- Execute
get_chat_id_and_update_env.py
:python get_chat_id_and_update_env.py
- Open a chat with your bot on Telegram and send
/start
. The bot will reply with yourchat_id
and update the.env
file.
- Execute
-
Test the Telegram integration:
- Run
send_telegram_message.py
:python send_telegram_message.py
- Respond to the message on Telegram to see if the script behaves as expected.
- Run
-
Run the point registration script:
- Execute
index.py
:python index.py
- Execute
- If you encounter any issues, ensure that the
.env
file is correctly configured and that the required dependencies are installed.
Distributed under the MIT License. See LICENSE
for more information.