Timestamp Events

Classes for representing timestamp-related events such as read receipts, delivery receipts, and message status updates.

Overview

Timestamp events track when messages are delivered, read, or when threads are marked as seen/unseen. These events help you monitor message status and user engagement.

from fbchat_muqit import Client, EventType
from fbchat_muqit import ReadReceipt, DeliveryReceipt

client = Client(cookies_file_path="cookies.json")

@client.event(EventType.READ_RECEIPT)
async def on_message_read(event: ReadReceipt):
    print(f"User {event.user_id} read messages in thread {event.thread_id}")

@client.event(EventType.DELIVERY_RECEIPT)
async def on_message_delivered(event: DeliveryReceipt):
    print(f"Messages {event.message_id} were delivered")

Read and Delivery Events

Read Receipt

class fbchat_muqit.ReadReceipt

Bases: Struct

When a User seen messages in a thread.

folder: Value

The Thread Folder where the user seen messages

thread_id: Value

The Id of that Thread.

timestamp: str

timestamp of the message

user_id: str

The user who seen the message

watermark_timestamp: str

seen timestamp

Delivery Receipt

class fbchat_muqit.DeliveryReceipt

Bases: Struct

Client’s Delivered message Delivery information

message_id: List[str]

List of Delivered message Id

thread_id: Value

The Thread Id where message was Delivered.

timestamp: int

Delivered timestamp

user_id: Value

The sender of the message.

Mark Status Events

Mark Folder Seen

class fbchat_muqit.MarkFolderSeen

Bases: Struct

Usually received when you open messenger :)

folders: List[str]

Usually Inbox can be Archive, Spam

timestamp: str

The seen timestamp

Mark Read

class fbchat_muqit.MarkRead

Bases: Struct

Client’s seen message information.

folder: Value | None

The Thread Folder where the event occurred such as Inbox, Spam, Archive

thread_ids: List[Value]

List of seen messages Thread Id

timestamp: str

The message timestamp

watermark_timestamp: str

The seen timestamp

Mark Unread

class fbchat_muqit.MarkUnread

Bases: Struct

Client’s Unread marking Thread related information.

thread_ids: List[Value]

List of Unread marked Thread Ids.

timestamp: str

The timestamp of the event

Usage Examples

Tracking Read Receipts

from fbchat_muqit import ReadReceipt, EventType, Client
import time

# Store message read status
message_reads = {}
client = Client(cookies_file_path="cookies.json")

@client.event(EventType.MARK_READ)
async def on_message_read(event: ReadReceipt):
   """Handle when someone reads your messages."""
   user_id = event.user_id
   thread_id = event.thread_id
   read_time = int(event.watermark_timestamp)

   print(f"👁️ User {user_id} read messages in thread {thread_id}")
   print(f"   Read at: {time.ctime(read_time / 1000)}")

   # Store read status
   if thread_id not in message_reads:
       message_reads[thread_id] = {}

   message_reads[thread_id][user_id] = read_time

   # Fetch user info
   users = await client.fetch_user_info(user_id)
   if user_id in users:
       user_name = users[user_id].name
       print(f"   Reader: {user_name}")

Monitoring Thread Status

from fbchat_muqit import MarkRead, MarkUnread, MarkFolderSeen, Client, EventType

client = Client(cookies_file_path="cookies.json")


@client.event(EventType.MARK_READ)
async def on_mark_read(event: MarkRead):
   """Handle when threads are marked as read."""
   for thread_key in event.thread_ids:
       thread_id = str(thread_key)
       print(f"✉️ Thread {thread_id} marked as read")


@client.event(EventType.MARK_UNREAD)
async def on_mark_unread(event: MarkUnread):
   """Handle when threads are marked as unread."""
   for thread_key in event.thread_ids:
       thread_id = str(thread_key)
       print(f"📬 Thread {thread_id} marked as unread")


@client.event(EventType.MESSAGE_SEEN)
async def on_folder_seen(event: MarkFolderSeen):
   """Handle when folders are marked as seen."""
   print(f"👀 Folders seen: {', '.join(event.folders)}")
   print(f"   Timestamp: {event.timestamp}")

See Also