A Python library to interact with a chat API
Project description
Seiketsu-API
Installation
Install the library using pip:
pip install seiketsu-api
Usage
First, import the ApiSeiketsu class from the library:
from api_seiketsu import ApiSeiketsu, ApiSeiketsuImage
Initialize the ApiSeiketsu object
In the token field, insert your token, or the public one: 3rnPH1ooGMjui9fwf8y4Ueta9ivDJfbae0lTNtMRGoRddzMAhKDr=dgq7yyfJR8v
Create an instance of the ApiSeiketsu class:
token = 'your_token'
seiketsu = ApiSeiketsu(token)
Read message
To get the latest message, call the read_message method:
sender, message_text = seiketsu.read_message()
sender contains the sender's nickname, message_text contains the text of the message.
If you want read_message to run all the time you can loop:
while True:
sender, message_text = seiketsu.read_message()
print(f'{sender}: {message_text}')
Write message
To write a new chat message, call the write_message method, passing alias and message_text as arguments:
seiketsu.write_message(alias="John", message_text="Hello, world!")
Upload image
To upload an image, call the upload_image method, passing the image file as an argument.
seiketsuImage = ApiSeiketsuImage()
image_file = open('C:\\folder\\image.png', 'rb') # Use the correct file path to your image
image_url = seiketsuImage.upload_image(image_file) # Call the upload_image function to upload the image
To display an image in chat, use the write_message method.
Example
Here is a simple example demonstrating the use of the Seiketsu-API. Reads the last message, checks if the bot wrote it himself, if not, repeats it.
from api_seiketsu import ApiSeiketsu
token = '3rnPH1ooGMjui9fwf8y4Ueta9ivDJfbae0lTNtMRGoRddzMAhKDr=dgq7yyfJR8v'
seiketsu = ApiSeiketsu(token) # Initialize seiketsu API
aliasBot = "TestBot" # Name for Bot
while True:
# Waiting for a new message
sender, message = seiketsu.read_message()
# Checking that this is not a message from a bot
if sender != aliasBot + '#BOT':
# Sending a reply message
seiketsu.write_message(alias=aliasBot, message_text=message)
# Message output to console
print(f'Repeated message: {aliasBot}: {message}')
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 Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file seiketsu-api-1.6.0.tar.gz.
File metadata
- Download URL: seiketsu-api-1.6.0.tar.gz
- Upload date:
- Size: 6.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.10.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0651242329f23c1f451eda088dc5608dea7543eb55c9030d515334f72143eb73
|
|
| MD5 |
73268275ed9ac39d3a5f84ce8da9c7be
|
|
| BLAKE2b-256 |
e99832be6bee2c5813cb9736917ff3a86cffb9102cf8779b7df90ddcf6d3018d
|
File details
Details for the file seiketsu_api-1.6.0-py3-none-any.whl.
File metadata
- Download URL: seiketsu_api-1.6.0-py3-none-any.whl
- Upload date:
- Size: 7.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.10.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b39aae13488941a24e0e3b226ab66759de505cf1f927a6bc97f46915232d3e07
|
|
| MD5 |
d3c916f8df67d1eef648a1765c7a5d39
|
|
| BLAKE2b-256 |
dace02b9ed84005dc1a1c41e1e329955f940075dfe24308a0ae37d5b248ba1fc
|