Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Added comments to invoke method

  • Loading branch information...
commit b0a63f32b3cc2823dfcf4eed058e1a2b233caefb 1 parent a707393
@hemanth authored
Showing with 9 additions and 0 deletions.
  1. +9 −0 rgbot.rb
View
9 rgbot.rb
@@ -30,12 +30,21 @@ def initialize(bot_name,bot_password)
end
def invoke(msg)
+ # This method takes care of invokation of the required
+ # method from the factoid that the user throws at.
+
+ # The below are the restricted methods, that must not be invoked
restricted_methods=['main','invoke','deliver']
+ # Get the method name from the chat msg
meth=@msg.body.split()[0]
+ # Remove the method name from the chat msg and save the rest
@msg.body=@msg.body.sub(/\w+\s*/, '')
if (self.respond_to?(meth) and !restricted_methods.include?(meth))
+ # If the method to be invoked is present and is not a restricted one then invoke it.
+ # Use obj.send(method,args) => method(args) similar to py's getattr
self.send(meth,@msg)
else
+ # If not then alter the user of what he can do
self.deliver(@msg,"I don't get what your are saying "+@msg.from.node+", but you can teach me @ https://github.com/hemanth/rgbot" )
end
end
Please sign in to comment.
Something went wrong with that request. Please try again.