Add improvements and logs
This commit is contained in:
@@ -81,6 +81,21 @@ async def ping_matrix(evt: CommandEvent) -> EventID:
|
|||||||
return await evt.reply("Your Matrix login is working.")
|
return await evt.reply("Your Matrix login is working.")
|
||||||
|
|
||||||
|
|
||||||
|
@command_handler(needs_auth=True, needs_matrix_puppeting=True, help_section=SECTION_AUTH,
|
||||||
|
help_text="Clear the Matrix sync token stored for your custom puppet.")
|
||||||
|
async def clear_cache_matrix(evt: CommandEvent) -> EventID:
|
||||||
|
puppet = pu.Puppet.get(evt.sender.tgid)
|
||||||
|
if not puppet.is_real_user:
|
||||||
|
return await evt.reply("You are not logged in with your Matrix account.")
|
||||||
|
try:
|
||||||
|
puppet.stop()
|
||||||
|
puppet.next_batch = None
|
||||||
|
await puppet.start()
|
||||||
|
except InvalidAccessToken:
|
||||||
|
return await evt.reply("Your access token is invalid.")
|
||||||
|
return await evt.reply("Cleared cache successfully.")
|
||||||
|
|
||||||
|
|
||||||
async def enter_matrix_token(evt: CommandEvent) -> EventID:
|
async def enter_matrix_token(evt: CommandEvent) -> EventID:
|
||||||
evt.sender.command_status = None
|
evt.sender.command_status = None
|
||||||
|
|
||||||
|
|||||||
@@ -14,12 +14,13 @@
|
|||||||
# You should have received a copy of the GNU Affero General Public License
|
# You should have received a copy of the GNU Affero General Public License
|
||||||
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
from typing import List, Optional, Tuple
|
from typing import List, Optional, Tuple
|
||||||
|
import logging
|
||||||
import codecs
|
import codecs
|
||||||
import base64
|
import base64
|
||||||
import re
|
import re
|
||||||
|
|
||||||
from telethon.errors import (InviteHashInvalidError, InviteHashExpiredError, OptionsTooMuchError,
|
from telethon.errors import (InviteHashInvalidError, InviteHashExpiredError, OptionsTooMuchError,
|
||||||
UserAlreadyParticipantError)
|
UserAlreadyParticipantError, ChatIdInvalidError)
|
||||||
from telethon.tl.patched import Message
|
from telethon.tl.patched import Message
|
||||||
from telethon.tl.types import (User as TLUser, TypeUpdates, MessageMediaGame, MessageMediaPoll,
|
from telethon.tl.types import (User as TLUser, TypeUpdates, MessageMediaGame, MessageMediaPoll,
|
||||||
TypePeer)
|
TypePeer)
|
||||||
@@ -143,7 +144,11 @@ async def join(evt: CommandEvent) -> Optional[EventID]:
|
|||||||
return await evt.reply(f"Invited you to portal of {portal.title}")
|
return await evt.reply(f"Invited you to portal of {portal.title}")
|
||||||
else:
|
else:
|
||||||
await evt.reply(f"Creating room for {chat.title}... This might take a while.")
|
await evt.reply(f"Creating room for {chat.title}... This might take a while.")
|
||||||
await portal.create_matrix_room(evt.sender, chat, [evt.sender.mxid])
|
try:
|
||||||
|
await portal.create_matrix_room(evt.sender, chat, [evt.sender.mxid])
|
||||||
|
except ChatIdInvalidError as e:
|
||||||
|
logging.getLogger("mau.commands").info(updates.stringify())
|
||||||
|
raise e
|
||||||
return await evt.reply(f"Created room for {portal.title}")
|
return await evt.reply(f"Created room for {portal.title}")
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
|||||||
@@ -545,7 +545,8 @@ class PortalMetadata(BasePortal, ABC):
|
|||||||
await self.main_intent.remove_room_alias(self._get_alias_localpart())
|
await self.main_intent.remove_room_alias(self._get_alias_localpart())
|
||||||
self.username = username or None
|
self.username = username or None
|
||||||
if self.username:
|
if self.username:
|
||||||
await self.main_intent.add_room_alias(self.mxid, self._get_alias_localpart())
|
await self.main_intent.add_room_alias(self.mxid, self._get_alias_localpart(),
|
||||||
|
override=True)
|
||||||
if self.public_portals:
|
if self.public_portals:
|
||||||
await self.main_intent.set_join_rule(self.mxid, "public")
|
await self.main_intent.set_join_rule(self.mxid, "public")
|
||||||
else:
|
else:
|
||||||
|
|||||||
Reference in New Issue
Block a user