add x selections
This commit is contained in:
@@ -140,6 +140,37 @@ async def archive_message(message_id: int) -> bool:
|
||||
return False
|
||||
|
||||
|
||||
async def archive_messages(message_ids: List[str]) -> Tuple[Optional[str], bool]:
|
||||
"""
|
||||
Archive multiple messages by their IDs.
|
||||
|
||||
Args:
|
||||
message_ids: A list of message IDs to archive.
|
||||
|
||||
Returns:
|
||||
A tuple containing an optional output string and a boolean indicating success.
|
||||
"""
|
||||
try:
|
||||
ids_str = " ".join(message_ids)
|
||||
cmd = f"himalaya message move Archives {ids_str}"
|
||||
|
||||
process = await asyncio.create_subprocess_shell(
|
||||
cmd,
|
||||
stdout=asyncio.subprocess.PIPE,
|
||||
stderr=asyncio.subprocess.PIPE,
|
||||
)
|
||||
stdout, stderr = await process.communicate()
|
||||
|
||||
if process.returncode == 0:
|
||||
return stdout.decode(), True
|
||||
else:
|
||||
logging.error(f"Error archiving messages: {stderr.decode()}")
|
||||
return None, False
|
||||
except Exception as e:
|
||||
logging.error(f"Exception during message archiving: {e}")
|
||||
return None, False
|
||||
|
||||
|
||||
async def get_message_content(message_id: int) -> Tuple[Optional[str], bool]:
|
||||
"""
|
||||
Retrieve the content of a message by its ID.
|
||||
|
||||
Reference in New Issue
Block a user