Compare commits

..

4 Commits

Author SHA1 Message Date
6623dd46c0 Assorted minor fixes 2022-05-02 03:13:18 -04:00
e35082bbea Improve "whoami", especially for users with no KakaoTalk ID
Also show whether the KakaoTalk ID is searchable or not
2022-05-02 02:52:55 -04:00
f1e08caee0 Fix token renewal for already logged-in users 2022-05-02 02:50:49 -04:00
d0dc921fd4 Add missing return on "whoami" error 2022-05-02 02:23:15 -04:00
6 changed files with 13 additions and 13 deletions

View File

@ -66,7 +66,7 @@ async def login(evt: CommandEvent) -> None:
"action": "Login",
"room_id": evt.room_id,
"next": enter_password,
"email": evt.args[0],
"email": email,
}
""" TODO Implement web login

View File

@ -65,13 +65,15 @@ async def whoami(evt: CommandEvent) -> None:
own_info = None
except CommandException as e:
await evt.reply(f"Error from KakaoTalk: {e}")
return
if own_info:
uuid = f"`{own_info.more.uuid}` ({'' if own_info.more.uuidSearchable else 'not '}searchable)" if own_info.more.uuid else "_none_"
await evt.reply(
f"You're logged in as `{own_info.more.uuid}` (nickname: {own_info.more.nickName}, user ID: {evt.sender.ktid})."
f"You're logged in as **{own_info.more.nickName}** (KakaoTalk ID: {uuid}, internal ID: `{evt.sender.ktid}`)"
)
else:
await evt.reply(
f"You're logged in, but the bridge is unable to retrieve your profile information (user ID: {evt.sender.ktid})."
f"You're logged in, but the bridge is unable to retrieve your profile information (internal ID: {evt.sender.ktid})"
)
@ -94,7 +96,7 @@ async def ping(evt: CommandEvent) -> None:
management_only=True,
help_section=SECTION_CONNECTION,
help_text="(Re)connect to KakaoTalk chats & sync any missed chat updates",
help_args="[number_of_channels_to_sync]",
help_args="[_number of channels to sync_]",
)
async def sync(evt: CommandEvent) -> None:
try:
@ -102,7 +104,7 @@ async def sync(evt: CommandEvent) -> None:
except IndexError:
sync_count = None
except ValueError:
await evt.reply("**Usage:** `sync [number_of_channels_to_sync]`")
await evt.reply("The number of channels to sync must either be an integer, or be left unspecified.")
return
await evt.mark_read()

View File

@ -32,7 +32,6 @@ __all__ = [
"init",
"Message",
"Portal",
"ThreadType",
"Puppet",
"User",
]

View File

@ -93,9 +93,7 @@ bridge:
# {userid} is replaced with the user ID of the KakaoTalk user.
username_template: "kakaotalk_{userid}"
# Displayname template for KakaoTalk users.
# {displayname} is replaced with the display name of the KakaoTalk user
# as defined below in displayname_preference.
# Keys available for displayname_preference are also available here.
# {displayname} is replaced with the display name of the KakaoTalk user.
displayname_template: "{displayname} (KT)"
# The prefix for commands. Only required in non-management rooms.

View File

@ -135,7 +135,7 @@ class User(DBUser, BaseUser):
self._is_connected = None
self._connection_time = time.monotonic()
self._sync_lock = SimpleLock(
"Waiting for thread sync to finish before handling %s", log=self.log
"Waiting for channel sync to finish before handling %s", log=self.log
)
self._is_rpc_reconnecting = False
self._logged_in_info = None
@ -348,7 +348,7 @@ class User(DBUser, BaseUser):
state_event=BridgeStateEvent.TRANSIENT_DISCONNECT,
)
await asyncio.sleep(60)
await self.reload_session(event_id, retries - 1, is_startup)
await self.reload_session(event_id, retries - 1)
else:
await self.send_bridge_notice(
notice,
@ -685,8 +685,9 @@ class User(DBUser, BaseUser):
if self.temp_disconnect_notices:
await self.send_bridge_notice(
"Disconnected from KakaoTalk: backend helper module exited. "
"Will reconnect once module resumes."
"Will reconnect once the module resumes."
)
await self.push_bridge_state(BridgeStateEvent.TRANSIENT_DISCONNECT)
self._is_rpc_reconnecting = True
asyncio.create_task(self.reload_session())

View File

@ -598,7 +598,7 @@ export default class PeerClient {
const oAuthClient = await OAuthApiClient.create()
const res = await oAuthClient.renew(req.oauth_credential)
if (res.success && userClient) {
await userClient.setCredential(res.result)
await userClient.setCredential(res.result.credential)
}
return res
}