add custom status message
This commit is contained in:
@@ -38,6 +38,7 @@ env vars
|
|||||||
* **POSTMOOGLE_NOOWNER** - allow change room settings by any room partisipant
|
* **POSTMOOGLE_NOOWNER** - allow change room settings by any room partisipant
|
||||||
* **POSTMOOGLE_FEDERATION** - allow usage of Postmoogle by users from others homeservers
|
* **POSTMOOGLE_FEDERATION** - allow usage of Postmoogle by users from others homeservers
|
||||||
* **POSTMOOGLE_NOENCRYPTION** - disable encryption support
|
* **POSTMOOGLE_NOENCRYPTION** - disable encryption support
|
||||||
|
* **POSTMOOGLE_STATUSMSG** - presence status message
|
||||||
* **POSTMOOGLE_SENTRY_DSN** - sentry DSN
|
* **POSTMOOGLE_SENTRY_DSN** - sentry DSN
|
||||||
* **POSTMOOGLE_LOGLEVEL** - log level
|
* **POSTMOOGLE_LOGLEVEL** - log level
|
||||||
* **POSTMOOGLE_DB_DSN** - database connection string
|
* **POSTMOOGLE_DB_DSN** - database connection string
|
||||||
|
|||||||
@@ -67,7 +67,7 @@ func (b *Bot) Notice(ctx context.Context, roomID id.RoomID, message string) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Start performs matrix /sync
|
// Start performs matrix /sync
|
||||||
func (b *Bot) Start() error {
|
func (b *Bot) Start(statusMsg string) error {
|
||||||
if err := b.migrate(); err != nil {
|
if err := b.migrate(); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@@ -77,7 +77,7 @@ func (b *Bot) Start() error {
|
|||||||
|
|
||||||
b.initSync()
|
b.initSync()
|
||||||
b.log.Info("Postmoogle has been started")
|
b.log.Info("Postmoogle has been started")
|
||||||
return b.lp.Start()
|
return b.lp.Start(statusMsg)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (b *Bot) email2content(email *utils.Email, cfg settings) *event.MessageEventContent {
|
func (b *Bot) email2content(email *utils.Email, cfg settings) *event.MessageEventContent {
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ func main() {
|
|||||||
initShutdown(quit)
|
initShutdown(quit)
|
||||||
defer recovery()
|
defer recovery()
|
||||||
|
|
||||||
go startBot()
|
go startBot(cfg.StatusMsg)
|
||||||
if err := smtp.Start(cfg.Domain, cfg.Port, cfg.LogLevel, cfg.MaxSize, mxb); err != nil {
|
if err := smtp.Start(cfg.Domain, cfg.Port, cfg.LogLevel, cfg.MaxSize, mxb); err != nil {
|
||||||
//nolint:gocritic
|
//nolint:gocritic
|
||||||
log.Fatal("SMTP server crashed: %v", err)
|
log.Fatal("SMTP server crashed: %v", err)
|
||||||
@@ -97,9 +97,9 @@ func initShutdown(quit chan struct{}) {
|
|||||||
}()
|
}()
|
||||||
}
|
}
|
||||||
|
|
||||||
func startBot() {
|
func startBot(statusMsg string) {
|
||||||
log.Debug("starting matrix bot...")
|
log.Debug("starting matrix bot: %s...", statusMsg)
|
||||||
err := mxb.Start()
|
err := mxb.Start(statusMsg)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
//nolint:gocritic
|
//nolint:gocritic
|
||||||
log.Fatal("cannot start the bot: %v", err)
|
log.Fatal("cannot start the bot: %v", err)
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ func New() *Config {
|
|||||||
NoOwner: env.Bool("noowner"),
|
NoOwner: env.Bool("noowner"),
|
||||||
Federation: env.Bool("federation"),
|
Federation: env.Bool("federation"),
|
||||||
MaxSize: env.Int("maxsize", defaultConfig.MaxSize),
|
MaxSize: env.Int("maxsize", defaultConfig.MaxSize),
|
||||||
|
StatusMsg: env.String("statusmsg", defaultConfig.StatusMsg),
|
||||||
Sentry: Sentry{
|
Sentry: Sentry{
|
||||||
DSN: env.String("sentry.dsn", defaultConfig.Sentry.DSN),
|
DSN: env.String("sentry.dsn", defaultConfig.Sentry.DSN),
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -1,11 +1,12 @@
|
|||||||
package config
|
package config
|
||||||
|
|
||||||
var defaultConfig = &Config{
|
var defaultConfig = &Config{
|
||||||
LogLevel: "INFO",
|
LogLevel: "INFO",
|
||||||
Domain: "localhost",
|
Domain: "localhost",
|
||||||
Port: "25",
|
Port: "25",
|
||||||
Prefix: "!pm",
|
Prefix: "!pm",
|
||||||
MaxSize: 1024,
|
MaxSize: 1024,
|
||||||
|
StatusMsg: "Delivering emails",
|
||||||
DB: DB{
|
DB: DB{
|
||||||
DSN: "local.db",
|
DSN: "local.db",
|
||||||
Dialect: "sqlite3",
|
Dialect: "sqlite3",
|
||||||
|
|||||||
@@ -24,6 +24,8 @@ type Config struct {
|
|||||||
Prefix string
|
Prefix string
|
||||||
// MaxSize of an email (including attachments)
|
// MaxSize of an email (including attachments)
|
||||||
MaxSize int
|
MaxSize int
|
||||||
|
// StatusMsg of the bot
|
||||||
|
StatusMsg string
|
||||||
|
|
||||||
// DB config
|
// DB config
|
||||||
DB DB
|
DB DB
|
||||||
|
|||||||
6
go.mod
6
go.mod
@@ -10,7 +10,7 @@ require (
|
|||||||
github.com/mattn/go-sqlite3 v1.14.14
|
github.com/mattn/go-sqlite3 v1.14.14
|
||||||
gitlab.com/etke.cc/go/env v1.0.0
|
gitlab.com/etke.cc/go/env v1.0.0
|
||||||
gitlab.com/etke.cc/go/logger v1.1.0
|
gitlab.com/etke.cc/go/logger v1.1.0
|
||||||
gitlab.com/etke.cc/linkpearl v0.0.0-20220823124436-ff8541c79eee
|
gitlab.com/etke.cc/linkpearl v0.0.0-20220826133247-10dcaedb8085
|
||||||
golang.org/x/net v0.0.0-20220822230855-b0a4917ee28c
|
golang.org/x/net v0.0.0-20220822230855-b0a4917ee28c
|
||||||
maunium.net/go/mautrix v0.12.0
|
maunium.net/go/mautrix v0.12.0
|
||||||
)
|
)
|
||||||
@@ -36,8 +36,8 @@ require (
|
|||||||
github.com/tidwall/pretty v1.2.0 // indirect
|
github.com/tidwall/pretty v1.2.0 // indirect
|
||||||
github.com/tidwall/sjson v1.2.5 // indirect
|
github.com/tidwall/sjson v1.2.5 // indirect
|
||||||
github.com/yuin/goldmark v1.4.12 // indirect
|
github.com/yuin/goldmark v1.4.12 // indirect
|
||||||
golang.org/x/crypto v0.0.0-20220817201139-bc19a97f63c8 // indirect
|
golang.org/x/crypto v0.0.0-20220824171710-5757bc0c5503 // indirect
|
||||||
golang.org/x/sys v0.0.0-20220823224334-20c2bfdbfe24 // indirect
|
golang.org/x/sys v0.0.0-20220825204002-c680a09ffe64 // indirect
|
||||||
golang.org/x/text v0.3.7 // indirect
|
golang.org/x/text v0.3.7 // indirect
|
||||||
gopkg.in/yaml.v3 v3.0.1 // indirect
|
gopkg.in/yaml.v3 v3.0.1 // indirect
|
||||||
maunium.net/go/maulogger/v2 v2.3.2 // indirect
|
maunium.net/go/maulogger/v2 v2.3.2 // indirect
|
||||||
|
|||||||
12
go.sum
12
go.sum
@@ -72,10 +72,10 @@ gitlab.com/etke.cc/go/env v1.0.0 h1:J98BwzOuELnjsVPFvz5wa79L7IoRV9CmrS41xLYXtSw=
|
|||||||
gitlab.com/etke.cc/go/env v1.0.0/go.mod h1:e1l4RM5MA1sc0R1w/RBDAESWRwgo5cOG9gx8BKUn2C4=
|
gitlab.com/etke.cc/go/env v1.0.0/go.mod h1:e1l4RM5MA1sc0R1w/RBDAESWRwgo5cOG9gx8BKUn2C4=
|
||||||
gitlab.com/etke.cc/go/logger v1.1.0 h1:Yngp/DDLmJ0jJNLvLXrfan5Gi5QV+r7z6kCczTv8t4U=
|
gitlab.com/etke.cc/go/logger v1.1.0 h1:Yngp/DDLmJ0jJNLvLXrfan5Gi5QV+r7z6kCczTv8t4U=
|
||||||
gitlab.com/etke.cc/go/logger v1.1.0/go.mod h1:8Vw5HFXlZQ5XeqvUs5zan+GnhrQyYtm/xe+yj8H/0zk=
|
gitlab.com/etke.cc/go/logger v1.1.0/go.mod h1:8Vw5HFXlZQ5XeqvUs5zan+GnhrQyYtm/xe+yj8H/0zk=
|
||||||
gitlab.com/etke.cc/linkpearl v0.0.0-20220823124436-ff8541c79eee h1:B880ePbakEEr02p2khEpdwUSzzO49ZnZhnQoxGfKj6U=
|
gitlab.com/etke.cc/linkpearl v0.0.0-20220826133247-10dcaedb8085 h1:Qr6o2ERYCEkZAOhvIl4cwgUOHBn4sHq+yReCMjg8kvE=
|
||||||
gitlab.com/etke.cc/linkpearl v0.0.0-20220823124436-ff8541c79eee/go.mod h1:CqwzwxVogKG6gDWTPTen3NyWbTESg42jxoTfXXwDGKQ=
|
gitlab.com/etke.cc/linkpearl v0.0.0-20220826133247-10dcaedb8085/go.mod h1:CqwzwxVogKG6gDWTPTen3NyWbTESg42jxoTfXXwDGKQ=
|
||||||
golang.org/x/crypto v0.0.0-20220817201139-bc19a97f63c8 h1:GIAS/yBem/gq2MUqgNIzUHW7cJMmx3TGZOrnyYaNQ6c=
|
golang.org/x/crypto v0.0.0-20220824171710-5757bc0c5503 h1:vJ2V3lFLg+bBhgroYuRfyN583UzVveQmIXjc8T/y3to=
|
||||||
golang.org/x/crypto v0.0.0-20220817201139-bc19a97f63c8/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
|
golang.org/x/crypto v0.0.0-20220824171710-5757bc0c5503/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
|
||||||
golang.org/x/net v0.0.0-20210501142056-aec3718b3fa0/go.mod h1:OJAsFXCWl8Ukc7SiCT/9KSuxbyM7479/AVlXFRxuMCk=
|
golang.org/x/net v0.0.0-20210501142056-aec3718b3fa0/go.mod h1:OJAsFXCWl8Ukc7SiCT/9KSuxbyM7479/AVlXFRxuMCk=
|
||||||
golang.org/x/net v0.0.0-20220822230855-b0a4917ee28c h1:JVAXQ10yGGVbSyoer5VILysz6YKjdNT2bsvlayjqhes=
|
golang.org/x/net v0.0.0-20220822230855-b0a4917ee28c h1:JVAXQ10yGGVbSyoer5VILysz6YKjdNT2bsvlayjqhes=
|
||||||
golang.org/x/net v0.0.0-20220822230855-b0a4917ee28c/go.mod h1:YDH+HFinaLZZlnHAfSS6ZXJJ9M9t4Dl22yv3iI2vPwk=
|
golang.org/x/net v0.0.0-20220822230855-b0a4917ee28c/go.mod h1:YDH+HFinaLZZlnHAfSS6ZXJJ9M9t4Dl22yv3iI2vPwk=
|
||||||
@@ -84,8 +84,8 @@ golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7w
|
|||||||
golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
golang.org/x/sys v0.0.0-20210927094055-39ccf1dd6fa6/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
golang.org/x/sys v0.0.0-20210927094055-39ccf1dd6fa6/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
golang.org/x/sys v0.0.0-20220823224334-20c2bfdbfe24 h1:TyKJRhyo17yWxOMCTHKWrc5rddHORMlnZ/j57umaUd8=
|
golang.org/x/sys v0.0.0-20220825204002-c680a09ffe64 h1:UiNENfZ8gDvpiWw7IpOMQ27spWmThO1RwwdQVbJahJM=
|
||||||
golang.org/x/sys v0.0.0-20220823224334-20c2bfdbfe24/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
golang.org/x/sys v0.0.0-20220825204002-c680a09ffe64/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
|
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
|
||||||
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
||||||
golang.org/x/text v0.3.7 h1:olpwvP2KacW1ZWvsR7uQhoyTYvKAupfQrRGBFM352Gk=
|
golang.org/x/text v0.3.7 h1:olpwvP2KacW1ZWvsR7uQhoyTYvKAupfQrRGBFM352Gk=
|
||||||
|
|||||||
Reference in New Issue
Block a user