mirror of
https://github.com/ergochat/ergo.git
synced 2025-12-20 02:00:11 -08:00
initial persistent history implementation
This commit is contained in:
parent
0d5a4fd584
commit
33dac4c0ba
34 changed files with 2229 additions and 595 deletions
|
|
@ -217,7 +217,7 @@ information on the settings and their possible values, see HELP SET.`,
|
|||
helpStrings: []string{
|
||||
`Syntax $bSET <setting> <value>$b
|
||||
|
||||
Set modifies your account settings. The following settings are available:`,
|
||||
SET modifies your account settings. The following settings are available:`,
|
||||
|
||||
`$bENFORCE$b
|
||||
'enforce' lets you specify a custom enforcement mechanism for your registered
|
||||
|
|
@ -247,6 +247,22 @@ lines for join and part. This provides more information about the context of
|
|||
messages, but may be spammy. Your options are 'always', 'never', and the default
|
||||
of 'commands-only' (the messages will be replayed in /HISTORY output, but not
|
||||
during autoreplay).`,
|
||||
`$bALWAYS-ON$b
|
||||
'always-on' controls whether your nickname/identity will remain active
|
||||
even while you are disconnected from the server. Your options are 'true',
|
||||
'false', and 'default' (use the server default value).`,
|
||||
`$bAUTOREPLAY-MISSED$b
|
||||
'autoreplay-missed' is only effective for always-on clients. If enabled,
|
||||
if you have at most one active session, the server will remember the time
|
||||
you disconnect and then replay missed messages to you when you reconnect.
|
||||
Your options are 'on' and 'off'.`,
|
||||
`$bDM-HISTORY$b
|
||||
'dm-history' is only effective for always-on clients. It lets you control
|
||||
how the history of your direct messages is stored. Your options are:
|
||||
1. 'off' [no history]
|
||||
2. 'ephemeral' [a limited amount of temporary history, not stored on disk]
|
||||
3. 'on' [history stored in a permanent database, if available]
|
||||
4. 'default' [use the server default]`,
|
||||
},
|
||||
authRequired: true,
|
||||
enabled: servCmdRequiresAccreg,
|
||||
|
|
@ -349,6 +365,31 @@ func displaySetting(settingName string, settings AccountSettings, client *Client
|
|||
nsNotice(rb, client.t("Bouncer functionality is currently enabled for your account"))
|
||||
}
|
||||
}
|
||||
case "always-on":
|
||||
stored := settings.AlwaysOn
|
||||
actual := client.AlwaysOn()
|
||||
nsNotice(rb, fmt.Sprintf(client.t("Your stored always-on setting is: %s"), persistentStatusToString(stored)))
|
||||
if actual {
|
||||
nsNotice(rb, client.t("Given current server settings, your client is always-on"))
|
||||
} else {
|
||||
nsNotice(rb, client.t("Given current server settings, your client is not always-on"))
|
||||
}
|
||||
case "autoreplay-missed":
|
||||
stored := settings.AutoreplayMissed
|
||||
if stored {
|
||||
if client.AlwaysOn() {
|
||||
nsNotice(rb, client.t("Autoreplay of missed messages is enabled"))
|
||||
} else {
|
||||
nsNotice(rb, client.t("You have enabled autoreplay of missed messages, but you can't receive them because your client isn't set to always-on"))
|
||||
}
|
||||
} else {
|
||||
nsNotice(rb, client.t("Your account is not configured to receive autoreplayed missed messages"))
|
||||
}
|
||||
case "dm-history":
|
||||
effectiveValue := historyEnabled(config.History.Persistent.DirectMessages, settings.DMHistory)
|
||||
csNotice(rb, fmt.Sprintf(client.t("Your stored direct message history setting is: %s"), historyStatusToString(settings.DMHistory)))
|
||||
csNotice(rb, fmt.Sprintf(client.t("Given current server settings, your direct message history setting is: %s"), historyStatusToString(effectiveValue)))
|
||||
|
||||
default:
|
||||
nsNotice(rb, client.t("No such setting"))
|
||||
}
|
||||
|
|
@ -429,6 +470,37 @@ func nsSetHandler(server *Server, client *Client, command string, params []strin
|
|||
return
|
||||
}
|
||||
}
|
||||
case "always-on":
|
||||
var newValue PersistentStatus
|
||||
newValue, err = persistentStatusFromString(params[1])
|
||||
// "opt-in" and "opt-out" don't make sense as user preferences
|
||||
if err == nil && newValue != PersistentOptIn && newValue != PersistentOptOut {
|
||||
munger = func(in AccountSettings) (out AccountSettings, err error) {
|
||||
out = in
|
||||
out.AlwaysOn = newValue
|
||||
return
|
||||
}
|
||||
}
|
||||
case "autoreplay-missed":
|
||||
var newValue bool
|
||||
newValue, err = utils.StringToBool(params[1])
|
||||
if err == nil {
|
||||
munger = func(in AccountSettings) (out AccountSettings, err error) {
|
||||
out = in
|
||||
out.AutoreplayMissed = newValue
|
||||
return
|
||||
}
|
||||
}
|
||||
case "dm-history":
|
||||
var newValue HistoryStatus
|
||||
newValue, err = historyStatusFromString(params[1])
|
||||
if err == nil {
|
||||
munger = func(in AccountSettings) (out AccountSettings, err error) {
|
||||
out = in
|
||||
out.DMHistory = newValue
|
||||
return
|
||||
}
|
||||
}
|
||||
default:
|
||||
err = errInvalidParams
|
||||
}
|
||||
|
|
@ -480,6 +552,9 @@ func nsGhostHandler(server *Server, client *Client, command string, params []str
|
|||
} else if ghost == client {
|
||||
nsNotice(rb, client.t("You can't GHOST yourself (try /QUIT instead)"))
|
||||
return
|
||||
} else if ghost.AlwaysOn() {
|
||||
nsNotice(rb, client.t("You can't GHOST an always-on client"))
|
||||
return
|
||||
}
|
||||
|
||||
authorized := false
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue