Documentation ¶
Index ¶
- Constants
- Variables
- func Atoi(s string) (int64, error)
- func EscapeText(parseMode string, text string) string
- func GetBytes(url string) ([]byte, error)
- func HTTPGetReadCloser(url string) (io.ReadCloser, error)
- func Itoa(i int64) string
- func NewGzipReadCloser(reader io.ReadCloser) (io.ReadCloser, error)
- func NextRandom() string
- func Respond(w http.ResponseWriter, data any) error
- func Uint32() uint32
- type AppData
- type ArchiveChat
- type BlobData
- type Chat
- type Configure
- type ErrorResponse
- type EventType
- type KeyMutex
- type Limb
- type LocationData
- type MessageChan
- type MessageType
- type OctopusEvent
- type OctopusMessage
- type OctopusRequest
- type OctopusResponse
- type ReplyInfo
- type RequestType
- type ResponseType
- type User
- type Vendor
Constants ¶
View Source
const ( VENDOR_SEP = ";" REMOTE_PREFIX = "remote:" )
Variables ¶
View Source
var (
UserAgent = "" /* 130-byte string literal not displayed */
)
Functions ¶
func EscapeText ¶
func HTTPGetReadCloser ¶
func HTTPGetReadCloser(url string) (io.ReadCloser, error)
func NewGzipReadCloser ¶
func NewGzipReadCloser(reader io.ReadCloser) (io.ReadCloser, error)
func NextRandom ¶
func NextRandom() string
Types ¶
type ArchiveChat ¶
type BlobData ¶
type Configure ¶
type Configure struct { Master struct { APIURL string `yaml:"api_url"` LocalMode bool `yaml:"local_mode"` AdminID int64 `yaml:"admin_id"` Token string `yaml:"token"` Proxy string `yaml:"proxy"` PageSize int `yaml:"page_size"` Archive []ArchiveChat `yaml:"archive"` Telegraph struct { Enable bool `ymal:"enable"` Proxy string `yaml:"proxy"` Tokens []string `yaml:"tokens"` } `yaml:"telegraph"` } `yaml:"master"` Service struct { Addr string `yaml:"addr"` Secret string `yaml:"secret"` SendTiemout time.Duration `yaml:"send_timeout"` } `yaml:"service"` Log struct { Level string `yaml:"level"` } `yaml:"log"` }
func LoadConfig ¶
type ErrorResponse ¶
type ErrorResponse struct { HTTPStatus int `json:"-"` Code string `json:"code"` Message string `json:"message"` }
func (*ErrorResponse) Error ¶
func (er *ErrorResponse) Error() string
func (ErrorResponse) Write ¶
func (er ErrorResponse) Write(w http.ResponseWriter)
type KeyMutex ¶
type KeyMutex interface { // Acquires a lock associated with the specified ID, creates the lock if one doesn't already exist. LockKey(id string) // Releases the lock associated with the specified ID. // Returns an error if the specified ID doesn't exist. UnlockKey(id string) error }
KeyMutex is a thread-safe interface for acquiring locks on arbitrary strings.
func NewHashed ¶
NewHashed returns a new instance of KeyMutex which hashes arbitrary keys to a fixed set of locks. `n` specifies number of locks, if n <= 0, we use number of cpus. Note that because it uses fixed set of locks, different keys may share same lock, so it's possible to wait on same lock.
type Limb ¶
func LimbFromString ¶
type LocationData ¶
type MessageChan ¶
type MessageChan struct {
// contains filtered or unexported fields
}
unbounded channel
func NewMessageChan ¶
func NewMessageChan(capacity int) *MessageChan
func (*MessageChan) In ¶
func (ch *MessageChan) In() chan<- *OctopusEvent
func (*MessageChan) Out ¶
func (ch *MessageChan) Out() <-chan *OctopusEvent
type MessageType ¶
type MessageType int
const ( MsgRequest MessageType = iota MsgResponse )
func (MessageType) String ¶
func (t MessageType) String() string
type OctopusEvent ¶
type OctopusEvent struct { Vendor Vendor `json:"vendor,omitempty"` ID string `json:"id,omitempty"` ThreadID string `json:"thread_id,omitempty"` Timestamp int64 `json:"timestamp,omitempty"` From User `json:"from,omitempty"` Chat Chat `json:"chat,omitempty"` Type EventType `json:"type,omitempty"` Content string `json:"content,omitempty"` Reply *ReplyInfo `json:"reply,omitempty"` Data any `json:"data,omitempty"` Callback func(*OctopusEvent, error) `json:"-"` }
func (*OctopusEvent) UnmarshalJSON ¶
func (o *OctopusEvent) UnmarshalJSON(data []byte) error
type OctopusMessage ¶
type OctopusMessage struct { ID int64 `json:"id,omitempty"` Type MessageType `json:"type,omitempty"` Data any `json:"data,omitempty"` }
func (*OctopusMessage) UnmarshalJSON ¶
func (o *OctopusMessage) UnmarshalJSON(data []byte) error
type OctopusRequest ¶
type OctopusRequest struct { Type RequestType `json:"type,omitempty"` Data any `json:"data,omitempty"` }
func (*OctopusRequest) UnmarshalJSON ¶
func (o *OctopusRequest) UnmarshalJSON(data []byte) error
type OctopusResponse ¶
type OctopusResponse struct { Type ResponseType `json:"type,omitempty"` Error *ErrorResponse `json:"error,omitempty"` Data any `json:"data,omitempty"` }
func (*OctopusResponse) UnmarshalJSON ¶
func (o *OctopusResponse) UnmarshalJSON(data []byte) error
type RequestType ¶
type RequestType int
const ( ReqDisconnect RequestType = iota ReqPing ReqEvent )
func (RequestType) String ¶
func (t RequestType) String() string
type ResponseType ¶
type ResponseType int
const ( RespClosed ResponseType = iota RespPing RespEvent )
func (ResponseType) String ¶
func (t ResponseType) String() string
Click to show internal directories.
Click to hide internal directories.