summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMaxime “pep” Buquet <pep@bouah.net>2022-03-01 00:37:19 +0100
committermathieui <mathieui@mathieui.net>2022-03-01 22:38:03 +0100
commit0676cec53eec893030baf3df2a99baa2e5174607 (patch)
tree77430c42d38c8ec6f728279888a03e14b225381e
parentcdf38ace9f91c652a866d0e06c874cd31b7d14e0 (diff)
downloadpoezio-0676cec53eec893030baf3df2a99baa2e5174607.tar.gz
poezio-0676cec53eec893030baf3df2a99baa2e5174607.tar.bz2
poezio-0676cec53eec893030baf3df2a99baa2e5174607.tar.xz
poezio-0676cec53eec893030baf3df2a99baa2e5174607.zip
impromptu: types, fstrings, naming
Signed-off-by: Maxime “pep” Buquet <pep@bouah.net>
-rw-r--r--poezio/core/core.py19
1 files changed, 10 insertions, 9 deletions
diff --git a/poezio/core/core.py b/poezio/core/core.py
index d4ce6443..bc57024c 100644
--- a/poezio/core/core.py
+++ b/poezio/core/core.py
@@ -30,7 +30,7 @@ from typing import (
)
from xml.etree import ElementTree as ET
-from slixmpp import JID, InvalidJID
+from slixmpp import Iq, JID, InvalidJID
from slixmpp.util import FileSystemPerJidCache
from slixmpp.xmlstream.handler import Callback
from slixmpp.exceptions import IqError, IqTimeout, XMPPError
@@ -943,7 +943,7 @@ class Core:
)
return True
- def _impromptu_room_form(self, room):
+ def _impromptu_room_form(self, room) -> Iq:
fields = [
('hidden', 'FORM_TYPE', 'http://jabber.org/protocol/muc#roomconfig'),
('boolean', 'muc#roomconfig_changesubject', True),
@@ -1009,12 +1009,12 @@ class Core:
retries = 3
while retries > 0:
localpart = utils.pronounceable()
- room_str = '{!s}@{!s}'.format(localpart, default_muc
+ room_str = f'{localpart}@{default_muc}'
try:
room = JID(room_str)
except InvalidJID:
self.information(
- 'The generated XMPP address is invalid: {!s}'.format(room_str),
+ f'The generated XMPP address is invalid: {room_str}',
'Error'
)
return None
@@ -1042,7 +1042,7 @@ class Core:
self.open_new_room(room, self.own_nick).join()
- async def join_callback(_presence):
+ async def configure_and_invite(_presence):
iq = self._impromptu_room_form(room)
try:
await iq.send()
@@ -1051,15 +1051,16 @@ class Core:
# TODO: destroy? leave room.
return None
- self.information('Room %s created' % room, 'Info')
+ self.information(f'Room {room} created', 'Info')
for jid in jids:
await self.invite(jid, room, force_mediated=True)
- self.information('Invited %s to %s' % (', '.join(jids), room.bare), 'Info')
+ jids_str = ', '.join(jids)
+ self.information(f'Invited {jids_str} to {room.bare}', 'Info')
self.xmpp.add_event_handler(
- 'muc::%s::groupchat_subject' % room.bare,
- join_callback,
+ f'muc::{room.bare}::groupchat_subject',
+ configure_and_invite,
disposable=True,
)