Skip to content

Commit

Permalink
Fix AFK and improve README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
celestix committed Jul 31, 2022
1 parent fab0996 commit c5053de
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
7 changes: 6 additions & 1 deletion modules/afk.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ func afk(ctx *ext.Context, u *ext.Update) error {
ID: u.EffectiveMessage.ID,
Message: fmt.Sprintf("Turned on AFK mode.%s", func() string {
if reason != "" {
return fmt.Sprintf("Reason: %s", reason)
return fmt.Sprintf("\nReason: %s", reason)
}
return reason
}()),
Expand Down Expand Up @@ -66,6 +66,11 @@ func afk(ctx *ext.Context, u *ext.Update) error {

func checkAfk(ctx *ext.Context, u *ext.Update) error {
chat := u.EffectiveChat()
user := u.EffectiveUser()
if user != nil && user.Bot {
// Don't replt to bots ffs
return nil
}
if !(u.EffectiveMessage.Mentioned || (chat.IsAUser() && chat.GetID() != gotgproto.Self.ID)) {
return nil
}
Expand Down
2 changes: 1 addition & 1 deletion sql/sql.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,5 +36,5 @@ func Load(l *logger.Logger) {
dB.SetMaxOpenConns(100)

// Create tables if they don't exist
SESSION.AutoMigrate(&Settings{})
SESSION.AutoMigrate(&AFK{}, &Settings{})
}

0 comments on commit c5053de

Please sign in to comment.