database

package
v1.5.16 Latest Latest
Warning

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

Go to latest
Published: Jan 11, 2021 License: GPL-3.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	DB           *sql.DB
	FanartCache  *redis.Client
	LiveCache    *redis.Client
	GeneralCache *redis.Client
)

Public variable

Functions

func CheckChannelEnable

func CheckChannelEnable(ChannelID, VtuberName string, GroupID int64) bool

Check enable or disable discord channel from `tag,del` command

func CheckUser

func CheckUser(DiscordID string, MemberID int64, ChannelChannelID int) bool

CheckUser Check user if already tagged

func GetChannelID

func GetChannelID(DiscordChannelID string, GroupID int64) int

GetChannelID Get Channel id from Discord ChannelID and VtuberGroupID

func GetGuildsCount

func GetGuildsCount() int

func GetModule

func GetModule() []string

func GetRanChannel

func GetRanChannel() string

GetRanChannel get random id channel

func GetTBiliBili

func GetTBiliBili(DynamicID string) bool

GetTBiliBili Check new post on TBiliBili

func GetTwitch

func GetTwitch()

func GetUserList

func GetUserList(ChannelIDDiscord int64, Member int64) []string

GetUserList GetUser tags

func GetUserReminderList

func GetUserReminderList(ChannelIDDiscord int, Member int64, Reminder int) []string

get Reminder tags

func ModuleInfo

func ModuleInfo(Name string)

func SetRoomToLive

func SetRoomToLive(MemberID int64)

func Start

func Start(dbsession *sql.DB)

Start Database session

func UserStatus

func UserStatus(UserID, Channel string) [][]string

Get userinfo(tags) from discord channel

Types

type DataFanart

type DataFanart struct {
	ID           int64
	EnName       string
	JpName       string
	PermanentURL string
	Author       string
	Photos       []string
	Videos       string
	Text         string
	Likes        int
	Dynamic_id   string
	State        string
}

func GetFanart

func GetFanart(GroupID, MemberID int64) DataFanart

GetFanart Get Member fanart URL from TBiliBili and Twitter

func (DataFanart) DeleteFanart

func (Data DataFanart) DeleteFanart() error

type DiscordChannel

type DiscordChannel struct {
	ID             int64
	ChannelID      string
	TypeTag        int
	LiveOnly       bool
	NewUpcoming    bool
	Dynamic        bool
	Group          Group
	YoutubeVideoID string
	EmbedMessageID string
	TextMessageID  string
}

func ChannelStatus

func ChannelStatus(ChannelID string) []DiscordChannel

Get Discord channel status

func ChannelTag

func ChannelTag(MemberID int64, typetag int, Options string) []DiscordChannel

ChannelTag get channel tags from `channel tags` command

func GetLiveNotifMsg

func GetLiveNotifMsg(Key string) []DiscordChannel

func (*DiscordChannel) AddChannel

func (Data *DiscordChannel) AddChannel() error

Add new discord channel from `enable` command

func (*DiscordChannel) ChannelCheck

func (Data *DiscordChannel) ChannelCheck() bool

Check Discord Channel from VtuberGroup

func (*DiscordChannel) DelChannel

func (Data *DiscordChannel) DelChannel(errmsg string) error

delete discord channel from `disable` command

func (DiscordChannel) MarshalBinary

func (ac DiscordChannel) MarshalBinary() ([]byte, error)

func (*DiscordChannel) PushReddis

func (Data *DiscordChannel) PushReddis()

func (*DiscordChannel) SetDynamic

func (Data *DiscordChannel) SetDynamic(new bool) *DiscordChannel

func (*DiscordChannel) SetLiveOnly

func (Data *DiscordChannel) SetLiveOnly(new bool) *DiscordChannel

func (*DiscordChannel) SetMsgEmbedID

func (Data *DiscordChannel) SetMsgEmbedID(new string) *DiscordChannel

func (*DiscordChannel) SetMsgTextID

func (Data *DiscordChannel) SetMsgTextID(new string) *DiscordChannel

func (*DiscordChannel) SetNewUpcoming

func (Data *DiscordChannel) SetNewUpcoming(new bool) *DiscordChannel

func (*DiscordChannel) SetTypeTag

func (Data *DiscordChannel) SetTypeTag(new int) *DiscordChannel

func (*DiscordChannel) SetVtuberGroupID

func (Data *DiscordChannel) SetVtuberGroupID(new int64) *DiscordChannel

