Comments (6)
简单了解下转base64方法就行了。
import base64
from iotbot import Action
action = Action(123456)
with open('./git.jpg', 'rb') as f:
content = f.read()
b64 = base64.b64encode(content).decode() // 二进制转base64
action.send_group_pic_msg(
123456,
picBase64Buf=b64
)
from python--iotbot.
简单了解下转base64方法就行了。
import base64 from iotbot import Action action = Action(123456) with open('./git.jpg', 'rb') as f: content = f.read() b64 = base64.b64encode(content).decode() // 二进制转base64 action.send_group_pic_msg( 123456, picBase64Buf=b64 )
多谢大佬的指点,另外,我还想请教一下,如果想处理at机器人的事件,应该怎样改下面的代码呢?比如信息是:at机器人+'图片'。如何让机器人先at用户,然后发文字“图片”,最后发图片呢?
import os
import re
import base64
from iotbot import Action, GroupMsg
def receive_group_msg(ctx: GroupMsg):
if ctx.FromUserId == ctx.CurrentQQ:
return
content = ctx.Content # type:str
# 本地图片
if re.findall(r"(图片)", content):
with open('./picture/git.jpg', 'rb') as f:
content = f.read()
b64 = base64.b64encode(content).decode()
Action(ctx.CurrentQQ).send_group_pic_msg(
ctx.FromGroupId, content = '\n图片' ,
picBase64Buf=b64
)
return
from python--iotbot.
意思是发一条消息,里面带文字和图片的吗?这个你应该去框架那边了解。
from python--iotbot.
意思是发一条消息,里面带文字和图片的吗?这个你应该去框架那边了解。
信息里面带文字和图片我会,就是不会怎么把文字放到图片前面去。另外一个问题就是,这个可以@用户回复吗?
下面的代码是你iotbot文件夹下action.py里的代码,其中写到“[PICFLAG] 改变图文消息顺序”,这个应该如何操作才能更改图文信息顺序呢?
def send_group_pic_msg(self, toUser: int, picUrl='', flashPic=False, atUser=0, content='',
picBase64Buf='', fileMd5='', timeout=3, **kwargs) -> dict:
"""发送群图片
Tips:
[秀图id] 各id对应效果
40000 秀图
40001 幻影
40002 抖动
40003 生日
40004 爱你
40005 征友
40006 无(只显示大图无特效)
[PICFLAG] 改变图文消息顺序
"""
data = {
"toUser": toUser,
"sendToType": 2,
"sendMsgType": "PicMsg",
"content": content,
"groupid": 0,
"atUser": atUser,
"picUrl": picUrl,
"picBase64Buf": picBase64Buf,
"fileMd5": fileMd5,
"flashPic": flashPic
}
return self.baseSender('POST', 'SendMsg', data, timeout, **kwargs)
from python--iotbot.
写在content
里呀,这个宏就相当于图片,占位用的。
from python--iotbot.
写在
content
里呀,这个宏就相当于图片,占位用的。
好的
from python--iotbot.
Related Issues (20)
- 图片发送不了 HOT 2
- 文档打不开了 HOT 1
- 关于机器人召唤词 HOT 1
- FriendMsg没有MsgTime属性 HOT 1
- 插件优先级问题 HOT 1
- 定时器的问题 HOT 5
- 启动失败 HOT 6
- 发送群消息问题 HOT 6
- (用这个库的来看一看)移除内置定时器的功能
- (用这个库的来看一看)删除Action队列发送的功能
- 删除不必要的功能,如定时器,队列
- 增加和完善接收函数装饰器
- 删除冗余参数,不常用或者说基本不用的参数全部参数,减少使用者的可选项
- 优化配置项
- bot.refresh_plugins()无效 HOT 10
- 优化内置webhook插件功能
- python setup.py build构建错误,
- 请问如何同时接收多个qq消息 HOT 12
- 请教一下,怎么控制会话呢,比如说bot提示后要获得它人第二次发的消息 HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from python--iotbot.