echo

package module
v1.3.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 10, 2022 License: Apache-2.0 Imports: 8 Imported by: 0

README

echo

Send log to Mixin Messenger Groups.

How to use Echo?

Config Scanner

1. Download echo binary
2. Get Token
  • Create a new group in Mixin Messenger
  • add echo bot to it
  • copy the token.
3. Config echo

write a .env file

SCANNER_TOKEN_INFO=YOUR_TOKEN_TO_SEND_INFO_LOG
SCANNER_TOKEN_ERROR=YOUR_TOKEN_TO_SEND_ERROR_LOG
SCANNER_TOKEN_WARNING=YOUR_TOKEN_TO_SEND_WARNING_LOG

add echo as a service

[Unit]
Description=Scanner Service
After=network.target

[Service]
Type=simple
User=YOUR_NAME
Restart=on-failure
RestartSec=1s
EnvironmentFile=YOUR_ENV_FILE_PATH
ExecStart=/YOUR_ECHO_FILE_PATH/scanner --format post --cmd '["/bin/journalctl","-u","THE_SERVICE_YOU_WANNA_WATCH","-f","-o","cat"]'

[Install]
WantedBy=multi-user.target
4. Done
  • use github.com/sirupsen/logrus and enable json log format in your service.
  • restart all services

Config Echo Server

Blaze

接收入群消息,然后自动发 token 给拉机器人进群的人

Server
POST https://echo.yiplee.com/message

Header:

Authorization: Bearer access_token

Params:

{
   "category": "Plain_Text",
   "data": "base64 msg data"
}
Rate Limit

一分钟一百个请求

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Endpoint = "https://echo.fox.one"

Functions

func Execute added in v1.1.1

func Execute(ctx context.Context, method, uri string, body interface{}) ([]byte, error)

Execute execute a request

func Get added in v1.1.1

func Get(ctx context.Context, uri string) ([]byte, error)

Get execute a get request

func ParseToken

func ParseToken(token string, sessionID string) (string, error)

ParseToken parse the jwt token

func SendMessage added in v1.1.1

func SendMessage(ctx context.Context, token string, payload Payload) error

SendMessage send a message

func SignToken

func SignToken(userID, sessionID, conversationID string) (string, error)

SignToken sign a jwt token

Types

type Payload added in v1.1.0

type Payload struct {
	MessageID   string `json:"message_id,omitempty"`
	RecipientID string `json:"recipient_id,omitempty"`
	Category    string `json:"category,omitempty"`
	Data        string `json:"data,omitempty"`
}

Payload represent message content leave RecipientID empty to broadcast

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL