chatbotbase

package
v0.6.5 Latest Latest
Warning

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

Go to latest
Published: Sep 21, 2020 License: Apache-2.0 Imports: 21 Imported by: 2

Documentation

Overview

Package chatbotbase is a generated GoMock package.

Index

Constants

View Source
const BigMsgLength = 4*1024*1024 - 1024

BigMsgLength -if msg length >= BigMsgLength, the message is big message

View Source
const VERSION = "0.6.5"

VERSION - charlescore version

Variables

View Source
var (
	// ErrNoAppServType - no app serv type
	ErrNoAppServType = errors.New("no app serv type")
	// ErrNoAppServToken - no app serv token
	ErrNoAppServToken = errors.New("no app serv token")
	// ErrNoAppServUserName - no app serv username
	ErrNoAppServUserName = errors.New("no app serv username")

	// ErrNoBindAddr - no bindaddr
	ErrNoBindAddr = errors.New("no bindaddr")
	// ErrNoDBPath - no dbpath
	ErrNoDBPath = errors.New("no dbpath")
	// ErrNoDBEngine - no dbengine
	ErrNoDBEngine = errors.New("no dbengine")

	// ErrNoConfig - no config
	ErrNoConfig = errors.New("no config")

	// ErrInvalidAppServType - invalid appservtype
	ErrInvalidAppServType = errors.New("invalid appservtype")
	// ErrInvalidAppServToken - invalid appservtoken
	ErrInvalidAppServToken = errors.New("invalid appservtoken")
	// ErrInvalidAppServUserName - invalid appservusername
	ErrInvalidAppServUserName = errors.New("invalid appservusername")

	// ErrNoServAddrInClient - no servaddr in client
	ErrNoServAddrInClient = errors.New("no servaddr in client")
	// ErrNoTokenInClient - no token in client
	ErrNoTokenInClient = errors.New("no token in client")

	// ErrDuplicatePlugin - duplicate plugin
	ErrDuplicatePlugin = errors.New("duplicate plugin")
	// ErrNoPlugin - no plugin
	ErrNoPlugin = errors.New("no plugin")
	// ErrPluginInvalidServ - invalid serv in plugin
	ErrPluginInvalidServ = errors.New("invalid serv in plugin")
	// ErrPluginInvalidServMgrText - invalid serv.MgrText in plugin
	ErrPluginInvalidServMgrText = errors.New("invalid serv.MgrText in plugin")
	// ErrPluginItsNotMine - It's not mine
	ErrPluginItsNotMine = errors.New("Plugin: It's not mine")

	// ErrNoAppServDB - no appserv database
	ErrNoAppServDB = errors.New("no appserv database")
	// ErrInvalidTokenInAppServDB - invalid token in appserv database
	ErrInvalidTokenInAppServDB = errors.New("invalid token in appserv database")

	// ErrNoServAddr - no servaddr
	ErrNoServAddr = errors.New("no servaddr")
	// ErrNoToken - no token
	ErrNoToken = errors.New("no token")
	// ErrNoUsername - no username
	ErrNoUsername = errors.New("no username")
	// ErrNoTelegramToken - no telegramtoken
	ErrNoTelegramToken = errors.New("no telegramtoken")

	// ErrNoCoolQServURL - no coolq servurl
	ErrNoCoolQServURL = errors.New("no coolq servurl")
	// ErrNoCoolQHttpServAddr - no servaddr
	ErrNoCoolQHttpServAddr = errors.New("no coolq http servaddr")

	// ErrStreamNoMsg - no chat in stream
	ErrStreamNoMsg = errors.New("no chat in stream")
	// ErrInvalidStartInStream - invalid start in stream
	ErrInvalidStartInStream = errors.New("invalid start in stream")
	// ErrInvalidLengthInStream - invalid length in stream
	ErrInvalidLengthInStream = errors.New("invalid length in stream")
	// ErrInvalidHashInStream - invalid hash in stream
	ErrInvalidHashInStream = errors.New("invalid hash in stream")
	// ErrInvalidTotalLengthInStream - invalid totalLength in stream
	ErrInvalidTotalLengthInStream = errors.New("invalid totalLength in stream")
	// ErrInvalidTotalHashInStream - invalid totalHash in stream
	ErrInvalidTotalHashInStream = errors.New("invalid totalHash in stream")
	// ErrInvalidStream - invalid chatstream
	ErrInvalidStream = errors.New("invalid chatstream")

	// ErrServInvalidErr - invalid error in serv
	ErrServInvalidErr = errors.New("invalid error in serv")
	// ErrServInvalidToken - invalid token in serv
	ErrServInvalidToken = errors.New("invalid token in serv")
	// ErrServInvalidUserInfo - invalid userinfo
	ErrServInvalidUserInfo = errors.New("invalid userinfo")

	// ErrCmdNoCmd - no command
	ErrCmdNoCmd = errors.New("no command")
	// ErrCmdEmptyCmd - empty command
	ErrCmdEmptyCmd = errors.New("empty command")
	// ErrCmdInvalidServ - invalid serv in command
	ErrCmdInvalidServ = errors.New("invalid serv in command")
	// ErrCmdInvalidServMgrText - invalid serv.MgrText in command
	ErrCmdInvalidServMgrText = errors.New("invalid serv.MgrText in command")
	// ErrCmdItsNotMine - It's not mine
	ErrCmdItsNotMine = errors.New("Command: It's not mine")

	// ErrUserMgrNoUserData - no userdata
	ErrUserMgrNoUserData = errors.New("no userdata")

	// ErrInvalidFileProcessorMgr - invalid FileProcessorMgr
	ErrInvalidFileProcessorMgr = errors.New("invalid FileProcessorMgr")

	// ErrNoteInvalidName - invalid note name
	ErrNoteInvalidName = errors.New("invalid note name")
	// ErrNoteNone - no note
	ErrNoteNone = errors.New("no note")

	// ErrUnkonow - unknow error
	ErrUnkonow = errors.New("unknow error")
)
View Source
var AppServTypeString []string

