Bots Library for Switch
Project description
SwiBots
Python library for switch app
Please check the documentation for more information.
Getting Started
You can start building your first app with SwiBots in less than 5 minutes.
- Install swibots library
pip install swibots
OR build from source
pip install git+https://github.com/switchcollab/Switch-Bots-Python-Library.git
- Open the editor of your choice and create a python file echobot.py (or whatever name you want!), and paste the following code:
from swibots import (
BotApp,
BotContext,
MessageEvent
)
TOKEN = "MY SUPER SECRET TOKEN"
# initialize the app and register commands
app = BotApp(
TOKEN, "A cool bot with annotations and everything you could possibly want :)"
)
@app.on_message()
async def message_handler(ctx: BotContext[MessageEvent]):
# easy way to prepare a mesage that is a response of an incomming message
message = ctx.event.message
response_text = f"Thank you! I received your message: {message.message}"
# send the message back to the user
await message.respond(response_text)
app.run()
-
Open your switch app and send a message to the bot
Hello world!
-
You will receive a reply from your bot saying
Thank you! I received your message: Hello world!
Checkout Bot samples
Examples
Sending Buttons
from swibots import InlineMarkup, InlineKeyboardButton
await bot.send_message(
Message(receiver_id=50,
inline_markup=InlineMarkup([[
InlineKeyboardButton("text", url="https://url.com")
]])
)
)
Sending media
from swibots import MediaUploadRequest
await bot.send_message(
Message(...),
media=MediaUploadRequest(path="file.png",
description="file_name.png",
thumbnail="file.png"
)
)
Sending embedded message
from swibots import EmbeddedMedia, EmbedInlineField
await bot.send_message(
Message(...),
media=EmbeddedMedia(
thumbnail="thumb_path.png",
title="Embedded message.",
header_name="message from swibots!",
header_icon="https://header.png",
footer_title="Hello from bot.",
footer_icon="https://footer.png",
inline_fields=[
[
EmbedInlineField("https://icon.png", "Nice Meeting you", "Hello 👋")
]
]
)
)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
No source distribution files available for this release.See tutorial on generating distribution archives.
Built Distribution
swibots-1.3.48b0-py3-none-any.whl
(145.2 kB
view hashes)
Close
Hashes for swibots-1.3.48b0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 77725c0db27e1e28c32504384e92847899d6e13356c2d463d9f6ad039aafc437 |
|
MD5 | a1309bd93fa5e3e22b58d4e74a7f7c84 |
|
BLAKE2b-256 | ba0a91335730f58207ce1d9ca708f433756b64bfeec97a2b47f7c41f63780dd5 |