func (*DiscordChannel) SetYoutubeVideoID

func (Data *DiscordChannel) SetYoutubeVideoID(new string) *DiscordChannel

func (*DiscordChannel) UpdateChannel

func (Data *DiscordChannel) UpdateChannel(UpdateType string) error

update discord channel type from `update` command

type Group

type Group struct {
	ID        int64
	IconURL   string
	GroupName string
}

func GetGroups

func GetGroups() []Group

GetGroup Get all vtuber groupData

func (Group) GetChannelByGroup

func (Data Group) GetChannelByGroup() []DiscordChannel

Get DiscordChannelID from VtuberGroup

type Guild

type Guild struct {
	ID   string
	Name string
	Join time.Time
}

func (Guild) CheckGuild

func (Data Guild) CheckGuild() int

func (Guild) InputGuild

func (Data Guild) InputGuild() error

func (Guild) UpdateJoin

func (Data Guild) UpdateJoin(id int) error

type InputBiliBili

type InputBiliBili struct {
	VideoID  string
	Type     string
	Title    string
	Thum     string
	Desc     string
	Update   time.Time
	Viewers  int
	MemberID int64
	Length   string
}

func (InputBiliBili) CheckVideo

func (Data InputBiliBili) CheckVideo() (bool, int)

CheckVideo Check New video from SpaceBiliBili

func (InputBiliBili) InputSpaceVideo

func (Data InputBiliBili) InputSpaceVideo()

InputSpaceVideo Input data to SpaceBiliBili

func (InputBiliBili) UpdateView

func (Data InputBiliBili) UpdateView(id int)

UpdateView Update SpaceBiliBili data

type InputTBiliBili

type InputTBiliBili struct {
	URL        string
	Author     string
	Avatar     string
	Like       int
	Photos     string
	Videos     string
	Text       string
	Dynamic_id string
}

func (InputTBiliBili) InputTBiliBili

func (Data InputTBiliBili) InputTBiliBili(MemberID int64)

InputTBiliBili Input TBiliBili data

type InputTW

type InputTW struct {
	Url      string
	Author   string
	Like     int
	Photos   string
	Video    string
	Text     string
	TweetID  string
	MemberID int64
}

type LiveBiliDB

type LiveBiliDB struct {
	LiveRoomID, Online, ID                                        int
	Status, Title, Thumbnail, Description, EnName, JpName, Avatar string
	ScheduledStart, PublishedAt                                   time.Time
}

func BilGet

func BilGet(GroupID int64, MemberID int64, Status string) []LiveBiliDB

BilGet Get LiveBiliBili by Status (live,past)

func GetRoomData

func GetRoomData(MemberID int64, RoomID int) (*LiveBiliDB, error)

GetRoomData get RoomData from LiveBiliBili

func (*LiveBiliDB) UpdateLiveBili

func (Data *LiveBiliDB) UpdateLiveBili(MemberID int64)

UpdateLiveBili Update LiveBiliBili Data

type Member

type Member struct {
	ID               int64
	Name             string
	EnName           string
	JpName           string
	YoutubeID        string
	YoutubeAvatar    string
	BiliBiliID       int
	BiliRoomID       int
	TwitterHashtags  string
	TwitterName      string
	BiliBiliHashtags string
	BiliBiliAvatar   string
	TwitchUserName   string
	Region           string
	GroupID          int64
}

func GetMembers

func GetMembers(GroupID int64) []Member

GetMember Get data of Vtuber member

func (Member) CheckMemberFanart

func (Member Member) CheckMemberFanart(Data *twitterscraper.Result) (bool, error)

func (Member) CheckYtVideo

func (Member Member) CheckYtVideo(VideoID string) (*YtDbData, error)

Check new video or not

func (Member) GetSubsCount

func (Member Member) GetSubsCount() (*MemberSubs, error)

GetSubsCount Get subs,follow,view,like data from Subscriber

func (Member) GetTwitterFollow

func (Data Member) GetTwitterFollow() (twitterscraper.Profile, error)

Scrapping twitter followers

func (Member) MarshalBinary

func (ac Member) MarshalBinary() ([]byte, error)

type MemberSubs

type MemberSubs struct {
	YtSubs, YtVideos, YtViews         int
	BiliFollow, BiliVideos, BiliViews int
	ID, TwFollow                      int
	MemberID                          int64
}

func (MemberSubs) MarshalBinary

