-
Notifications
You must be signed in to change notification settings - Fork 3
/
answer.rb
72 lines (50 loc) · 1.56 KB
/
answer.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#!/bin/env ruby
# encoding: utf-8
class Answer
def initialize(module_name, method_name, username, message, channel, memory = nil)
@module_name = module_name
@method_name = method_name
@username = username
@message = message
@channel = channel
@memory = if memory == nil then Memory.new() else memory end
end
def debug
return "#{@module_name} - #{@username} - #{@message} - #{@channel}"
end
def includeModule name
moduleLocation = "modules/module."+name+".rb"
require_relative(moduleLocation)
end
def output
includeModule(@module_name)
if self.respond_to?(@method_name)
return self.send(@method_name)
elsif self.respond_to?(@module_name)
return self.send(@module_name)
end
return ""
end
def hey
return "hey #{@username}."
end
def _matchPronouns string
@string = string
def match(pronoun, content)
@string = @string.gsub(/(^|[ ,.])#{pronoun}([ ,.]|$)/i, '\1'+content+'\2')
end
match("me", @username)
match("my", @username+"'s")
match("mine", @username+"'s")
match("i", @username)
match("you", "ludivine")
match("your", "ludivine's")
match("you're", "ludivine is")
match("yours", "ludivine's")
match("we", "merveilles")
match("us", "merveilles")
match("our", "merveilles'")
match("ours", "merveilles'")
return @string
end
end