groups

package
v0.0.0-...-eca5cb0 Latest Latest
Warning

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

Go to latest
Published: May 12, 2020 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BoltDB

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

BoltDB implements store to put and get groups with specific alias

func NewBoltDB

func NewBoltDB(fileName string, opts bolt.Options) (*BoltDB, error)

NewBoltDB creates new groupbot store

func (*BoltDB) AddChat

func (b *BoltDB) AddChat(id string) error

AddChat creates a chat bucket in the storage

func (*BoltDB) AddUser

func (b *BoltDB) AddUser(chatID string, alias string, user string) error

AddUser adds user to the specified group

func (*BoltDB) DeleteGroup

func (b *BoltDB) DeleteGroup(chatID string, alias string) error

DeleteGroup removes group from the database by given chatID

func (*BoltDB) DeleteUserFromGroup

func (b *BoltDB) DeleteUserFromGroup(chatID string, alias string, user string) error

DeleteUserFromGroup removes user from the group

func (*BoltDB) FindAliases

func (b *BoltDB) FindAliases(chatID string, aliases []string) ([]string, error)

FindAliases looks for group aliases in the database and returns members of groups if group alias is present

func (*BoltDB) GetGroup

func (b *BoltDB) GetGroup(chatID string, alias string) ([]string, error)

GetGroup returns all users of the single group

func (*BoltDB) GetGroups

func (b *BoltDB) GetGroups(chatID string) (map[string][]string, error)

GetGroups returns the list of groups by chatID in form map[group_alias][]users

func (*BoltDB) PutGroup

func (b *BoltDB) PutGroup(chatID string, alias string, users []string) error

PutGroup creates a new group in the database with specified users

type MockStore

type MockStore struct {
	mock.Mock
}

MockStore is an autogenerated mock type for the Store type

func (*MockStore) AddChat

func (_m *MockStore) AddChat(id string) error

AddChat provides a mock function with given fields: id

func (*MockStore) AddUser

func (_m *MockStore) AddUser(chatID string, alias string, user string) error

AddUser provides a mock function with given fields: chatID, alias, user

func (*MockStore) DeleteGroup

func (_m *MockStore) DeleteGroup(chatID string, alias string) error

DeleteGroup provides a mock function with given fields: chatID, alias

func (*MockStore) DeleteUserFromGroup

func (_m *MockStore) DeleteUserFromGroup(chatID string, alias string, user string) error

DeleteUserFromGroup provides a mock function with given fields: chatID, alias, user

func (*MockStore) FindAliases

func (_m *MockStore) FindAliases(chatID string, aliases []string) ([]string, error)

FindAliases provides a mock function with given fields: chatID, aliases

func (*MockStore) GetGroup

func (_m *MockStore) GetGroup(chatID string, alias string) ([]string, error)

GetGroup provides a mock function with given fields: chatID, alias

func (*MockStore) GetGroups

func (_m *MockStore) GetGroups(chatID string) (map[string][]string, error)

GetGroups provides a mock function with given fields: chatID

func (*MockStore) PutGroup

func (_m *MockStore) PutGroup(chatID string, alias string, users []string) error

PutGroup provides a mock function with given fields: chatID, alias, users

type Store

type Store interface {
	PutGroup(chatID string, alias string, users []string) (err error)
	AddUser(chatID string, alias string, user string) (err error)
	GetGroup(chatID string, alias string) (users []string, err error)
	GetGroups(chatID string) (groups map[string][]string, err error)
	DeleteUserFromGroup(chatID string, alias string, user string) (err error)
	DeleteGroup(chatID string, alias string) (err error)
	FindAliases(chatID string, aliases []string) (users []string, err error)
	AddChat(id string) (err error)
}

Store defines methods to store and fetch user groups

Jump to

Keyboard shortcuts

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