sql

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Oct 20, 2019 License: AGPL-3.0 Imports: 9 Imported by: 8

Documentation

Index

Constants

View Source
const (
	TEXT        = 0
	BUTTON_TEXT = 1
	STICKER     = 2
	DOCUMENT    = 3
	PHOTO       = 4
	AUDIO       = 5
	VOICE       = 6
	VIDEO       = 7
)

Variables

View Source
var SESSION *gorm.DB

Functions

func AddNoteToDb

func AddNoteToDb(chatId string, noteName string, noteData string, msgtype int, buttons []Button, file string)

func AddToBlacklist

func AddToBlacklist(chatId string, trigger string)

func AddWarnFilter

func AddWarnFilter(chatId string, keyword string, reply string)

func AllFedChats

func AllFedChats(fedId string) []string

func ChatJoinFed

func ChatJoinFed(fedId string, chatId string) bool

func ChatLeaveFed

func ChatLeaveFed(chatId string) bool

func DelFed

func DelFed(fedId string)

func EnsureBotInDb

func EnsureBotInDb(u *gotgbot.Updater)

func FbanUser

func FbanUser(fedId string, userId string, reason string)

func GetFedId

func GetFedId(chatId string) string

func GetWarnSetting

func GetWarnSetting(chatId string) (int, bool)

func GetWarns

func GetWarns(userId string, chatId string) (int, []string)

func IsUserFedAdmin

func IsUserFedAdmin(fedId string, userId string) string

func IsUserFedOwner

func IsUserFedOwner(userId string, fedId string) bool

func NewFed

func NewFed(ownerId string, fedId string, fedName string) bool

func RemoveWarn

func RemoveWarn(userId string, chatId string) bool

func RemoveWarnFilter

func RemoveWarnFilter(chatId string, keyword string) bool

func ResetWarns

func ResetWarns(userId string, chatId string)

func RmFromBlacklist

func RmFromBlacklist(chatId string, trigger string) bool

func RmNote

func RmNote(chatId string, noteName string) bool

func SetWarnLimit

func SetWarnLimit(chatId string, warnLimit int)

func SetWarnStrength

func SetWarnStrength(chatId string, softWarn bool)

func UnFbanUser

func UnFbanUser(fedId string, userId string)

func UpdateUser

func UpdateUser(userId int, username string, chatId string, chatName string)

func UserDemoteFed

func UserDemoteFed(fedId string, userId string)

func UserPromoteFed

func UserPromoteFed(fedId string, userId string)

func WarnUser

func WarnUser(userId string, chatId string, reason string) (int, []string)

Types

type BlackListFilters

type BlackListFilters struct {
	ChatId  string `gorm:"primary_key"`
	Trigger string `gorm:"primary_key"`
}

func GetChatBlacklist

func GetChatBlacklist(chatId string) []BlackListFilters

type Button

type Button struct {
	Id       uint   `gorm:"primary_key;AUTO_INCREMENT"`
	ChatId   string `gorm:"primary_key"`
	NoteName string `gorm:"primary_key"`
	Name     string `gorm:"not null"`
	Url      string `gorm:"not null"`
	SameLine bool   `gorm:"default:false"`
}

func GetButtons

func GetButtons(chatId string, noteName string) []Button

type Chat

type Chat struct {
	ChatId   string `gorm:"primary_key"`
	ChatName string
}

func (Chat) String

func (c Chat) String() string

type FedAdmin

type FedAdmin struct {
	FedRef string `gorm:"primary_key"`
	UserId string `gorm:"primary_key"`
}

func GetAllFedsAdminsGlobal

func GetAllFedsAdminsGlobal() []FedAdmin

func GetFedAdmins

func GetFedAdmins(fedId string) []FedAdmin

type FedBan

type FedBan struct {
	FedRef string `gorm:"primary_key"`
	UserId string `gorm:"primary_key"`
	Reason string
}

func GetAllFbanUsers

func GetAllFbanUsers(fedId string) []FedBan

func GetAllFbanUsersGlobal

func GetAllFbanUsersGlobal() []FedBan

func GetFbanUser

func GetFbanUser(fedId string, userId string) *FedBan

type FedChat

type FedChat struct {
	ChatId string `gorm:"primary_key"`
	FedRef string
}

type Federation

type Federation struct {
	Id        string `gorm:"primary_key"`
	OwnerId   string
	FedName   string
	FedAdmins []FedAdmin `gorm:"foreignkey:Id"`
	//FedChats []FedChat `gorm:"foreignkey:Id"`
	FedBans []FedBan `gorm:"foreignkey:FedRef"`
}

func GetChatFed

func GetChatFed(chatId string) *Federation

func GetFedFromOwnerId

func GetFedFromOwnerId(ownerId string) *Federation

func GetFedInfo

func GetFedInfo(fedId string) *Federation

func GetUserFbans

func GetUserFbans(userId string) []Federation

type Note

type Note struct {
	ChatId     string `gorm:"primary_key"`
	Name       string `gorm:"primary_key"`
	Value      string `gorm:"not null"`
	File       string
	IsReply    bool `gorm:"default:false"`
	HasButtons bool `gorm:"default:false"`
	Msgtype    int  `gorm:"default:1"`
}

func GetAllChatNotes

func GetAllChatNotes(chatId string) []Note

func GetNote

func GetNote(chatId string, noteName string) *Note

type User

type User struct {
	UserId   int `gorm:"primary_key"`
	UserName string
}

func GetUserIdByName

func GetUserIdByName(username string) *User

func (User) String

func (u User) String() string

type WarnFilters

type WarnFilters struct {
	ChatId  string `gorm:"primary_key"`
	Keyword string `gorm:"primary_key"`
	Reply   string `gorm:"not null"`
}

func GetChatWarnTriggers

func GetChatWarnTriggers(chatId string) []WarnFilters

func GetWarnFilter

func GetWarnFilter(chatId string, keyword string) *WarnFilters

func (WarnFilters) String

func (wf WarnFilters) String() string

type WarnSettings

type WarnSettings struct {
	ChatId    string `gorm:"primary_key"`
	WarnLimit int    `gorm:"default:3"`
	SoftWarn  bool   `gorm:"default:false"`
}

type Warns

type Warns struct {
	UserId   string         `gorm:"primary_key"`
	ChatId   string         `gorm:"primary_key"`
	NumWarns int            `gorm:"default:0"`
	Reasons  pq.StringArray `gorm:"type:varchar(64)[]"`
}

func (Warns) String

func (w Warns) String() string

Jump to

Keyboard shortcuts

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