Skip to content
This repository has been archived by the owner on May 22, 2024. It is now read-only.

Commit

Permalink
docs: 📝 Update docs for match.py
Browse files Browse the repository at this point in the history
  • Loading branch information
HarHarLinks committed Nov 25, 2021
1 parent 2d63cbe commit 838be53
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions doc/manual/match.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ match = botlib.Match(

The room, event, and bot arguments are neccesary. The room and event arguments should be the same as the arguments of the handler function. The bot argument should be the same as the instance of the Bot class. This class is intended to be used with non-message events, as the MessageMatch class is a child class of this class, and has message-specific methods. A list of methods for the Match class is shown below.

#### <div id="match-methods">List of Methods:</div>
#### List of Methods:

| Method | Explanation |
| ------------------------------- | --------------------------------------------------------------- |
Expand Down Expand Up @@ -70,13 +70,25 @@ async def example(room, message):
#Respond to help command
```

A list of methods for the Match class is shown below. [Methods from the Match class](#match-methods) can also be used with the MessageMatch class.
It is also possible to match by mention of the bot's username, matrix ID, etc.
In the next example, we can use the prefix or mention the bot to show its help message.

```python
bot.listener.on_message_event
async def help(room, message):
match = botlib.MessageMatch(room, message, bot, "!")
if match.command("help") and (match.prefix() or match.mention()):
#Respond to help command
```

A list of methods for the Match class is shown below. [Methods from the Match class](#list-of-methods) can also be used with the MessageMatch class.

#### List of Methods:

| Method | Explanation |
| ----------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `MessageMatch.command()` or `MessageMatch.command(command)` | The "command" is the beginning of messages that are intended to be commands, but after the prefix; e.g. "help". Returns the command if the command argument is empty. Returns True if the command argument is equivalent to the command. |
| `MessageMatch.prefix()` | Returns True if the message begins with the prefix specified during the initialization of the instance of the MessageMatch class. Returns True if no prefix was specified during the initialization. |
| `MessageMatch.mention()` | Returns True if the message begins with the bot's display name, disambiguated display name, matrix ID, or pill (HTML link to the bot via matrix.to) if formatted_body is present. |
| `MessageMatch.args()` | Returns a list of strings; each string is part of the message separated by a space, with the exception of the part of the message before the first space (the prefix and command). Returns an empty list if it is a single-word command. |
| `MessageMatch.contains(string)` | Returns True if the message contains the value specified in the string argument. |
| `MessageMatch.contains(string)` | Returns True if the message contains the value specified in the string argument. |

0 comments on commit 838be53

Please sign in to comment.