aad / telgraf
Installs: 0
Dependents: 0
Suggesters: 0
Security: 0
Stars: 6
Watchers: 2
Forks: 3
Open Issues: 0
Type:project
Requires
- ext-json: *
- monolog/monolog: ^2.2
- ramsey/uuid: ^4.1
- respect/validation: ^2.2
Requires (Dev)
- swoole/ide-helper: @dev
This package is auto-updated.
Last update: 2024-11-10 19:35:45 UTC
README
Simple live support server with PHP Swoole Websocket and Telegram API.
Usage
Server Setup
- Clone repository with following command.
git clone https://github.com/ademalidurmus/telgraf.git
- Enter project folder with
cd telgraf
command. - Update initial credentials (BOT_TOKEN, APP_SECRET and APP_CHAT_IDS) from
.env.example
file via any text editor. - You can use some makefile commands for configurations. Makefile commands like make [COMMAND], for details you can run
make help
.- Use
make env
command for create environment file.You need update initial credentials from
.env.example
file before using makefile commands. If you were runmake .env
command, you may need update.env
and.env.example
files at the same times. - Run
make build
for building telgraf application. This command also runcomposer install
for dependency installation and serves the application. - If you are already built app, and you need just serve app you can run
make up
. For restart app server you can runmake restart
, for stop app server you can also runmake stop
. - For access to cli or container bash you can run
make cli
. make status
command is shows containers status likedocker ps
. If you want to show telgraf logs you can usemake logs
command.make set_webhook
command setting telegram bot webhook using defined environments.make delete_webhook
command delete telegram bot webhook using defined environments.make clean
command stops telgraf server, delete.env
file and clear all log files.
- Use
Telegram Bot Commands
/start
command is for the starting agent session to accept any client connections./stop
command is for the stopping agent session./close
command is for the stopping current client connection. The agent will continue to wait for any connection./add [CHAT_ID]
command is used to add a new agent to the agent access control list./remove [CHAT_ID]
command for removing the agent from the agent access control list.
API Docs
wss://{your_webserver_url}
type
: enum(message|info), action typecontent
: string, message text or action detailsattributes
: object, message attributesattributes.name
: string, client name
Sample websocket message history:
❌ Disconnected from wss://telgraf.durmus.me
⬇️ {"type":"info","content":"connection unassigned","attributes":[]}
⬆️ {"type":"message","content":"Test Client Message 2","attributes":{"name":"Client 1"}}
⬇️ {"type":"message","content":"Test Message 2","attributes":{"name":"Adem Ali D."}}
⬆️ {"type":"message","content":"Test Client Message 1","attributes":{"name":"Client 1"}}
⬇️ {"type":"message","content":"Test Message 1","attributes":{"name":"Adem Ali D."}}
⬇️ {"type":"info","content":"connection assigned","attributes":[]}
✔️ Connected to wss://telgraf.durmus.me
License
MIT