File tree Expand file tree Collapse file tree 2 files changed +46
-0
lines changed
Expand file tree Collapse file tree 2 files changed +46
-0
lines changed Original file line number Diff line number Diff line change 11* ~
22.bundle
3+ * .swp
Original file line number Diff line number Diff line change 1+ require 'cinch'
2+
3+ class QuestionRecord < Struct . new ( :who , :what , :time )
4+ def to_s
5+ "[#{ time . asctime } ] #{ who } had a question, '#{ what } '"
6+ end
7+ end
8+
9+ bot = Cinch ::Bot . new do
10+ configure do |c |
11+ c . nick = "HacketyRobot"
12+ c . password = ""
13+ c . server = "irc.freenode.org"
14+ c . channels = [ "#hacketyhack" ]
15+ @users = { }
16+ end
17+
18+ on :message , "hello" do |m |
19+ m . reply "Hello, #{ m . user . nick } "
20+ end
21+
22+ on :message , /\? / do |m |
23+ @users [ m . user . nick ] ||= [ ]
24+ if @users [ m . user . nick ] . length == 0
25+ m . channel . send "#{ m . user . nick } : Thanks for asking a question! You can also get help here: http://bit.ly/hacketyhelp"
26+ end
27+ @users [ m . user . nick ] << QuestionRecord . new ( m . user . nick , m . message , Time . new )
28+ m . channel . send "#{ m . user . nick } : your question has been recorded."
29+ end
30+
31+ on :channel , /^!question (.+)/ do |m , nick |
32+ if nick == bot . nick
33+ m . reply "That's me!"
34+ elsif @users . key? ( nick )
35+ @users [ nick ] . each do |qr |
36+ m . reply qr . to_s
37+ end
38+ else
39+ m . reply "I haven't seen #{ nick } "
40+ end
41+ end
42+ end
43+
44+ bot . start
45+
You can’t perform that action at this time.
0 commit comments