diff --git a/public/vroom.pl b/public/vroom.pl index 3a7e73c..fa3979d 100755 --- a/public/vroom.pl +++ b/public/vroom.pl @@ -218,6 +218,17 @@ helper valid_room_name => sub { return $ret; }; +# Generate a random name +helper get_random_name => sub { + my $self = shift; + my $name = join '' => map{('a'..'z','0'..'9')[rand 36]} 0..9; + # Get another one if already taken + while ($self->get_room($name)){ + $name = $self->get_random_name(); + } + return $name; +}; + any '/' => 'index'; get '/about' => sub { @@ -257,7 +268,7 @@ get '/goodby/(:room)' => sub { post '/create' => sub { my $self = shift; $self->res->headers->cache_control('max-age=1, no-cache'); - my $name = $self->param('roomName') || lc guid_string(); + my $name = $self->param('roomName') || $self->get_random_name(); $self->login; unless ($self->valid_room_name($name)){ return $self->render('error',