Class: MoonBot::Parser
- Inherits:
-
Object
- Object
- MoonBot::Parser
- Defined in:
- lib/MoonBot/parser.rb
Class Method Summary collapse
Class Method Details
.parse(data) ⇒ Object
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/MoonBot/parser.rb', line 3 def self.parse data = {} # if not empty if data.scan(/^:/).empty? body = data.split ' ' [:command] = body.shift [:args] = body else separated = data.split ':' body = separated[1].split ' ' [:prefix] = body.shift [:command] = body.shift [:params] = body.shift 2.times { separated.shift } [:trailing] = separated.join(":") end rescue nil end |