sql

package
v0.0.0-...-704a55d Latest Latest
Warning

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

Go to latest
Published: Dec 31, 2019 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TEXT        = 0
	BUTTON_TEXT = 1
	STICKER     = 2
	DOCUMENT    = 3
	PHOTO       = 4
	AUDIO       = 5
	VOICE       = 6
	VIDEO       = 7
)
View Source
const DefaultWelcome = "Hey {first}, how are you?"

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 AllChats

func AllChats() []string

func AllFedChats

func AllFedChats(fedId string) []string

func CacheBlacklist

func CacheBlacklist(chatID string)

func ChatJoinFed

func ChatJoinFed(fedId string, chatId string) bool

func ChatLeaveFed

func ChatLeaveFed(chatId string) bool

func DelFed

func DelFed(fedId string)

func DoesChatGban

func DoesChatGban(chatId string) bool

func EnsureBotInDb

func EnsureBotInDb(u *gotgbot.Updater)

func FbanUser

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

func GbanUser

func GbanUser(userId string, reason string)

func GetCleanWelcome

func GetCleanWelcome(chatID string) int

GetCleanWelcome Get whether to clean old welcome messages or not

func GetDelPref

func GetDelPref(chatID string) bool

GetDelPref Get Whether to delete service messages or not

func GetFbanUsersCount

func GetFbanUsersCount(fedId string) int

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 HasUserClickedButton

func HasUserClickedButton(userID, chatID string) bool

HasUserClickedButton Has the user clicked button to unmute themselves

func IsUserFedAdmin

func IsUserFedAdmin(fedId string, userId string) string

func IsUserFedOwner

func IsUserFedOwner(userId string, fedId string) bool

func IsUserHuman

func IsUserHuman(userID, chatID string) bool

IsUserHuman Is the user a human

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 SetChatRules

func SetChatRules(chatId, rules string)

func SetCleanWelcome

func SetCleanWelcome(chatID string, cw int)

SetCleanWelcome Set whether to clean old welcome messages or not

func SetCustomWelcome

func SetCustomWelcome(chatID string, welcome string, buttons []WelcomeButton, welcType int)

SetCustomWelcome Set the custom welcome string

func SetDelPref

func SetDelPref(chatID string, pref bool)

SetDelPref Set whether to delete service messages or not

func SetGBanPref

func SetGBanPref(chatID string, pref bool)

func SetMutePref

func SetMutePref(chatID string, pref bool)

SetMutePref Set whether to mute users when they join or not

func SetWarnLimit

func SetWarnLimit(chatId string, warnLimit int)

func SetWarnStrength

func SetWarnStrength(chatId string, softWarn bool)

func SetWelcPref

func SetWelcPref(chatID string, pref bool)

func UnFbanUser

func UnFbanUser(fedId string, userId string)

func UnGbanUser

func UnGbanUser(userId string)

func UpdateUser

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

func UserClickedButton

func UserClickedButton(userID, chatID string)

UserClickedButton Mark the user as a human

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" json:"chat_id"`
	Trigger string `gorm:"primary_key" json:"trigger"`
}

func GetChatBlacklist

func GetChatBlacklist(chatID string) []BlackListFilters

type Button

type Button struct {
	Id       uint   `gorm:"primary_key;AUTO_INCREMENT" json:"id"`
	ChatId   string `gorm:"primary_key" json:"chat_id"`
	NoteName string `gorm:"primary_key" json:"note_name"`
	Name     string `gorm:"not null" json:"name"`
	Url      string `gorm:"not null" json:"url"`
	SameLine bool   `gorm:"default:false" json:"same_line"`
}

func GetButtons

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

type Chat

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

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" json:"fed_ref"`
	UserId string `gorm:"primary_key" json:"user_id"`
	Reason string `json:"reason"`
}

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 GlobalBan

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

func GetGbanUser

func GetGbanUser(userId string) *GlobalBan

type GlobalBanSetting

type GlobalBanSetting struct {
	ChatId  string `gorm:"primary_key"`
	Setting bool   `gorm:"default:false"`
}

type MutedUser

type MutedUser struct {
	UserId        string `gorm:"primary_key"`
	ChatId        string `gorm:"primary_key"`
	ButtonClicked bool   `gorm:"default:false"`
}

type Note

type Note struct {
	ChatId     string `gorm:"primary_key" json:"chat_id"`
	Name       string `gorm:"primary_key" json:"name"`
	Value      string `gorm:"not null" json:"value"`
	File       string `json:"file"`
	IsReply    bool   `gorm:"default:false" json:"is_reply"`
	HasButtons bool   `gorm:"default:false" json:"has_buttons"`
	Msgtype    int    `gorm:"default:1" json:"msgtype"`
}

func GetAllChatNotes

func GetAllChatNotes(chatId string) []Note

func GetNote

func GetNote(chatId string, noteName string) *Note

type Rules

type Rules struct {
	ChatId string `gorm:"primary_key" json:"chat_id"`
	Rules  string `json:"rules"`
}

func GetChatRules

func GetChatRules(chatId string) *Rules

type User

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

func GetUserIdByName

func GetUserIdByName(username string) *User

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

type Welcome

type Welcome struct {
	ChatId        string `gorm:"primary_key"`
	CustomWelcome string
	ShouldWelcome bool `gorm:"default:true"`
	ShouldMute    bool `gorm:"default:true"`
	DelJoined     bool `gorm:"default:false"`
	CleanWelcome  int  `gorm:"default:0"`
	WelcomeType   int  `gorm:"default:0"`
	MuteTime      int  `gorm:"default:0"`
}

func GetWelcomePrefs

func GetWelcomePrefs(chatID string) *Welcome

GetWelcomePrefs Return the preferences for welcoming users

type WelcomeButton

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

func GetWelcomeButtons

func GetWelcomeButtons(chatID string) []WelcomeButton

GetWelcomeButtons Get the buttons for the welcome message

Jump to

Keyboard shortcuts

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