AppServTypeString - appserv type string

Functions

func AppendString

func AppendString(strs ...string) string

AppendString - append string

func BuildLogFilename

func BuildLogFilename(logtype string, subname string) string

BuildLogFilename -

func BuildLogSubFilename

func BuildLogSubFilename(appName string, version string) string

BuildLogSubFilename -

func BytesToInt64

func BytesToInt64(buf []byte) int64

BytesToInt64 - bytes -> int64

func CheckAppServConfig

func CheckAppServConfig(cfg *AppServConfig) error

CheckAppServConfig - check app service config

func ClearLogs

func ClearLogs() error

ClearLogs - clear logs

func Debug

func Debug(message string, fields ...zap.Field)

Debug logs a debug message with the given fields

func Error

func Error(message string, fields ...zap.Field)

Error logs a debug message with the given fields

func Fatal

func Fatal(message string, fields ...zap.Field)

Fatal logs a message than calls os.Exit(1)

func FormatCommand added in v0.2.25

func FormatCommand(str string) string

FormatCommand - format command, /start => start

func FormatFileSize added in v0.2.10

func FormatFileSize(s int64) string

FormatFileSize - format size to string

func FormatNow added in v0.6.5

func FormatNow(t ITime) string

FormatNow - format time

func GetAppServType

func GetAppServType(strType string) (chatbotpb.ChatAppType, error)

GetAppServType - strtype -> chatbotpb.ChatAppType

func GetCurTime

func GetCurTime() int64

GetCurTime - append string

func GetLogger added in v0.6.5

func GetLogger() *zap.Logger

GetLogger - get zap.Logger

func ID2Str added in v0.2.25

func ID2Str(id int) string

ID2Str - id -> string

func ID642Str added in v0.2.25

func ID642Str(id int64) string

ID642Str - id64 -> string

func IndexOfArrayString

func IndexOfArrayString(arr []string, str string) int

IndexOfArrayString - find a string in []string

func Info

func Info(message string, fields ...zap.Field)

Info logs a debug message with the given fields

func InitLogger

func InitLogger(logname string, appVersion string, level string, isConsole bool, logpath string)

InitLogger - initializes a thread-safe singleton logger

func Int64ToBytes

func Int64ToBytes(i int64) []byte

Int64ToBytes - int64 -> bytes

func JSON

func JSON(name string, jobj interface{}) zap.Field

JSON - It's like zap.String(name, str)

func JSONFormat

func JSONFormat(obj interface{}) (string, error)

JSONFormat - json format string

func MD5Buffer

func MD5Buffer(buf []byte) string

MD5Buffer - hash buffer

func ParseLogLevel added in v0.5.42

func ParseLogLevel(str string) zapcore.Level

ParseLogLevel - string to zapcore.Level

func RandString

func RandString(length int) (str string)

RandString - random a string

func SetLogger added in v0.6.5

func SetLogger(curLogger *zap.Logger) *zap.Logger

SetLogger - set zap.Logger, return last zap.Logger

func Str2ID added in v0.2.25

func Str2ID(str string) (int, error)

Str2ID - string -> id

func Str2ID64 added in v0.2.25

func Str2ID64(str string) (int64, error)

Str2ID64 - string -> id

func SyncLogger

func SyncLogger()

SyncLogger - sync logger

func Timestamp2Str

func Timestamp2Str(ts int64) string

Timestamp2Str - unix timestamp to string

func Warn

func Warn(message string, fields ...zap.Field)

Warn logs a debug message with the given fields

Types

type AppServConfig

type AppServConfig struct {
	Type     string
	Token    string
	UserName string
}

AppServConfig - app serv

func FindAppServConfig

func FindAppServConfig(token string, lst []AppServConfig) *AppServConfig

FindAppServConfig - find a app service config

type ITime added in v0.6.5

type ITime interface {
	// Now - get now time
	Now() time.Time
}

ITime - Time

type MockITime added in v0.6.5

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

MockITime is a mock of ITime interface

func NewMockITime added in v0.6.5

func NewMockITime(ctrl *gomock.Controller) *MockITime

NewMockITime creates a new mock instance

func (*MockITime) EXPECT added in v0.6.5

func (m *MockITime) EXPECT() *MockITimeMockRecorder

EXPECT returns an object that allows the caller to indicate expected use

func (*MockITime) Now added in v0.6.5

func (m *MockITime) Now() time.Time

Now mocks base method

type MockITimeMockRecorder added in v0.6.5

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

MockITimeMockRecorder is the mock recorder for MockITime

func (*MockITimeMockRecorder) Now added in v0.6.5

func (mr *MockITimeMockRecorder) Now() *gomock.Call

Now indicates an expected call of Now

type Time added in v0.6.5

type Time struct {
}

Time - default Time

func (Time) Now added in v0.6.5

func (t Time) Now() time.Time

Now - get now time

Jump to

Keyboard shortcuts

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