Method: WeChat::Bot::Handler#call
- Defined in:
- lib/wechat/bot/handler.rb
#call(message, captures, arguments) ⇒ Thread
执行 Handler
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 |
# File 'lib/wechat/bot/handler.rb', line 51 def call(, captures, arguments) = captures + arguments thread = Thread.new { @bot.logger.debug "[New thread] For #{self}: #{Thread.current} -- #{@thread_group.list.size} in total." begin if @execute_in_callback @bot.callback.instance_exec(, *@args, *, &@block) else @block.call(, *@args, *) end rescue => e @bot.logger.error "[Thread error] #{e.message} -> #{e.backtrace.join("\n")}" ensure @bot.logger.debug "[Thread done] For #{self}: #{Thread.current} -- #{@thread_group.list.size - 1} remaining." end } @thread_group.add(thread) thread end |