Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Added comments to invoke method

  • Loading branch information...
commit b0a63f32b3cc2823dfcf4eed058e1a2b233caefb 1 parent a707393
hemanth.hm authored

Showing 1 changed file with 9 additions and 0 deletions. Show diff stats Hide diff stats

  1. +9 0 rgbot.rb
9 rgbot.rb
@@ -30,12 +30,21 @@ def initialize(bot_name,bot_password)
30 30 end
31 31
32 32 def invoke(msg)
  33 + # This method takes care of invokation of the required
  34 + # method from the factoid that the user throws at.
  35 +
  36 + # The below are the restricted methods, that must not be invoked
33 37 restricted_methods=['main','invoke','deliver']
  38 + # Get the method name from the chat msg
34 39 meth=@msg.body.split()[0]
  40 + # Remove the method name from the chat msg and save the rest
35 41 @msg.body=@msg.body.sub(/\w+\s*/, '')
36 42 if (self.respond_to?(meth) and !restricted_methods.include?(meth))
  43 + # If the method to be invoked is present and is not a restricted one then invoke it.
  44 + # Use obj.send(method,args) => method(args) similar to py's getattr
37 45 self.send(meth,@msg)
38 46 else
  47 + # If not then alter the user of what he can do
39 48 self.deliver(@msg,"I don't get what your are saying "+@msg.from.node+", but you can teach me @ https://github.com/hemanth/rgbot" )
40 49 end
41 50 end

0 comments on commit b0a63f3

Please sign in to comment.
Something went wrong with that request. Please try again.