impromptu: pronounceable MUC names

Signed-off-by: Maxime “pep” Buquet <pep@bouah.net>
This commit is contained in:
Maxime “pep” Buquet 2021-12-25 00:47:37 +01:00
parent db9b423000
commit ca3cb8fae0
Signed by: pep
GPG key ID: DEDA74AEECA9D0F2
2 changed files with 23 additions and 1 deletions

View file

@ -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)

21
poezio/utils.py Normal file
View file

@ -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