Module: Puggernaut::Server::Shared
Instance Method Summary collapse
- #gather_messages(channels, lasts, time) ⇒ Object
- #join_channels(channels, user_id) ⇒ Object
- #leave_channel(channel) ⇒ Object
- #query_defaults(query) ⇒ Object
Instance Method Details
#gather_messages(channels, lasts, time) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/puggernaut/server/shared.rb', line 5 def (channels, lasts, time) if time channels.inject([]) { |array, channel| array += Channel.(channel, Time.parse(time)) array }.join("\n") elsif !lasts.empty? channels.inject([]) { |array, channel| array += Channel.(channel, lasts.shift) array }.join("\n") else '' end end |
#join_channels(channels, user_id) ⇒ Object
21 22 23 24 25 26 |
# File 'lib/puggernaut/server/shared.rb', line 21 def join_channels(channels, user_id) Channel.say channels.inject({}) { |hash, channel| hash[channel] = "!PUGJOIN#{user_id}" hash }, user_id end |
#leave_channel(channel) ⇒ Object
28 29 30 31 32 33 |
# File 'lib/puggernaut/server/shared.rb', line 28 def leave_channel(channel) Channel.say channel.channels.inject({}) { |hash, c| hash[c] = "!PUGLEAVE#{channel.user_id}" hash }, channel.user_id end |
#query_defaults(query) ⇒ Object
35 36 37 38 39 40 41 42 43 |
# File 'lib/puggernaut/server/shared.rb', line 35 def query_defaults(query) [ (query['channel'].dup rescue []), (query['join_leave'].dup[0] rescue nil), (query['last'].dup rescue []), (query['time'].dup[0] rescue nil), (query['user_id'].dup[0] rescue nil) ] end |