{"id":28318389,"url":"https://github.com/iu2frl/pistar-lastheard-telegram","last_synced_at":"2025-10-11T22:05:07.197Z","repository":{"id":291810271,"uuid":"978695124","full_name":"iu2frl/pistar-lastheard-telegram","owner":"iu2frl","description":"Telegram bot to monitor the last transmissions of a Pi-Star gateway","archived":false,"fork":false,"pushed_at":"2025-05-10T06:23:34.000Z","size":28,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-06-24T17:45:46.276Z","etag":null,"topics":["d-star","dstar","mmdvm","pi-star","pistar","python","raspberry"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/iu2frl.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-05-06T11:27:56.000Z","updated_at":"2025-05-10T06:23:37.000Z","dependencies_parsed_at":"2025-05-06T17:38:19.964Z","dependency_job_id":null,"html_url":"https://github.com/iu2frl/pistar-lastheard-telegram","commit_stats":null,"previous_names":["iu2frl/pistar-lastheard-telegram"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/iu2frl/pistar-lastheard-telegram","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iu2frl%2Fpistar-lastheard-telegram","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iu2frl%2Fpistar-lastheard-telegram/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iu2frl%2Fpistar-lastheard-telegram/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iu2frl%2Fpistar-lastheard-telegram/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/iu2frl","download_url":"https://codeload.github.com/iu2frl/pistar-lastheard-telegram/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iu2frl%2Fpistar-lastheard-telegram/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279009026,"owners_count":26084547,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-11T02:00:06.511Z","response_time":55,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["d-star","dstar","mmdvm","pi-star","pistar","python","raspberry"],"created_at":"2025-05-25T07:12:33.300Z","updated_at":"2025-10-11T22:05:07.192Z","avatar_url":"https://github.com/iu2frl.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Pi-Star Last Heard Telegram Bot\n\nThis project is a Python-based Telegram bot that monitors DStar logs and sends updates to a specified Telegram chat. It uses the `python-telegram-bot` library to interact with Telegram and parses DStar log files to extract relevant information.\n\n## Features\n\n- Monitors DStar log files for new entries.\n- Parses log entries and formats them into readable messages.\n- Sends updates to a Telegram chat using a bot.\n- Configurable via environment variables.\n\n## Prerequisites\n\n- Python 3.7 or higher\n- A Telegram bot token (create one using [BotFather](https://core.telegram.org/bots#botfather)).\n- A Telegram chat ID where the bot will send messages.\n- Access to the DStar log files on your Pi-Star system.\n\n## Preparation\n\n1. Clone the repository to your Pi-Star system:\n\n```bash\ngit clone https://github.com/iu2frl/pistar-lastheard-telegram\ncd pistar-lastheard-telegram\n```\n\n2. Create a `.env` file in the project directory and add the following environment variables:\n\n```env\n# Telegram bot token\nTG_BOTTOKEN=\u003cyour-telegram-bot-token\u003e\n# Target chat where to send messages\nTG_CHATID=\u003cyour-telegram-chat-id\u003e\n# Address of the RP2C device\nGW_ADDRESS=172.16.0.1\n# Ignore the time server messages?\nGW_IGNORE_TIME_MESSAGES = True\n```\n\n## Usage\n\nThe bot can be launched using the following command:\n\n```bash\n./main.sh\n```\n\nThe script will:\n- Create and activate a virtual environment (if not already created).\n- Install the required dependencies.\n- Start the bot and monitor the DStar logs.\n\n## Automatic execution\n\nTo run the script at boot, add an entry in cron:\n\n```bash\n@reboot cd /home/pi-star/lastheard \u0026\u0026 ./main.sh \u003e /tmp/lastheard.txt 2\u003e\u00261\n```\n\n## File Structure\n\n- `main.py`: The main script that contains the bot logic and log monitoring functionality.\n- `main.sh`: A shell script to set up the environment and run the bot.\n- `requirements.txt`: A list of Python dependencies required for the project.\n\n## How It Works\n\n1. **Log Monitoring**:  \n    The bot reads the latest DStar log file and extracts the last line. It parses the log line using a regex pattern to extract fields like timestamp, callsigns, and repeaters.\n\n2. **Telegram Integration**:  \n    The bot formats the parsed log entry into an HTML message and sends it to the specified Telegram chat using the `python-telegram-bot` library.\n\n3. **Environment Variables**:  \n    The bot uses environment variables (`TG_BOTTOKEN` and `TG_CHATID`) to configure the Telegram bot token and chat ID.\n\n## Dependencies\n\n\u003e [!TIP]\n\u003e If using the `main.sh` script, all dependencies and virtual environment are created automatically\n\nThe project requires the following Python libraries:\n- `python-telegram-bot`: For interacting with the Telegram Bot API.\n- `dotenv`: For loading environment variables from a `.env` file.\n\nInstall them using:\n\n```bash\npip install -r requirements.txt\n```\n\n## Tips when running on Pi-Star\n\nAs Pi-Star starts the device in read-only mode, I suggest commenting out the `pip install ...` line in `main.sh` to avoid errors due to read-only mode\n\n## Logging\n\nThe bot uses Python's `logging` module to log events and errors. Logs are displayed in the console for easy debugging.\n\n## Contributing\n\nFeel free to submit issues or pull requests to improve the project.\n\n## License\n\nThis project is licensed under the GNU GPL v3 License. See the `LICENSE` file for details.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fiu2frl%2Fpistar-lastheard-telegram","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fiu2frl%2Fpistar-lastheard-telegram","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fiu2frl%2Fpistar-lastheard-telegram/lists"}