config

package
v0.2.0-alpha Latest Latest
Warning

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

Go to latest
Published: Sep 5, 2022 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RoomConfigInitialUpdate

func RoomConfigInitialUpdate(ids []id.RoomID, parentCtx context.Context)

RoomConfigInitialUpdate updates all RoomConfig entries to set activity and create blank configs

func SaveRoomConfig

func SaveRoomConfig(roomConfig *RoomConfig) error

func SetRoomConfigActive

func SetRoomConfigActive(id string, active bool)

SetRoomConfigActive updates the active state for a given room

Types

type HashCheckerConfig

type HashCheckerConfig struct {
	// NoticeToChat specifies weather or not to post a public notice to chat
	NoticeToChat bool `bson:"chat_notice"`

	// NotificationPowerLevel is currently unused
	NotificationPowerLevel int `yaml:"notification_level" bson:"notification_level"`

	/*
		HashCheckMode specifies the mode the bot should operate under in this room

		HashCheck-Modes:
		 0. Notice Mode (Post notice)
		 1. Delete Mode (Remove message, post notice)
		 2. Mute Mode (Remove message, post notice & mute user)
		 3. Ban Mode (Remove message, post notice & ban user)
	*/
	HashCheckMode uint8 `yaml:"mode" bson:"hash_check_mode"`

	// SubscribedLists contains the lists this room is subscribed to
	SubscribedLists []*primitive.ObjectID `bson:"subscribed_lists" json:"subscribed_lists"`
}

type RoomConfig

type RoomConfig struct {
	ID primitive.ObjectID `bson:"_id"`

	// Active tells if the bot is active in this room (Set to false on leave/kick/ban)
	Active bool `yaml:"active" bson:"active"`

	// Deactivate can be set by an admin to disable the bot for a room
	Deactivate bool `yaml:"deactivate" bson:"deactivate"`

	// Name is fetched regularly from the room state
	Name string `yaml:"name" bson:"name"`

	// RoomID is the rooms ID
	RoomID string `yaml:"roomID" bson:"room_id"`

	// Debug specifies if the bot shall run in dry run mode
	Debug bool `yaml:"debug" bson:"debug"`

	// AlertChannel is currently unused
	AlertChannel *string `bson:"alert_channel"`

	// AdminPowerLevel specifies the power-level a user has to have to manage the room
	AdminPowerLevel int `bson:"admin_power_level"`

	// HashChecker contains configuration specific to the hash-checker
	HashChecker HashCheckerConfig `bson:"hash_checker"`

	Admins []string `bson:"admins"`
}

RoomConfig is the configuration attached to every joined room

func AddRoomConfig

func AddRoomConfig(id string) RoomConfig

func GetDefaultRoomConfig

func GetDefaultRoomConfig() RoomConfig

func GetRoomConfig

func GetRoomConfig(id string) RoomConfig

GetRoomConfig returns the RoomConfig linked to the specified ID

func GetRoomConfigByObjectID

func GetRoomConfigByObjectID(id primitive.ObjectID) (*RoomConfig, error)

func GetRoomConfigByRoomID

func GetRoomConfigByRoomID(id string) (*RoomConfig, error)

type RoomConfigTree

type RoomConfigTree map[string]RoomConfig

RoomConfigTree is a map from string to RoomConfig

Jump to

Keyboard shortcuts

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