summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMaxime “pep” Buquet <pep@bouah.net>2021-12-25 00:47:37 +0100
committerMaxime “pep” Buquet <pep@bouah.net>2021-12-25 00:47:37 +0100
commitca3cb8fae0a5883973ca84d61c2602c7ab3637e2 (patch)
tree3787d0819d5ed67ce45358b7238f72ef298f9a02
parentdb9b423000e9a1b0c595a49d69d8e723eeafed3d (diff)
downloadpoezio-ca3cb8fae0a5883973ca84d61c2602c7ab3637e2.tar.gz
poezio-ca3cb8fae0a5883973ca84d61c2602c7ab3637e2.tar.bz2
poezio-ca3cb8fae0a5883973ca84d61c2602c7ab3637e2.tar.xz
poezio-ca3cb8fae0a5883973ca84d61c2602c7ab3637e2.zip
impromptu: pronounceable MUC names
Signed-off-by: Maxime “pep” Buquet <pep@bouah.net>
-rw-r--r--poezio/core/core.py3
-rw-r--r--poezio/utils.py21
2 files changed, 23 insertions, 1 deletions
diff --git a/poezio/core/core.py b/poezio/core/core.py
index ffdd11d1..17e352de 100644
--- a/poezio/core/core.py
+++ b/poezio/core/core.py
@@ -42,6 +42,7 @@ from poezio import events
from poezio import theming
from poezio import timed_events
from poezio import windows
+from poezio import utils
from poezio.bookmarks import (
BookmarkList,
@@ -1005,7 +1006,7 @@ class Core:
return
nick = self.own_nick
- localpart = uuid.uuid4().hex
+ localpart = utils.pronounceable()
room_str = '{!s}@{!s}'.format(localpart, default_muc)
try:
room = JID(room_str)
diff --git a/poezio/utils.py b/poezio/utils.py
new file mode 100644
index 00000000..124d2002
--- /dev/null
+++ b/poezio/utils.py
@@ -0,0 +1,21 @@
+#!/usr/bin/env python3
+# -*- coding: utf-8 -*-
+
+"""
+ Utilities
+"""
+
+from random import choice
+
+VOWELS = 'aiueo'
+CONSONANTS = 'bcdfghjklmnpqrstvwxz'
+
+
+def pronounceable(length: int = 6) -> str:
+ """Generates a pronounceable name"""
+ out = ''
+ vowels = choice((True, False))
+ for _ in range(0, length):
+ out += choice(VOWELS if vowels else CONSONANTS)
+ vowels = not vowels
+ return out