gypsum

package
Version: v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Mar 5, 2021 License: GPL-3.0 Imports: 46 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	BuildVersion = "0.0.0-unknown"
	BuildCommit  = "unknown"
)

Functions

func ChangeNameForParent added in v0.6.0

func ChangeNameForParent(parentID, selfID uint64, newName string) error

func DeleteFromParent added in v0.6.0

func DeleteFromParent(parentID, selfID uint64) error

func ExtractWebAssets added in v1.0.0

func ExtractWebAssets(extractPath string) error

func RestoreFromUserRecord added in v0.5.0

func RestoreFromUserRecord(itemType ItemType, itemBytes []byte, newParentID uint64) (uint64, error)

func UpdateGypsum added in v1.0.0

func UpdateGypsum(newVersion, mirror string, forcedUpdate bool, logger func(...interface{})) error

Types

type ArchiveItem added in v0.5.0

type ArchiveItem struct {
	ItemType    ItemType
	DisplayName string
	ItemBytes   []byte
}

type ConfigType added in v0.6.0

type ConfigType struct {
	Listen         string
	Password       string
	PasswordSalt   string
	ExternalAssets string
	ResourceShare  string
	HttpBackRef    string
}
var Config *ConfigType

func (*ConfigType) CheckValid added in v1.0.0

func (c *ConfigType) CheckValid() (changed bool, err error)

type Group added in v0.5.0

type Group struct {
	DisplayName   string `json:"display_name"`
	PluginName    string `json:"plugin_name"`
	PluginVersion int64  `json:"plugin_version"`
	Items         []Item `json:"items"`
	ParentGroup   uint64 `json:"-"`
}

func GroupFromArchiveReader added in v0.5.0

func GroupFromArchiveReader(reader io.Reader, newGroupID uint64) (*Group, error)

func GroupFromBytes added in v0.5.0

func GroupFromBytes(b []byte) (*Group, error)

func (Group) ExportToArchive added in v0.5.0

func (g Group) ExportToArchive(name string, version int64) *GroupArchive

func (*Group) GetDisplayName added in v0.6.0

func (g *Group) GetDisplayName() string

func (*Group) GetParentID added in v0.5.0

func (g *Group) GetParentID() uint64

func (*Group) NewParent added in v0.5.0

func (g *Group) NewParent(selfID, parentID uint64) error

func (*Group) SaveToDB added in v0.5.0

func (g *Group) SaveToDB(gid uint64) error

func (*Group) ToBytes added in v0.5.0

func (g *Group) ToBytes() ([]byte, error)

type GroupArchive added in v0.5.0

type GroupArchive struct {
	DisplayName   string
	PluginName    string
	PluginVersion int64
	GypsumVersion string
	GypsumCommit  string
	ArchiveItems  []ArchiveItem
}

func (*GroupArchive) ToBytes added in v0.5.0

func (g *GroupArchive) ToBytes() ([]byte, error)

type Item added in v0.5.0

type Item struct {
	ItemType    ItemType `json:"item_type"`
	DisplayName string   `json:"display_name"`
	ItemID      uint64   `json:"item_id"`
}

type ItemType added in v0.5.0

type ItemType string
const (
	RuleItem      ItemType = "rule"
	TriggerItem   ItemType = "trigger"
	SchedulerItem ItemType = "scheduler"
	ResourceItem  ItemType = "resource"
	GroupItem     ItemType = "group"
)

type MessageType added in v0.3.0

type MessageType uint32
const (
	FriendMessage MessageType = 1 << iota
	GroupTmpMessage
	OtherTmpMessage
	OfficialMessage
	GroupNormalMessage
	GroupAnonymousMessage
	GroupNoticeMessage
	DiscussMessage

	NoMessage      MessageType = 0
	AllMessage     MessageType = 0xffffffff
	PrivateMessage             = FriendMessage | GroupTmpMessage | OtherTmpMessage
	GroupMessage               = GroupNormalMessage | GroupAnonymousMessage | GroupNoticeMessage
)

type Resource added in v0.5.0

type Resource struct {
	FileName    string `json:"file_name"`
	Ext         string `json:"ext"`
	Sha256Sum   string `json:"sha256_sum"`
	ParentGroup uint64 `json:"-"`
}

func ResourceFromBytes added in v0.5.0

func ResourceFromBytes(b []byte) (*Resource, error)

func (*Resource) GetDisplayName added in v0.6.0

func (r *Resource) GetDisplayName() string

func (*Resource) GetParentID added in v0.5.0

func (r *Resource) GetParentID() uint64

func (*Resource) NewParent added in v0.5.0

func (r *Resource) NewParent(selfID, parentID uint64) error

