Giter VIP home page Giter VIP logo

python--iotbot's Introduction

bot端更新太快,该项目已不适用,请移步botoy

python-iotbot

pypi python-version

Install

pip install python-iotbot -i https://pypi.org/simple --upgrade

Quick Start

from iotbot import IOTBOT, GroupMsg

bot = IOTBOT(your_bot_qq)


@bot.on_group_msg
def group(ctx: GroupMsg):
    print(f"""
{ctx.FromNickName}{ctx.MsgTime}的时候,发了一个类型是{ctx.MsgType}的消息,内容为:
{ctx.Content}""")
    print(ctx.CurrentQQ)


bot.run()

documentation

LICENSE

MIT

python--iotbot's People

Contributors

itjoker233 avatar xiyaowong avatar yuban10703 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

python--iotbot's Issues

如何使用本地图片

如果想用本地图片发图,应该怎样写代码呢(本人不怎么会python,烦请大佬解答一下)

优化配置项

  1. 配置优先级从 配置文件.iotbot.json > 指定参数值params > 默认参数值 default 改为 params > .iotbot.json > default
  2. 添加配置项,不知道添加啥
  3. 连接项可以只填一个域名(地址)
  4. 。。。

插件优先级问题

不知作者有没有考虑一下插件的优先级问题,场景:对于一些指定或含有关键词的信息,我们可以特定处理,对一些平常的消息做另一种处理,在我使用中,我发现好像是在每一个插件里都去处理了这条消息,是否可以采用优先级来处理这个问题呢?按照优先级的顺序加载插件,找到与信息相关的插件后不再引用其他插件,并且这样也能达到对不同信息不同处理的效果

发送群消息问题

image
400是发送文本消息的长度,没超过限制(而且在Linux上好像没限制),演示图在Windows,但无法发送,相同的内容用postman却可以发送,好友消息也可以,群消息就不行

关于机器人召唤词

作者你好,开源的python--iotbot作品很棒,但有一点想说,在群聊的时候,也许我们不必要对每条信息处理,只对触发某些关键词
的信息做处理,可以考虑在配置文件里添一个配置项:机器人的名称,这样在群聊的时候可以通过指定的关键词来召唤机器人,对信息处理。我个人在群聊消息中间件里做了处理,实现了此功能,可能写法有点儿拙略,并未提交Pull,希望作者可以出一个该功能,以下是我改写的

    def __group_msg_handler(self, msg):
        context: GroupMsg = model_map['OnGroupMsgs'](msg)
        logger.info(f'{context.__class__.__name__} ->  {context.data}')
        bot_name = config.bot_name
        # 开启了关键词指令 非机器人发送的消息,进行匹配
        if bot_name is not None and context.FromUserId not in self.qq:
            msgContent = ""
            if context.MsgType == "PicMsg":
                msgContentDict = json.loads(context.Content)
                msgContent = msgContentDict['Content']
            elif context.MsgType == "TextMsg":
                msgContent = context.Content

            # 仅触发召唤词
            if context.MsgType == "TextMsg" and bot_name == msgContent:
                context.Content = "召唤机器人"
            else:
                if not re.match(str(bot_name + " "), msgContent):
                    # 未匹配到不做处理
                    return

                # 匹配到则去掉机器人名字,只保留指令
                res = re.match(str(bot_name + " "), msgContent)
                order = msgContent.split(res.group())[1]
                if context.MsgType == "PicMsg":
                    msgContentDict = json.loads(context.Content)
                    msgContentDict['Content'] = order
                    context.Content = json.dumps(msgContentDict)
                elif context.MsgType == "TextMsg":
                    context.Content = order
        # 黑名单
        if context.FromGroupId in self.group_blacklist:
            return
        # 中间件
        if self.__group_context_middleware is not None:
            new_context = self.__group_context_middleware(context)
            if isinstance(new_context, type(context)):
                context = new_context
        self.__executor.submit(self.__group_context_distributor, context)

python setup.py build构建错误,

Error:

# python setup.py build
Traceback (most recent call last):
  File "setup.py", line 26, in <module>
    version=meta['__version__'],
KeyError: '__version__'

Solution:

# setup.py
26 version=meta['__version__'],

# replace '__version__' with 'version'

26 version=meta['version'],

bot.refresh_plugins()无效

在三四次调用bot.refresh_plugins()之后,插件反而刷新到之前的版本了,再继续调用仍然无果,只能重启

定时器的问题

如图,我创建了定时器
11111.jpg
但似乎会在任务执行完成后抛出异常

另外我发现好像不支持动态插入定时器,场景:在用户执行某个操作后,需要在未来某个时刻执行某个操作,我尝试动态创建,但貌似不会执行,必须要重新启动主程序,此任务才会重新加载。

另一点,可否考虑在创建实例IOTBOT并启动主程序后,将其注入到插件中,这样一来,启用插件后,实例可以在插件中直接引用,否则创建定时器的话又要重新创建新实例

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.