Class: Chat
- Inherits:
-
Cogibara::OperatorBase
- Object
- Cogibara::OperatorBase
- Chat
- Defined in:
- lib/cogibara/operators/chat.rb
Instance Attribute Summary
Attributes inherited from Cogibara::OperatorBase
#clientID, #message_structure, #message_text, #operator_config
Instance Method Summary collapse
Methods inherited from Cogibara::OperatorBase
#confirm, #initialize, #process_file, #receive_message, #say
Constructor Details
This class inherits a constructor from Cogibara::OperatorBase
Instance Method Details
#initialize_operator ⇒ Object
5 6 7 8 9 10 11 |
# File 'lib/cogibara/operators/chat.rb', line 5 def initialize_operator @cleverbot_client = Cleverbot::Client.new pf_ID = self.operator_config["Bot_ID"].to_i if pf_ID > 0 @pf_ID = pf_ID end end |
#process(message) ⇒ Object
13 14 15 16 17 18 19 20 21 |
# File 'lib/cogibara/operators/chat.rb', line 13 def process() if @pf_ID reply = Curl.post("http://www.personalityforge.com/directchat.php?BotID=#{@pf_ID}&MID=8", {Message: .text, action: "Send Message", UserID: @pf_ID}) reply.body_str.slice(/<\!-- Bot's reply -->.*?<\!-- end section -->/m).slice(/<span class="bigfont">.*<\/span>/m).gsub(/<.*>/,'').gsub("\n\t",'') else @cleverbot_client.write .text end end |