func (*Resource) SaveToDB added in v0.5.0

func (r *Resource) SaveToDB(idx uint64) error

func (*Resource) ToBytes added in v0.5.0

func (r *Resource) ToBytes() ([]byte, error)

type Rule

type Rule struct {
	DisplayName string      `json:"display_name"`
	Active      bool        `json:"active"`
	MessageType MessageType `json:"message_type"`
	GroupsID    []int64     `json:"groups_id"`
	UsersID     []int64     `json:"users_id"`
	MatcherType RuleType    `json:"matcher_type"`
	Patterns    []string    `json:"patterns"`
	OnlyAtMe    bool        `json:"only_at_me"`
	Response    string      `json:"response"`
	Priority    int         `json:"priority"`
	Block       bool        `json:"block"`
	ParentGroup uint64      `json:"-"`
}

func RuleFromBytes

func RuleFromBytes(b []byte) (*Rule, error)

func (*Rule) GetDisplayName added in v0.6.0

func (r *Rule) GetDisplayName() string

func (*Rule) GetParentID added in v0.5.0

func (r *Rule) GetParentID() uint64

func (*Rule) NewParent added in v0.5.0

func (r *Rule) NewParent(selfID, parentID uint64) error

func (*Rule) Register

func (r *Rule) Register(id uint64) error

func (*Rule) SaveToDB added in v0.5.0

func (r *Rule) SaveToDB(idx uint64) error

func (*Rule) ToBytes

func (r *Rule) ToBytes() ([]byte, error)

type RuleType added in v0.2.0

type RuleType int
const (
	FullMatch RuleType = iota
	Keyword
	Prefix
	Suffix
	Command
	Regex
)

type ScheduledJob added in v1.0.2

type ScheduledJob struct {
	DisplayName string  `json:"display_name"`
	Active      bool    `json:"active"`
	GroupsID    []int64 `json:"groups_id"`
	UsersID     []int64 `json:"users_id"`
	Once        bool    `json:"once"`
	CronSpec    string  `json:"cron_spec"`
	Action      string  `json:"action"`
	ParentGroup uint64  `json:"-"`
}

func JobFromBytes added in v0.3.0

func JobFromBytes(b []byte) (*ScheduledJob, error)

func (*ScheduledJob) Executor added in v1.0.2

func (j *ScheduledJob) Executor() (func(), *uint64, error)

func (*ScheduledJob) GetDisplayName added in v1.0.2

func (j *ScheduledJob) GetDisplayName() string

func (*ScheduledJob) GetParentID added in v1.0.2

func (j *ScheduledJob) GetParentID() uint64

func (*ScheduledJob) NewParent added in v1.0.2

func (j *ScheduledJob) NewParent(selfID, parentID uint64) error

func (*ScheduledJob) Register added in v1.0.2

func (j *ScheduledJob) Register(id uint64) error

func (*ScheduledJob) SaveToDB added in v1.0.2

func (j *ScheduledJob) SaveToDB(idx uint64) error

func (*ScheduledJob) ToBytes added in v1.0.2

func (j *ScheduledJob) ToBytes() ([]byte, error)

type Trigger added in v0.2.0

type Trigger struct {
	DisplayName string   `json:"display_name"`
	Active      bool     `json:"active"`
	GroupsID    []int64  `json:"groups_id"`
	UsersID     []int64  `json:"users_id"`
	TriggerType []string `json:"trigger_type"`
	Response    string   `json:"response"`
	Priority    int      `json:"priority"`
	Block       bool     `json:"block"`
	ParentGroup uint64   `json:"-"`
}

func TriggerFromByte added in v0.2.0

func TriggerFromByte(b []byte) (*Trigger, error)

func (*Trigger) GetDisplayName added in v0.6.0

func (t *Trigger) GetDisplayName() string

func (*Trigger) GetParentID added in v0.5.0

func (t *Trigger) GetParentID() uint64

func (*Trigger) NewParent added in v0.5.0

func (t *Trigger) NewParent(selfID, parentID uint64) error

func (*Trigger) Register added in v0.2.0

func (t *Trigger) Register(id uint64) error

func (*Trigger) SaveToDB added in v0.5.0

func (t *Trigger) SaveToDB(idx uint64) error

func (*Trigger) ToBytes added in v0.2.0

func (t *Trigger) ToBytes() ([]byte, error)

type TriggerCategory added in v0.2.0

type TriggerCategory int

type UserRecord added in v0.5.0

type UserRecord interface {
	ToBytes() ([]byte, error)
	GetParentID() uint64
	GetDisplayName() string
	NewParent(selfID, parentID uint64) error
	SaveToDB(selfID uint64) error
}

Jump to

Keyboard shortcuts

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