beerbot 0.1.5 → 0.2.0.pre.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,35 +0,0 @@
1
- # The files in this directory are part of BeerBot, a a ruby irc bot library.
2
- # Copyright (C) 2014 Daniel Bush
3
- # This program is distributed under the terms of the GNU
4
- # General Public License. A copy of the license should be
5
- # enclosed with this project in the file LICENSE. If not
6
- # see <http://www.gnu.org/licenses/>.
7
-
8
- require_relative '../00.utils/More'
9
-
10
- module BeerBot
11
-
12
- # More-based filter that can be applied to botmsg's.
13
- #
14
- # #filter expects a botmsg and returns an array, either of botmsg's
15
- # or emtpy.
16
-
17
- class BotMsgMore < ::BeerBot::Utils::More
18
- def filter botmsg
19
- arr = BeerBot::BotMsg.to_a(botmsg)
20
- # At this point if arr isn't a valid bot msg we'll get [].
21
- replies = []
22
- by_to = Hash.new{|h,k| h[k]=[]}
23
-
24
- arr.inject(by_to){|h,v| h[v[:to]].push(v); h}
25
- by_to.each_pair{|to,a|
26
- replies += super(a,to)
27
- if replies.size < a.size then
28
- replies += [msg:"Type: more",to:to]
29
- end
30
- }
31
- return replies
32
- end
33
- end
34
-
35
- end