# MessageData

### Table of Contents

1. [Events](#events)
2. [Public Functions](#public-functions)

***

## <mark style="color:purple;">Events</mark>

### logNewMsg

This event is triggered when a new message is posted. It logs the details of the message.

### logRemoveMsg

This event is triggered when a message is removed. It logs the ID of the message that was removed.

### logUpdateMsgStats

This event is triggered when the statistics of a message are updated. It logs the type of statistic, message ID, the updated value of the statistic, and tips.

***

### <mark style="color:purple;">Public Function</mark>

### getPoster

This function returns the address of the user or group that posted a specific message.

**Inputs**

| Name  | Type    | Description                                             | Example |
| ----- | ------- | ------------------------------------------------------- | ------- |
| msgID | uint256 | The ID of the message to check for the poster's address | 1       |

**Outputs**

| Name | Type    | Description                                       |
| ---- | ------- | ------------------------------------------------- |
|      | address | The address of the member that posted the message |

**Example**

Using ethers.js to call the `getPoster` function:

```javascript
const contract = new ethers.Contract(contractAddress, contractABI, provider);

let msgID = 1;

async function getPoster() {
    const poster = await contract.getPoster(msgID);
    console.log(`The message was posted by: ${poster}`);
}

getPoster();
```

***

### getInGroups

This function returns a list of group IDs in which a specific message was posted.

**Inputs**

| Name  | Type    | Description                        | Example |
| ----- | ------- | ---------------------------------- | ------- |
| msgID | uint256 | The ID of the message to check for | 1       |

**Outputs**

| Name | Type       | Description                                          |
| ---- | ---------- | ---------------------------------------------------- |
|      | uint256\[] | An array of group IDs that the message was posted in |

**Example**

Using ethers.js to call the `getInGroups` function:

```javascript
const contract = new ethers.Contract(contractAddress, contractABI, provider);

let msgID = 1;

async function getInGroups() {
    const groups = await contract.getInGroups(msgID);
    console.log(`The message was posted in groups: ${groups}`);
}

getInGroups();
```

***

### getMsgCommentLevel

This function returns the comment level of a post. If the return value is 0, comments are open. If the return value is 1, comments are closed.

**Inputs**

| Name  | Type    | Description                        | Example |
| ----- | ------- | ---------------------------------- | ------- |
| msgID | uint256 | The ID of the message to check for | 1       |

**Outputs**

| Name | Type    | Description                      |
| ---- | ------- | -------------------------------- |
|      | uint256 | The comment level of the message |

**Example**

Using ethers.js to call the `getMsgCommentLevel` function:

```javascript
const contract = new ethers.Contract(contractAddress, contractABI, provider);

let msgID = 1;

async function getMsgCommentLevel() {
    const commentLevel = await contract.getMsgCommentLevel(msgID);
    console.log(`The comment level of the message is: ${commentLevel}`);
}

getMsgCommentLevel();
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.kuthulu.xyz/contracts/messagedata.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
