laniakea v0.6
This commit is contained in:
@@ -16,13 +16,13 @@ import (
|
||||
|
||||
func RegisterLogs(bot *laniakea.Bot) {
|
||||
p := laniakea.NewPlugin("Logs")
|
||||
p.Command(getLogs, "logs")
|
||||
p.Command(getMsgLogs, "msglogs")
|
||||
p.AddCommand(p.NewCommand(getLogs, "logs").SkipCommandAutoGen())
|
||||
p.AddCommand(p.NewCommand(getMsgLogs, "msglogs").SkipCommandAutoGen())
|
||||
p.AddMiddleware(AdminMiddleware())
|
||||
bot.AddPlugins(p.Build())
|
||||
bot.AddPlugins(p)
|
||||
}
|
||||
func InitLogMiddleware() laniakea.Middleware {
|
||||
return laniakea.NewMiddleware("LogMiddleware", logMiddleware).SetAsync(true).Build()
|
||||
return *laniakea.NewMiddleware("LogMiddleware", logMiddleware).SetAsync(true)
|
||||
}
|
||||
|
||||
func getLogs(ctx *laniakea.MsgContext, db *laniakea.DatabaseContext) {
|
||||
@@ -61,9 +61,9 @@ func encodeLogs[T comparable](logs extypes.Slice[T]) extypes.Slice[string] {
|
||||
return out
|
||||
}
|
||||
|
||||
func logMiddleware(ctx *laniakea.MsgContext, db *laniakea.DatabaseContext) {
|
||||
func logMiddleware(ctx *laniakea.MsgContext, db *laniakea.DatabaseContext) bool {
|
||||
if ctx.Msg == nil {
|
||||
return
|
||||
return true
|
||||
}
|
||||
entry := &mdb.MessageLogEntry{
|
||||
MessageID: ctx.Msg.MessageID,
|
||||
@@ -76,6 +76,7 @@ func logMiddleware(ctx *laniakea.MsgContext, db *laniakea.DatabaseContext) {
|
||||
if err != nil {
|
||||
ctx.Bot.Logger().Errorln(err)
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
type DatabaseWriter struct {
|
||||
|
||||
Reference in New Issue
Block a user