config

package
v0.0.0-...-76a9b92 Latest Latest
Warning

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

Go to latest
Published: May 4, 2021 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ConfigPath = "config.json"

Functions

func GetLogLevel

func GetLogLevel(level string) []logrus.Level

GetLogLevel 获取日志等级

可能的值有

"trace","debug","info","warn","warn","error"

func InitDefaultCronJobConf

func InitDefaultCronJobConf()

Types

type CronJobConfig

type CronJobConfig struct {
	Cron []*CronMessage `json:"cron_config"`
}

func LoadCron

func LoadCron() *CronJobConfig

func (CronJobConfig) Save

func (c CronJobConfig) Save(p string) error

type CronMessage

type CronMessage struct {
	Cron       string `json:"cron"`
	ToUserName string `json:"to_user_name"`
	TextMsg    string `json:"text_msg"`
}

type JsonConfig

type JsonConfig struct {
	Phone               string     `json:"phone_number"`
	Password            string     `json:"password"`
	AppID               string     `json:"appid"`
	AppHash             string     `json:"app_hash"`
	UseMessageDatabase  bool       `json:"use_message_database"`
	UseFileDatabase     bool       `json:"use_file_database"`
	UseChatInfoDatabase bool       `json:"use_chat_info_database"`
	UseTestDataCenter   bool       `json:"use_test_data_center"`
	DatabaseDirectory   string     `json:"database_directory"`
	FileDirectory       string     `json:"file_directory"`
	IgnoreFileNames     bool       `json:"ignore_file_name"`
	Proxy               *Proxy     `json:"proxy"`
	WebHook             []*WebHook `json:"webhook"`
	WebApi              *WebApi    `json:"webapi"`
}

func DefaultConfig

func DefaultConfig() *JsonConfig

func Load

func Load(p string) *JsonConfig

func (*JsonConfig) Save

func (c *JsonConfig) Save(p string) error

type LocalHook

type LocalHook struct {
	// contains filtered or unexported fields
}

LocalHook logrus本地钩子

func NewLocalHook

func NewLocalHook(args interface{}, formatter logrus.Formatter, levels ...logrus.Level) *LocalHook

NewLocalHook 初始化本地日志钩子实现

func (*LocalHook) Fire

func (hook *LocalHook) Fire(entry *logrus.Entry) error

Fire ref: logrus/hooks.go impl Hook interface

func (*LocalHook) Levels

func (hook *LocalHook) Levels() []logrus.Level

Levels ref: logrus/hooks.go impl Hook interface

func (*LocalHook) SetFormatter

func (hook *LocalHook) SetFormatter(formatter logrus.Formatter)

SetFormatter 设置日志格式

func (*LocalHook) SetPath

func (hook *LocalHook) SetPath(path string)

SetPath 设置日志写入路径

func (*LocalHook) SetWriter

func (hook *LocalHook) SetWriter(writer io.Writer)

SetWriter 设置Writer

type Proxy

type Proxy struct {
	ProxyStatus bool   `json:"status"` //开关
	ProxyType   string `json:"type"`   // "HTTP",HTTPS,Socks5、MtProto
	ProxyAddr   string `json:"addr"`   // 10.0.0.1
	ProxyPort   string `json:"port"`   // 1234
	ProxyUser   string `json:"user"`   // user
	ProxyPasswd string `json:"passwd"` //passwd
}

type WebApi

type WebApi struct {
	WebApiStatus bool   `json:"status"`    //开关
	WebApiHost   string `json:"bind_addr"` //绑定地址
	WebApiPort   string `json:"port"`      //api端口地址
	WebApiToken  string `json:"token"`     //简易的api鉴权参数
}

api

type WebHook

type WebHook struct {
	WebHookStatus bool           `json:"status"`        //开关
	WebHookUrl    string         `json:"http_post_url"` //post推送地址
	WebHookSecret string         `json:"secret"`        //推送签名校验用的secret
	WebHookFilter *WebHookFilter `json:"filter"`        //过滤仅这些用户推送
}

webhook

type WebHookFilter

type WebHookFilter struct {
	FilterStatus bool     `json:"status"` //开关
	FilterNames  []string `json:"names"`  //过滤的用户名们
}

Jump to

Keyboard shortcuts

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