本文整理汇总了Golang中github.com/velour/catbase/bot.Bot.DBVersion方法的典型用法代码示例。如果您正苦于以下问题:Golang Bot.DBVersion方法的具体用法?Golang Bot.DBVersion怎么用?Golang Bot.DBVersion使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/velour/catbase/bot.Bot
的用法示例。
在下文中一共展示了Bot.DBVersion方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: New
// NewFirstPlugin creates a new FirstPlugin with the Plugin interface
func New(b bot.Bot) *FirstPlugin {
if b.DBVersion() == 1 {
_, err := b.DB().Exec(`create table if not exists first (
id integer primary key,
day integer,
time integer,
body string,
nick string
);`)
if err != nil {
log.Fatal("Could not create first table: ", err)
}
}
log.Println("First plugin initialized with day:", midnight(time.Now()))
first, err := getLastFirst(b.DB())
if err != nil {
log.Fatal("Could not initialize first plugin: ", err)
}
return &FirstPlugin{
Bot: b,
db: b.DB(),
First: first,
}
}
示例2: New
// NewCounterPlugin creates a new CounterPlugin with the Plugin interface
func New(bot bot.Bot) *CounterPlugin {
if bot.DBVersion() == 1 {
if _, err := bot.DB().Exec(`create table if not exists counter (
id integer primary key,
nick string,
item string,
count integer
);`); err != nil {
log.Fatal(err)
}
}
return &CounterPlugin{
Bot: bot,
DB: bot.DB(),
}
}
示例3: New
// NewDowntimePlugin creates a new DowntimePlugin with the Plugin interface
func New(bot bot.Bot) *DowntimePlugin {
p := DowntimePlugin{
Bot: bot,
db: bot.DB(),
}
if bot.DBVersion() == 1 {
_, err := p.db.Exec(`create table if not exists downtime (
id integer primary key,
nick string,
lastSeen integer
);`)
if err != nil {
log.Fatal("Error creating downtime table: ", err)
}
}
return &p
}
示例4: New
// NewBeersPlugin creates a new BeersPlugin with the Plugin interface
func New(bot bot.Bot) *BeersPlugin {
if bot.DBVersion() == 1 {
if _, err := bot.DB().Exec(`create table if not exists untappd (
id integer primary key,
untappdUser string,
channel string,
lastCheckin integer,
chanNick string
);`); err != nil {
log.Fatal(err)
}
}
p := BeersPlugin{
Bot: bot,
db: bot.DB(),
}
p.LoadData()
for _, channel := range bot.Config().Untappd.Channels {
go p.untappdLoop(channel)
}
return &p
}