Method: WeChat::Bot::Core#start
- Defined in:
- lib/wechat/bot/core.rb
#start ⇒ void
This method returns an undefined value.
运行机器人
105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 |
# File 'lib/wechat/bot/core.rb', line 105 def start @client.login @client.contacts @contact_list.each do |c| @logger.debug "Contact: #{c}" end while true break unless @client.logged? || @client.alive? sleep 1 end rescue Interrupt => e = "你使用 Ctrl + C 终止了运行" @logger.warn() @client.send_text(@config.fireman, "[告警] 意外下线\n#{message}\n#{e.backtrace.join("\n")}") if @client.logged? && @client.alive? rescue Exception => e = e. @logger.fatal(e) @client.send_text(@config.fireman, "[告警] 意外下线\n#{message}\n#{e.backtrace.join("\n")}") if @client.logged? && @client.alive? ensure @client.logout if @client.logged? && @client.alive? end |