func (ac MemberSubs) MarshalBinary() ([]byte, error)

func (*MemberSubs) UpBiliFollow

func (Member *MemberSubs) UpBiliFollow(new int) *MemberSubs

UpBiliFollow update bilibili state

func (*MemberSubs) UpBiliVideo

func (Member *MemberSubs) UpBiliVideo(new int) *MemberSubs

UpBiliVideo Add bilibili Videos

func (*MemberSubs) UpBiliViews

func (Member *MemberSubs) UpBiliViews(new int) *MemberSubs

UpBiliViews Add views

func (*MemberSubs) UpYtSubs

func (Member *MemberSubs) UpYtSubs(new int) *MemberSubs

UpYtSubs update youtube state

func (*MemberSubs) UpYtVideo

func (Member *MemberSubs) UpYtVideo(new int) *MemberSubs

UpYtVideo Update youtube videos

func (*MemberSubs) UpYtViews

func (Member *MemberSubs) UpYtViews(new int) *MemberSubs

UpYtViews Update youtube views

func (*MemberSubs) UpdateSubs

func (Member *MemberSubs) UpdateSubs(State string)

UpdateSubs Update Subscriber data

func (*MemberSubs) UptwFollow

func (Member *MemberSubs) UptwFollow(new int) *MemberSubs

UptwFollow Update twitter state

type SpaceBiliDB

type SpaceBiliDB struct {
	Viewers                                                                      int
	VideoID, Title, Thumbnail, Description, EnName, JpName, Avatar, Type, Length string
	UploadDate                                                                   time.Time
}

func SpaceGet

func SpaceGet(GroupID int64, MemberID int64) []SpaceBiliDB

SpaceGet Get SpaceBiliBili Data

type TwitterUser

type TwitterUser struct {
	ID              int         `json:"id"`
	IDStr           string      `json:"id_str"`
	Name            string      `json:"name"`
	ScreenName      string      `json:"screen_name"`
	Location        string      `json:"location"`
	ProfileLocation interface{} `json:"profile_location"`
	Description     string      `json:"description"`
	URL             string      `json:"url"`
	Entities        struct {
		URL struct {
			Urls []struct {
				URL         string `json:"url"`
				ExpandedURL string `json:"expanded_url"`
				DisplayURL  string `json:"display_url"`
				Indices     []int  `json:"indices"`
			} `json:"urls"`
		} `json:"url"`
		Description struct {
			Urls []struct {
				URL         string `json:"url"`
				ExpandedURL string `json:"expanded_url"`
				DisplayURL  string `json:"display_url"`
				Indices     []int  `json:"indices"`
			} `json:"urls"`
		} `json:"description"`
	} `json:"entities"`
	Protected       bool        `json:"protected"`
	FollowersCount  int         `json:"followers_count"`
	FriendsCount    int         `json:"friends_count"`
	ListedCount     int         `json:"listed_count"`
	CreatedAt       string      `json:"created_at"`
	FavouritesCount int         `json:"favourites_count"`
	UtcOffset       interface{} `json:"utc_offset"`
	TimeZone        interface{} `json:"time_zone"`
	GeoEnabled      bool        `json:"geo_enabled"`
	Verified        bool        `json:"verified"`
	StatusesCount   int         `json:"statuses_count"`
	Lang            interface{} `json:"lang"`
	Status          struct {
		CreatedAt string `json:"created_at"`
		ID        int64  `json:"id"`
		IDStr     string `json:"id_str"`
		Text      string `json:"text"`
		Truncated bool   `json:"truncated"`
		Entities  struct {
			Hashtags     []interface{} `json:"hashtags"`
			Symbols      []interface{} `json:"symbols"`
			UserMentions []struct {
				ScreenName string `json:"screen_name"`
				Name       string `json:"name"`
				ID         int    `json:"id"`
				IDStr      string `json:"id_str"`
				Indices    []int  `json:"indices"`
			} `json:"user_mentions"`
			Urls []interface{} `json:"urls"`
		} `json:"entities"`
		Source               string      `json:"source"`
		InReplyToStatusID    int64       `json:"in_reply_to_status_id"`
		InReplyToStatusIDStr string      `json:"in_reply_to_status_id_str"`
		InReplyToUserID      int         `json:"in_reply_to_user_id"`
		InReplyToUserIDStr   string      `json:"in_reply_to_user_id_str"`
		InReplyToScreenName  string      `json:"in_reply_to_screen_name"`
		Geo                  interface{} `json:"geo"`
		Coordinates          interface{} `json:"coordinates"`
		Place                interface{} `json:"place"`
		Contributors         interface{} `json:"contributors"`
		IsQuoteStatus        bool        `json:"is_quote_status"`
		RetweetCount         int         `json:"retweet_count"`
		FavoriteCount        int         `json:"favorite_count"`
		Favorited            bool        `json:"favorited"`
		Retweeted            bool        `json:"retweeted"`
		Lang                 string      `json:"lang"`
	} `json:"status"`
	ContributorsEnabled            bool   `json:"contributors_enabled"`
	IsTranslator                   bool   `json:"is_translator"`
	IsTranslationEnabled           bool   `json:"is_translation_enabled"`
	ProfileBackgroundColor         string `json:"profile_background_color"`
	ProfileBackgroundImageURL      string `json:"profile_background_image_url"`
	ProfileBackgroundImageURLHTTPS string `json:"profile_background_image_url_https"`
	ProfileBackgroundTile          bool   `json:"profile_background_tile"`
	ProfileImageURL                string `json:"profile_image_url"`
	ProfileImageURLHTTPS           string `json:"profile_image_url_https"`
	ProfileBannerURL               string `json:"profile_banner_url"`
	ProfileLinkColor               string `json:"profile_link_color"`
	ProfileSidebarBorderColor      string `json:"profile_sidebar_border_color"`
	ProfileSidebarFillColor        string `json:"profile_sidebar_fill_color"`
	ProfileTextColor               string `json:"profile_text_color"`
	ProfileUseBackgroundImage      bool   `json:"profile_use_background_image"`
	HasExtendedProfile             bool   `json:"has_extended_profile"`
	DefaultProfile                 bool   `json:"default_profile"`
	DefaultProfileImage            bool   `json:"default_profile_image"`
	Following                      bool   `json:"following"`
	FollowRequestSent              bool   `json:"follow_request_sent"`
	Notifications                  bool   `json:"notifications"`
	TranslatorType                 string `json:"translator_type"`
}

