option to specify minimum length for upstream nicks
This commit is contained in:
parent
b470b9a5b3
commit
f4025ad513
11
NTFConfig.go
11
NTFConfig.go
@ -8,11 +8,12 @@ import (
|
|||||||
// NTFConfig keeps track of setup properties as well as runtime state.
|
// NTFConfig keeps track of setup properties as well as runtime state.
|
||||||
// FIXME separate compile-time and run-time properties into separate files
|
// FIXME separate compile-time and run-time properties into separate files
|
||||||
type NTFConfig struct {
|
type NTFConfig struct {
|
||||||
HubAddr string
|
HubAddr string
|
||||||
HubDescription string
|
HubDescription string
|
||||||
HubSecNick string // Nickname of Hub-Security to exclude (e.g. "PtokaX")
|
HubSecNick string // Nickname of Hub-Security to exclude (e.g. "PtokaX")
|
||||||
BotAPIKey string
|
HubNickMinChars int
|
||||||
GroupChatID int64
|
BotAPIKey string
|
||||||
|
GroupChatID int64
|
||||||
|
|
||||||
// Map of telegram user IDs to NMDC nicks
|
// Map of telegram user IDs to NMDC nicks
|
||||||
KnownUsers map[int64]string
|
KnownUsers map[int64]string
|
||||||
|
@ -544,6 +544,12 @@ func (this *NTFServer) HandleDirectMessage(update telegram.Update) error {
|
|||||||
|
|
||||||
} else if strings.HasPrefix(msg, "/join ") {
|
} else if strings.HasPrefix(msg, "/join ") {
|
||||||
requestedHubNick := msg[6:]
|
requestedHubNick := msg[6:]
|
||||||
|
|
||||||
|
// Minimum nick lengths
|
||||||
|
if len(requestedHubNick) < this.config.HubNickMinChars {
|
||||||
|
return respond(fmt.Sprintf("Upstream nickname '%s' should be at least %d characters long", requestedHubNick, this.config.HubNickMinChars))
|
||||||
|
}
|
||||||
|
|
||||||
err := this.registerUser(userID, requestedHubNick)
|
err := this.registerUser(userID, requestedHubNick)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Printf("Failed to register user: %s", err.Error())
|
log.Printf("Failed to register user: %s", err.Error())
|
||||||
|
Loading…
Reference in New Issue
Block a user