db

package
v0.0.0-...-3eedb2d Latest Latest
Warning

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

Go to latest
Published: Mar 1, 2017 License: GPL-3.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddCensLevel

func AddCensLevel(user *tgbotapi.User) (currentLevel int, err error)

AddCensLevel added +1 to cens level in year

func AddWarnLevel

func AddWarnLevel(user *tgbotapi.User) (currentLevel int, err error)

AddWarnLevel added +1 to warning level for user

func AddedDateToCaches

func AddedDateToCaches(chatID int64, d time.Time)

AddedDateToCaches added date to caches

func ClearCensLevel

func ClearCensLevel(user *tgbotapi.User) (err error)

ClearCensLevel remove document from bucket

func ClearWarnLevel

func ClearWarnLevel(user *tgbotapi.User) (err error)

ClearWarnLevel remove document from bucket

func GetCensLevel

func GetCensLevel(user *tgbotapi.User) (currentLevel int, err error)

GetCensLevel function returns censore level for user

func GetChats

func GetChats() (chats []*tgbotapi.Chat, err error)

GetChats returns chat list

func GetDates

func GetDates(chatID int64, year int, month int) (result []int, err error)

GetDates function returns month list msg date from chat messages and year

func GetFile

func GetFile(fileID string, chatID int64) (f *tgbotapi.File, err error)

GetFile returns file json from couchbase

func GetMessages

func GetMessages(chatID int64) (messages []*tgbotapi.Message, err error)

GetMessages returns chat list

func GetMessagesByDate

func GetMessagesByDate(chatID int64, beginTime, endTime time.Time) (messages []*tgbotapi.Message, err error)

GetMessagesByDate returns chat list on date

func GetMonthList

func GetMonthList(chatID int64, year int) (result []time.Month, err error)

GetMonthList function returns month list msg date from chat messages and year

func GetUser

func GetUser(username string) (user *tgbotapi.User, err error)

GetUser get user by username or first and last name

func GetUsers

func GetUsers() (users []*tgbotapi.User, err error)

GetUsers returns chat list

func GetWarnLevel

func GetWarnLevel(user *tgbotapi.User) (currentLevel int, err error)

GetWarnLevel function returns warning level for user

func GetYears

func GetYears(chatID int64) (result []string, err error)

GetYears function returns years msg date from chat messages

func GoSaveMessage

func GoSaveMessage(msg *tgbotapi.Message)

GoSaveMessage is a shell method for goroutine SaveMessage

func InitCouchbase

func InitCouchbase(couchbaseCluster, couchbaseBucket, couchbaseSecret string)

InitCouchbase function initialize couchbase bucket with parameters

func SaveChat

func SaveChat(chat *tgbotapi.Chat, forward bool) (err error)

SaveChat method for save chat to database

func SaveFile

func SaveFile(file *tgbotapi.File, chatID int64) (err error)

SaveFile method save user to database

func SaveMessage

func SaveMessage(msg *tgbotapi.Message) (err error)

SaveMessage method save message to database

func SaveUser

func SaveUser(user *tgbotapi.User) (err error)

SaveUser method save user to database

func SetCensLevel

func SetCensLevel(user *tgbotapi.User, setlevel int) (err error)

SetCensLevel function sets level for user

func SetWarnLevel

func SetWarnLevel(user *tgbotapi.User, setlevel int) (err error)

SetWarnLevel function sets level for user

Types

type Cache

type Cache struct {
	Years        []string
	MonthsByYear map[int][]time.Month
	Days         map[string][]int
	// contains filtered or unexported fields
}

Cache is struct for store date caches

func CreateNewCache

func CreateNewCache() *Cache

CreateNewCache function create new Cache pointer

type Caches

type Caches map[int64]*Cache

Caches is a map cache to chat ID

type CensLevel

type CensLevel struct {
	ID    int `json:"user_id"`
	Level int `json:"level"`
	Year  int `json:"year"`
}

CensLevel main struct for records censlevel:year:id

type WarnLevel

type WarnLevel struct {
	ID    int `json:"user_id"`
	Level int `json:"level"`
}

WarnLevel main struct for records warnlevel:id

Jump to

Keyboard shortcuts

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