type UserStruct

type UserStruct struct {
	DiscordID, DiscordUserName, Channel_ID string
	GroupID                                int64
	Reminder                               int
	Human                                  bool
}

func (UserStruct) Adduser

func (Data UserStruct) Adduser(MemberID int64) error

Adduser form `tag me command`

func (UserStruct) Deluser

func (Data UserStruct) Deluser(MemberID int64) error

Deluser Delete user from `del` command

func (*UserStruct) SetDiscordChannelID

func (Data *UserStruct) SetDiscordChannelID(new string) *UserStruct

func (*UserStruct) SetDiscordID

func (Data *UserStruct) SetDiscordID(new string) *UserStruct

func (*UserStruct) SetDiscordUserName

func (Data *UserStruct) SetDiscordUserName(new string) *UserStruct

func (*UserStruct) SetGroupID

func (Data *UserStruct) SetGroupID(new int64) *UserStruct

func (*UserStruct) SetHuman

func (Data *UserStruct) SetHuman(new bool) *UserStruct

func (*UserStruct) SetReminder

func (Data *UserStruct) SetReminder(new int) *UserStruct

func (UserStruct) UpdateReminder

func (Data UserStruct) UpdateReminder(MemberID int64) error

UpdateReminder Update reminder time

type YtDbData

type YtDbData struct {
	ID            int64
	ChannelID     string
	Group         string
	Status        string
	NameEN        string
	NameJP        string
	VideoID       string
	Title         string
	Thumb         string
	Desc          string
	YoutubeAvatar string
	Schedul       time.Time
	End           time.Time
	Published     time.Time
	Type          string
	Region        string
	Viewers       string
	Length        string
	MemberID      int64
	GroupID       int64
}

func YtGetStatus

func YtGetStatus(Group, Member int64, Status, Region string) ([]YtDbData, error)

Get Youtube data from status

func (*YtDbData) InputYt

func (Data *YtDbData) InputYt() (int64, error)

Input youtube new video

func (YtDbData) IsEmpty

func (Data YtDbData) IsEmpty() bool

func (YtDbData) MarshalBinary

func (ac YtDbData) MarshalBinary() ([]byte, error)

func (*YtDbData) UpdateYt

func (Data *YtDbData) UpdateYt(Status string)

Update youtube data

Jump to

Keyboard shortcuts

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