This repository has been archived by the owner on Oct 20, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
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
33 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,26 @@ | ||
"""生成二维码,格式:生成二维码{内容}""" | ||
import base64 | ||
import io | ||
|
||
from botoy import GroupMsg | ||
from botoy.decorators import ignore_botself, startswith, these_msgtypes | ||
from botoy.sugar import Picture | ||
|
||
try: | ||
import qrcode | ||
except ImportError as e: | ||
raise ImportError("请先安装依赖库: pip install qrcode") from e | ||
|
||
|
||
def gen_qrcode(text: str) -> str: | ||
img = qrcode.make(text) | ||
img_buffer = io.BytesIO() | ||
img.save(img_buffer) | ||
return base64.b64encode(img_buffer.getvalue()).decode() | ||
|
||
|
||
@ignore_botself | ||
@these_msgtypes("TextMsg") | ||
@startswith("生成二维码") | ||
def receive_group_msg(ctx: GroupMsg): | ||
Picture(pic_base64=gen_qrcode(ctx.Content[5:])) |
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 |
---|---|---|
|
@@ -95,3 +95,9 @@ | |
汉字转拼音 | ||
|
||
格式: 拼音{汉字} | ||
|
||
# generate Qrcode | ||
|
||
生成二维码 | ||
|
||
格式:生成二维码{内容} |
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 |
---|---|---|
@@ -1,3 +1,4 @@ | ||
botoy | ||
pillow | ||
aiofiles | ||
qrcode |