一個用於k12的bot包
Project description
12
NKUST UCL K12 ChatBot
簡介
NKUST UCL K12 ChatBot 是一個基於 K12 API 的 ChatBot,它能夠自動發送文字訊息、圖片、文件,接收到來自聊天室的訊息,支援消息歷史查詢。
安裝
使用 pip 安裝:
pip install nkust-ucl-k12-bot
用法
初始化 K12 Bot
from nkust_ucl_k12_bot import K1
custom_k12 = K12(config_file='config/k12.yaml')
custom_k12.set_chat_bot_info(
SendUserID="my_id",
SendUserName="ChatGPT_ucl",
SendUserImage="https://upload.wikimedia.org/wikipedia/commons/thumb/0/04/ChatGPT_logo.svg/512px-ChatGPT_logo.svg.png"
)
發送文字訊息
custom_k12.send_text(roomid="12345", text="你好!")
發送圖片
# image_path可以是網址或是本地路徑
custom_k12.send_image(roomid="12345", image_path="/path/to/image.png")
發送文件
# doc_path可以是網址或是本地路徑
custom_k12.send_document(roomid="12345", doc_path="/path/to/document.pdf")
接收訊息
註冊 on_processed_message
處理方法以接收來自聊天室的訊息:
@K12.on_processed_message
def my_custom_on_processed_message(self, chat_msg):
# ... 自定義的 on_processed 行為 ...
# ChatMsg 為訊息物件
自定義 on_connect 行為
@K12.on_connect
def my_custom_on_connect(self, client, userdata, flags, rc):
# ... 自定義的 on_connect 行為 ...
# self.client.mqttSubscribe為訂閱的主題
client.subscribe(self.client.mqttSubscribe)
print("開始訂閱")
如何貢獻
- Fork 專案
- 創建新的分支 (
git checkout -b feature/fooBar
) - 提交你的修改 (
git commit -am 'Add some fooBar'
) - 推送到分支 (
git push origin feature/fooBar
) - 創建一個新的 Merge Request
License
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
Close
Hashes for nkust_ucl_k12_bot-2.6.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 259d188397f9225122b13cdee36b478670c7fccf319fa132c89820d3a087a422 |
|
MD5 | 33f7e0d13a5f7877687dbdea814d2f14 |
|
BLAKE2b-256 | e77a6afe9ab95521396798c18e9c1f79476a3b93aafde86e31518a3d7178b505 |