Redmine Telegram Notification is a Telegram bot designed to notify users about updates and status changes of issues in Redmine. Developed for personal use, this project can be utilized by others, and feedback is greatly appreciated.
For any inquiries or suggestions, reach out via Telegram: @danek_kulikov
- Development Rules
- Installation
- Configuration
- Available Scripts
- Project Structure
- Running the Bot
- Functionality
- For a new feature or fix, create a branch from
Main
with a descriptive name, for example:fixCalendarApi
. - Test to ensure everything is working fine, then create a PR to merge this branch into the
Dev
branch. - Verify in the
Dev
branch that everything is working correctly, possibly checking all the functionality with someone else, and then create a PR to mergeDev
intoMain
. - You are awesome (broke everything again).
To get started with BIV Redmine Notification Bot, clone the repository and install the dependencies.
git clone https://github.com/zonder12120/redmine-telegram-notification.git
cd redmine-telegram-notification
npm install
- Install the Prettier extension (Prettier - Code formatter) from the extensions marketplace.
- In Visual Studio Code settings, set Prettier as the default formatter:
File
>Preferences
>Settings
>Text Editor
>Formatting
.
- In WebStorm settings, follow this path:
Settings
>Languages & Frameworks
>JavaScript
>Prettier
. - Select the
manual configuration
option, and the package path should be automatically detected. - Check the
Run Reformat code action
andRun on save
options.
Create a .env
file in the root directory of the project with the following environment variables:
TELEGRAM_BOT_TOKEN
: The token for your Telegram bot.CHAT_ID
: The chat ID where the bot will send notifications.REDMINE_API_KEY
: Your API key for Redmine.BASE_URL
: Base URL for your Redmine instance like https://redmine.your-company.com
ATTENTION, CUSTOM RUSSIAN HOLIDAY CALENDAR IN USE!
If you are not from Russia, you can find an API for your country's calendar. I don't think there would be any difficulties with that.
Example .env
file:
TELEGRAM_BOT_TOKEN=your_telegram_bot_token
CHAT_ID=your_chat_id
REDMINE_API_KEY=your_redmine_api_key
BASE_URL=https://redmine.your-company.com
GOOGLE_CALENDAR_KEY - well-known key for accessing a custom Google calendar, this is present in the config.ts
. You can use any other API to obtain holiday days, this is done in the file time.ts
.
In the project directory, you can run:
npm run build
Compiles the TypeScript files into JavaScript.
npm start
Compiles the TypeScript files and starts the bot.
npm test
Runs tests (not specified).
The project structure includes the following key files:
- config.ts: Handles the configuration by loading environment variables.
- redmine.ts: Contains functions to interact with the Redmine API.
- time.ts: Functions to handle date and time, including working hours and holidays.
- notifications.ts: Handles sending notifications via Telegram.
- telegram.ts: Utility functions to send messages via the Telegram bot.
- app.ts: Main application file, initializes and runs the bot.
Before running the bot, ensure the environment variables are set correctly in the .env file. Then, build and start the bot using the following commands:
npm run build
npm start
The bot will start running, checking for updates every minute, and sending notifications for new issues, status updates, and comments.
- Fetching Issues: Retrieves the list of current issues from Redmine.
- Ignoring Certain Issues: Certain issues can be ignored based on their ID.
- Filtering Updates: Filters issues based on status and tracks updates.
Various types of notifications are sent via Telegram:
- New Issues: Notifies about newly added issues.
- Status Updates: Notifies when the status of an issue changes.
- Comments: Notifies when a comment is added to an issue.
- Delayed Notifications: Collects notifications during non-working hours and sends them during working hours.
- Work Time Check: Verifies if the current time falls within working hours.
- Holidays: Integrates with Google Calendar to check for holidays.
- Date Formatting: Formats the current date and time for consistent logging.
- Error Handling: Logs errors with timestamps.
Feel free to contribute, fork, or suggest improvements. Your feedback is valuable in making this bot more efficient and user-friendly. For further assistance or to report issues, please contact via Telegram: @danek_kulikov
For a full explanation of the code and more detailed instructions, please refer to each file's comments and functions within the codebase.