-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
58 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{ | ||
"label": "Example", | ||
"position": 5, | ||
"link": { | ||
"type": "generated-index", | ||
"description": "5 minutes to learn the most important SwiBots concepts." | ||
}, | ||
"collapsed": true | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
# Creating Your First Bot: Echo Bot | ||
|
||
In this example, we'll create a simple echo bot using SwiBots. This bot will respond to any message it receives by sending the same message back to the user. | ||
|
||
## Prerequisites | ||
|
||
Before you begin, make sure you have: | ||
|
||
1. Installed SwiBots (`pip install swibots`) | ||
2. Obtained a bot token from the Switch platform | ||
|
||
## The Code | ||
|
||
Here's the complete code for our echo bot: | ||
|
||
```python | ||
from swibots import Client, BotContext, MessageEvent | ||
|
||
app = Client("YOUR_BOT_TOKEN") | ||
|
||
@app.on_message() | ||
async def message_handler(ctx: BotContext[MessageEvent]): | ||
message = ctx.event.message | ||
await message.respond(f"Received: {message.message}") | ||
|
||
|
||
app.run() | ||
``` | ||
|
||
## Running the Bot | ||
|
||
To run the bot, simply execute the script: | ||
|
||
```bash | ||
python echo_bot.py | ||
``` | ||
|
||
## Testing the Bot |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{ | ||
"label": "Fundamentals", | ||
"position": 3, | ||
"link": { | ||
"type": "generated-index", | ||
"description": "5 minutes to learn the most important SwiBots concepts." | ||
}, | ||
"collapsed": true | ||
|
||
} |