Giter VIP home page Giter VIP logo

Comments (6)

xiyaowong avatar xiyaowong commented on September 22, 2024

简单了解下转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.

githubdl avatar githubdl commented on September 22, 2024

简单了解下转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.

xiyaowong avatar xiyaowong commented on September 22, 2024

意思是发一条消息,里面带文字和图片的吗?这个你应该去框架那边了解。

from python--iotbot.

githubdl avatar githubdl commented on September 22, 2024

意思是发一条消息,里面带文字和图片的吗?这个你应该去框架那边了解。

信息里面带文字和图片我会,就是不会怎么把文字放到图片前面去。另外一个问题就是,这个可以@用户回复吗?
下面的代码是你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.

xiyaowong avatar xiyaowong commented on September 22, 2024

写在content里呀,这个宏就相当于图片,占位用的。

from python--iotbot.

githubdl avatar githubdl commented on September 22, 2024

写在content里呀,这个宏就相当于图片,占位用的。

好的

from python--iotbot.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.