https://github.com/winstxnhdw/telefy
A generic notification API server for Telegram.
https://github.com/winstxnhdw/telefy
bun cloudflare-workers elysiajs grammyjs
Last synced: about 1 month ago
JSON representation
A generic notification API server for Telegram.
- Host: GitHub
- URL: https://github.com/winstxnhdw/telefy
- Owner: winstxnhdw
- Created: 2025-01-23T11:46:36.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2025-10-07T21:03:26.000Z (9 months ago)
- Last Synced: 2025-10-07T23:21:47.590Z (9 months ago)
- Topics: bun, cloudflare-workers, elysiajs, grammyjs
- Language: TypeScript
- Homepage:
- Size: 450 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# telefy
[](https://github.com/winstxnhdw/telefy/actions/workflows/main.yml)
[](https://github.com/winstxnhdw/telefy/actions/workflows/deploy.yml)
[](https://github.com/winstxnhdw/telefy/actions/workflows/formatter.yml)
`telefy` is a Cloudflare Worker that submits generic notifications to the Telegram API.
## Usage
`POST` **`/`** `(send notification)`
### Request Headers
> | name | type | description |
> | ------------- | -------- | --------------------------------- |
> | Authorization | required | `AUTH_TOKEN` environment variable |
### Parameters
#### NotificationSchema
> | name | type | data type | description |
> | ----------- | -------- | ---------------| ----------------------------- |
> | subject | required | `string` | notification subject |
> | body | required | `string` | notification body |
> | attachments | optional | `File[]` | array of files to attach |
### Responses
> | http code | content-type | reason |
> | --------- | ------------ | ------------------------------- |
> | `200` | `text/plain` | notification sent successfully |
> | `400` | `text/plain` | invalid request body |
> | `401` | `text/plain` | invalid authentication token |
### Example cURL
> ```bash
> curl $TELEFY_ENDPOINT
> -H "Authorization: Bearer $AUTH_TOKEN" \
> -F "subject=Title" \
> -F "body=This is the body of the notification." \
> -F "attachments=@/path/to/file1" \
> -F "attachments=@/path/to/file2"
> ```
### Example AIOHTTP
> ```python
> async with ClientSession(headers={'Authorization': f'Bearer {env["AUTH_TOKEN"]}'}) as session:
> form_data = FormData()
> form_data.add_field('subject', 'Hello World')
> form_data.add_field('body', 'This is the body of the notification.')
> form_data.add_field('attachments', image, filename='image.jpg', content_type='image/jpeg')
>
> async with session.post(env['TELEFY_ENDPOINT'], data=form_data) as response:
> response.raise_for_status()
> ```
### Example HTTPX
> ```python
> async with AsyncClient() as client:
> await client.post(env['TELEFY_ENDPOINT'],
> headers={"Authorization": f"Bearer {env['AUTH_TOKEN']}"},
> data={"subject": "Hello World", "body": "This is the body of the notification."},
> files=[("attachments", ("image.jpg", image, "image/jpeg"))],
> )
> ```
## Setup
Populate the following environment variables in your Cloudflare Worker
```bash
{
echo "AUTH_TOKEN=$AUTH_TOKEN"
echo "TELEGRAM_BOT_TOKEN=$TELEGRAM_BOT_TOKEN"
echo "TELEGRAM_CHAT_ID=$TELEGRAM_CHAT_ID"
} > .dev.vars
```
## Development
Install all dependencies.
```bash
bun install
```
Run the development server.
```bash
bun dev
```