Initial bot functionality
* The bot now properly joins the management room * The management room is persisted in the database * Welcome/help messages are sent in the management room
This commit is contained in:
27
database/userquery.go
Normal file
27
database/userquery.go
Normal file
@@ -0,0 +1,27 @@
|
||||
package database
|
||||
|
||||
import (
|
||||
log "maunium.net/go/maulogger/v2"
|
||||
"maunium.net/go/mautrix/id"
|
||||
)
|
||||
|
||||
type UserQuery struct {
|
||||
db *Database
|
||||
log log.Logger
|
||||
}
|
||||
|
||||
func (uq *UserQuery) New() *User {
|
||||
return &User{
|
||||
db: uq.db,
|
||||
log: uq.log,
|
||||
}
|
||||
}
|
||||
|
||||
func (uq *UserQuery) GetByMXID(userID id.UserID) *User {
|
||||
row := uq.db.QueryRow("SELECT mxid, id, management_room, token FROM user where mxid=$1", userID)
|
||||
if row == nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
return uq.New().Scan(row)
|
||||
}
|
||||
Reference in New Issue
Block a user