Skip to content

Commit

Permalink
#157 [LS] - Add random name generator.
Browse files Browse the repository at this point in the history
  • Loading branch information
steffano0 committed Jan 31, 2025
1 parent bd845b6 commit 283a061
Show file tree
Hide file tree
Showing 3 changed files with 121 additions and 8 deletions.
12 changes: 4 additions & 8 deletions gui/hosting.go
Original file line number Diff line number Diff line change
Expand Up @@ -529,14 +529,6 @@ func (h *hostData) handleOnStartMeeting(b *uiBuilder) {
username := b.get("inpMeetingUsername").(gtki.Entry)
password := b.get("inpMeetingPassword").(gtki.Entry)

if h.asSuperUser {
u, _ := username.GetText()
if len(u) == 0 {
h.u.reportError(i18n().Sprintf("The username is required"))
return
}
}

h.handlerOnStartMeeting(username, password)
}

Expand Down Expand Up @@ -570,6 +562,10 @@ func (h *hostData) handlerOnStartMeeting(u, p gtki.Entry) {
h.meetingUsername, _ = u.GetText()
h.meetingPassword, _ = p.GetText()

if h.meetingUsername == "" {
h.meetingUsername = getRandomName()
}

h.startMeetingHandler()
}

Expand Down
3 changes: 3 additions & 0 deletions gui/invite_meeting.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,9 @@ func (u *gtkUI) handleOnJoinMeeting(b *uiBuilder) {

url, _ := entMeetingID.GetText()
username, _ := entScreenName.GetText()
if username == "" {
username = getRandomName()
}
password, _ := entMeetingPassword.GetText()

// TODO: remove this if we show a custom input field to enter
Expand Down
114 changes: 114 additions & 0 deletions gui/names_generator.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
package gui

import "math/rand"

var names = [...]string{
"Shadow",
"Phoenix",
"Storm",
"Dragon",
"Wolf",
"Tiger",
"Eagle",
"Lion",
"Falcon",
"Bear",
"Cobra",
"Raven",
"Viper",
"Panther",
"Hawk",
"Fox",
"Shark",
"Owl",
"Jaguar",
"Lotus",
"Crystal",
"Diamond",
"Ruby",
"Sapphire",
"Emerald",
"Pearl",
"Jade",
"Onyx",
"Topaz",
"Opal",
"Star",
"Moon",
"Sun",
"Comet",
"Nova",
"Atlas",
"Titan",
"Echo",
"Thunder",
"Lightning",
"Blaze",
"Frost",
"Ice",
"Steel",
"Iron",
"Stone",
"Oak",
"Maple",
"Pine",
"Willow",
"River",
"Ocean",
"Lake",
"Mountain",
"Canyon",
"Valley",
"Cloud",
"Rain",
"Wind",
"Arrow",
"Blade",
"Shield",
"Saber",
"Dagger",
"Hammer",
"Anvil",
"Crown",
"Knight",
"Warrior",
"Guardian",
"Sentinel",
"Hunter",
"Scout",
"Ranger",
"Ghost",
"Spirit",
"Phantom",
"Legend",
"Myth",
"Dawn",
"Dusk",
"Twilight",
"Aurora",
"Winter",
"Summer",
"Spring",
"Autumn",
"Vector",
"Pixel",
"Cipher",
"Matrix",
"Nexus",
"Core",
"Pulse",
"Spark",
"Wave",
"Prism",
"Quartz",
"Obsidian",
"Sage",
"Oracle",
"Cipher",
"Edge",
}

func getRandomName() string {
index := rand.Intn(len(names)) //nolint:gosec // G404: Use of weak random number generator (math/rand instead of crypto/rand)
return names[index]
}

0 comments on commit 283a061

Please sign in to comment.