hobostove 0.0.4 → 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (2) hide show
  1. data/lib/hobostove/window.rb +17 -3
  2. metadata +3 -2
@@ -20,6 +20,8 @@ module Hobostove
20
20
  end
21
21
 
22
22
  def main
23
+ room.join
24
+
23
25
  while @running && (ch = Ncurses.getch)
24
26
  case ch
25
27
  when 10 # enter
@@ -35,6 +37,8 @@ module Hobostove
35
37
  @message_panel << @current_message
36
38
  @message_panel.update_cursor
37
39
  end
40
+
41
+ room.leave
38
42
  end
39
43
 
40
44
  def speak
@@ -52,11 +56,10 @@ module Hobostove
52
56
  while true do
53
57
  recent = room.recent(10)
54
58
  recent.each do |message|
55
- next unless message[:body]
56
59
  next if messages.include?(message[:id])
57
60
  messages << message[:id]
58
- message = "#{user(message[:user_id])[:name]}: #{message[:body]}"
59
- @messages_panel << message
61
+
62
+ handle_message(message)
60
63
  end
61
64
 
62
65
  sleep 1
@@ -64,6 +67,17 @@ module Hobostove
64
67
  end
65
68
  end
66
69
 
70
+ def handle_message(message)
71
+ case message.type
72
+ when "TextMessage"
73
+ @messages_panel << "#{user(message[:user_id])[:name]}: #{message[:body]}"
74
+ when "EnterMessage"
75
+ @messages_panel << "\t#{user(message[:user_id])[:name]} joined"
76
+ when "LeaveMessage"
77
+ @messages_panel << "\t#{user(message[:user_id])[:name]} left"
78
+ end
79
+ end
80
+
67
81
  def room
68
82
  @room ||= campfire.find_room_by_name(Configuration.room)
69
83
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hobostove
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -139,7 +139,8 @@ files:
139
139
  - lib/hobostove.rb
140
140
  - bin/hobostove
141
141
  homepage: http://github.com/oestrich/hobostove
142
- licenses: []
142
+ licenses:
143
+ - MIT
143
144
  post_install_message:
144
145
  rdoc_options: []
145
146
  require_paths: