Giter Club home page Giter Club logo

Comments (3)

sang4lv avatar sang4lv commented on July 18, 2024

这是崩溃是出的call stack

/var/www/node/wechat/app.js:122
      return info.param.eventKey.toLowerCase() === 'service_delivery';
                                 ^
TypeError: Cannot call method 'toLowerCase' of undefined
    at Rule.wechat.set.pattern (/var/www/node/wechat/app.js:122:34)
    at Rule.test (/var/www/node/wechat/node_modules/weixin-robot/node_modules/webot/lib/rule.js:157:14)
    at tick (/var/www/node/wechat/node_modules/weixin-robot/node_modules/webot/lib/webot.js:400:15)
    at /var/www/node/wechat/node_modules/weixin-robot/node_modules/webot/lib/webot.js:438:7
    at Rule.exec (/var/www/node/wechat/node_modules/weixin-robot/node_modules/webot/lib/rule.js:236:14)
    at tick (/var/www/node/wechat/node_modules/weixin-robot/node_modules/webot/lib/webot.js:424:10)
    at /var/www/node/wechat/node_modules/weixin-robot/node_modules/webot/lib/webot.js:438:7
    at Rule.handler (/var/www/node/wechat/app.js:101:5)
    at Rule.exec (/var/www/node/wechat/node_modules/weixin-robot/node_modules/webot/lib/rule.js:238:15)
    at tick (/var/www/node/wechat/node_modules/weixin-robot/node_modules/webot/lib/webot.js:424:10)

from weixin-robot.

ktmud avatar ktmud commented on July 18, 2024

info.noReply 只代表最后处理出的消息内容不会返回给微信接口;你可以使用 info.ended 来表示不再需要执行下一条规则。

另外,不建议直接在 handler 里直接给 info.reply 赋值。因为一个 handler 提供的 reply 应该是唯一的,你可以直 return 回复内容。

随附的代码可以优化为:

    wechat.set('SUPPORT', {
      pattern: function(info) {
        return info.session.is_chat_user;
      },
      handler: function(info) {
        if( info.is('event') ) {
          return 'Doing Stuff...';
        }
        eventEmitter.emit('userMessage', info.uid, info.text);
        info.noReply = true;
        info.ended = true;
      }
    });

from weixin-robot.

ktmud avatar ktmud commented on July 18, 2024

另外, info.session 对每个微信用户来说都是唯一的,不要把全局数据赋给每个 session

from weixin-robot.

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.