Add rawmessages
configuration option
This commit is contained in:
parent
0610479734
commit
2a5af5a264
|
@ -37,11 +37,13 @@ type Session struct {
|
||||||
Login string `yaml:":login"`
|
Login string `yaml:":login"`
|
||||||
Timezone string `yaml:":timezone"`
|
Timezone string `yaml:":timezone"`
|
||||||
KeepOnline bool `yaml:":keeponline"`
|
KeepOnline bool `yaml:":keeponline"`
|
||||||
|
RawMessages bool `yaml:":rawmessages"`
|
||||||
}
|
}
|
||||||
|
|
||||||
var configKeys = []string{
|
var configKeys = []string{
|
||||||
"timezone",
|
"timezone",
|
||||||
"keeponline",
|
"keeponline",
|
||||||
|
"rawmessages",
|
||||||
}
|
}
|
||||||
|
|
||||||
var sessionDB *SessionsYamlDB
|
var sessionDB *SessionsYamlDB
|
||||||
|
@ -110,6 +112,8 @@ func (s *Session) Get(key string) (string, error) {
|
||||||
return s.Timezone, nil
|
return s.Timezone, nil
|
||||||
case "keeponline":
|
case "keeponline":
|
||||||
return fromBool(s.KeepOnline), nil
|
return fromBool(s.KeepOnline), nil
|
||||||
|
case "rawmessages":
|
||||||
|
return fromBool(s.RawMessages), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
return "", errors.New("Unknown session property")
|
return "", errors.New("Unknown session property")
|
||||||
|
@ -139,6 +143,13 @@ func (s *Session) Set(key string, value string) (string, error) {
|
||||||
}
|
}
|
||||||
s.KeepOnline = b
|
s.KeepOnline = b
|
||||||
return value, nil
|
return value, nil
|
||||||
|
case "rawmessages":
|
||||||
|
b, err := toBool(value)
|
||||||
|
if err != nil {
|
||||||
|
return "", err
|
||||||
|
}
|
||||||
|
s.RawMessages = b
|
||||||
|
return value, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
return "", errors.New("Unknown session property")
|
return "", errors.New("Unknown session property")
|
||||||
|
|
|
@ -83,6 +83,7 @@ var chatCommands = map[string]command{
|
||||||
var transportConfigurationOptions = map[string]configurationOption{
|
var transportConfigurationOptions = map[string]configurationOption{
|
||||||
"timezone": configurationOption{"<timezone>", "adjust timezone for Telegram user statuses (example: +02:00)"},
|
"timezone": configurationOption{"<timezone>", "adjust timezone for Telegram user statuses (example: +02:00)"},
|
||||||
"keeponline": configurationOption{"<bool>", "always keep telegram session online and rely on jabber offline messages (example: true)"},
|
"keeponline": configurationOption{"<bool>", "always keep telegram session online and rely on jabber offline messages (example: true)"},
|
||||||
|
"rawmessages": configurationOption{"<bool>", "do not add additional info (message id, origin etc.) to incoming messages (example: true)"},
|
||||||
}
|
}
|
||||||
|
|
||||||
type command struct {
|
type command struct {
|
||||||
|
|
|
@ -210,7 +210,7 @@ func (c *Client) updateNewMessage(update *client.UpdateNewMessage) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// OTR support (I do not know why would you need it, seriously)
|
// OTR support (I do not know why would you need it, seriously)
|
||||||
if !strings.HasPrefix(text, "?OTR") {
|
if !(strings.HasPrefix(text, "?OTR") || c.Session.RawMessages) {
|
||||||
var prefix strings.Builder
|
var prefix strings.Builder
|
||||||
prefix.WriteString(c.messageToPrefix(update.Message, c.formatContent(file, filename)))
|
prefix.WriteString(c.messageToPrefix(update.Message, c.formatContent(file, filename)))
|
||||||
if text != "" {
|
if text != "" {
|
||||||
|
|
Loading…
Reference in a new issue