meshchat 0.7.1 → 0.8.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/meshchat/cli.rb +6 -1
- data/lib/meshchat/cli/input.rb +2 -26
- data/lib/meshchat/command/base.rb +12 -0
- data/lib/meshchat/command/chat.rb +30 -0
- data/lib/meshchat/command/emote.rb +20 -0
- data/lib/meshchat/command/help.rb +3 -1
- data/lib/meshchat/command/irb.rb +4 -3
- data/lib/meshchat/display.rb +1 -0
- data/lib/meshchat/display/base.rb +7 -0
- data/lib/meshchat/display/manager.rb +4 -0
- data/lib/meshchat/message.rb +3 -0
- data/lib/meshchat/message/chat.rb +6 -1
- data/lib/meshchat/message/emote.rb +9 -0
- data/lib/meshchat/net/listener/server.rb +1 -1
- data/lib/meshchat/version.rb +1 -1
- metadata +6 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fca3ee7e9b96b4f3c908452a8431b30439f677af
|
4
|
+
data.tar.gz: c83a3c29a2e306b82ac9eeec85a92012001cf010
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 18c8c043f8ac60af265de57719d76ff2bf6aea30d6474f9d9a6d6621f6a49768a646b5b2d97c4342b09203e56e98e2bd1129492c86f7bbec39c6da6cb19b3243
|
7
|
+
data.tar.gz: 1213ce77facbfb2263afd1a5b89a3288a2ded7074c05fdb3996e0631d25eaac79fe3b5435ff7d7f4c10d267aab3eec1e2b83364f9fa4985f23fa59013f74dfd7
|
data/lib/meshchat/cli.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
require 'meshchat/cli/input'
|
2
2
|
require 'meshchat/cli/base'
|
3
3
|
require 'meshchat/command/base'
|
4
|
+
require 'meshchat/command/chat'
|
4
5
|
require 'meshchat/command/identity'
|
5
6
|
require 'meshchat/command/irb'
|
6
7
|
require 'meshchat/command/config'
|
@@ -19,6 +20,7 @@ require 'meshchat/command/offline'
|
|
19
20
|
require 'meshchat/command/init'
|
20
21
|
require 'meshchat/command/share'
|
21
22
|
require 'meshchat/command/import'
|
23
|
+
require 'meshchat/command/emote'
|
22
24
|
|
23
25
|
|
24
26
|
module MeshChat
|
@@ -45,7 +47,10 @@ module MeshChat
|
|
45
47
|
MeshChat::Command::Base::OFFLINE => MeshChat::Command::Offline,
|
46
48
|
MeshChat::Command::Base::HELP => MeshChat::Command::Help,
|
47
49
|
MeshChat::Command::Base::BIND => MeshChat::Command::Bind,
|
48
|
-
MeshChat::Command::Base::SEND_DISCONNECT => MeshChat::Command::SendDisconnect
|
50
|
+
MeshChat::Command::Base::SEND_DISCONNECT => MeshChat::Command::SendDisconnect,
|
51
|
+
MeshChat::Command::Base::EMOTE => MeshChat::Command::Emote,
|
52
|
+
MeshChat::Command::Base::CHAT => MeshChat::Command::Chat
|
53
|
+
|
49
54
|
}
|
50
55
|
|
51
56
|
|
data/lib/meshchat/cli/input.rb
CHANGED
@@ -21,41 +21,17 @@ module MeshChat
|
|
21
21
|
elsif is_whisper?(input)
|
22
22
|
Command::Whisper
|
23
23
|
else
|
24
|
-
|
25
|
-
CLI::Input
|
24
|
+
Command::Chat
|
26
25
|
end
|
27
26
|
|
27
|
+
Display.debug("INPUT: Detected '#{klass.name}' from '#{input}'")
|
28
28
|
klass.new(input)
|
29
29
|
end
|
30
|
-
|
31
30
|
end
|
32
31
|
|
33
32
|
def initialize(input)
|
34
33
|
self._input = input.chomp
|
35
34
|
end
|
36
|
-
|
37
|
-
def handle
|
38
|
-
return if _input.empty?
|
39
|
-
|
40
|
-
servers = Node.online
|
41
|
-
if !servers.empty?
|
42
|
-
m = Message::Chat.new(
|
43
|
-
message: _input
|
44
|
-
)
|
45
|
-
|
46
|
-
Display.chat m.display
|
47
|
-
|
48
|
-
# if sending to all, iterate thorugh list of
|
49
|
-
# servers, and send to each one
|
50
|
-
# TODO: do this async so that one server doesn't block
|
51
|
-
# the rest of the servers from receiving the messages
|
52
|
-
servers.each do |entry|
|
53
|
-
Net::Client.send(node: entry, message: m)
|
54
|
-
end
|
55
|
-
else
|
56
|
-
Display.warning 'you have no servers'
|
57
|
-
end
|
58
|
-
end
|
59
35
|
end
|
60
36
|
end
|
61
37
|
end
|
@@ -32,9 +32,11 @@ module MeshChat
|
|
32
32
|
HELP = 'help'
|
33
33
|
BIND = 'bind'
|
34
34
|
SEND_DISCONNECT = 'senddisconnect'
|
35
|
+
EMOTE = 'me'
|
35
36
|
|
36
37
|
def handle
|
37
38
|
klass = CLI::COMMAND_MAP[command]
|
39
|
+
Display.debug("INPUT: #{klass.name} from #{command} derived from #{_input}")
|
38
40
|
if klass
|
39
41
|
klass.new(_input).handle
|
40
42
|
else
|
@@ -44,6 +46,16 @@ module MeshChat
|
|
44
46
|
|
45
47
|
protected
|
46
48
|
|
49
|
+
def corresponding_message_class
|
50
|
+
my_kind = self.class.name.demodulize
|
51
|
+
message_root_name = MeshChat::Message.name
|
52
|
+
message_class_name = "#{message_root_name}::#{my_kind}"
|
53
|
+
|
54
|
+
Display.debug("Corresponding: #{message_class_name}")
|
55
|
+
|
56
|
+
message_class_name.constantize
|
57
|
+
end
|
58
|
+
|
47
59
|
def command_string
|
48
60
|
@command_string ||= _input[1, _input.length]
|
49
61
|
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
module MeshChat
|
2
|
+
class Command
|
3
|
+
class Chat < Command::Base
|
4
|
+
def handle
|
5
|
+
servers = Node.online
|
6
|
+
if !servers.empty?
|
7
|
+
m = corresponding_message_class.new(
|
8
|
+
message: _input
|
9
|
+
)
|
10
|
+
|
11
|
+
show_myself(m)
|
12
|
+
|
13
|
+
# if sending to all, iterate thorugh list of
|
14
|
+
# servers, and send to each one
|
15
|
+
# TODO: do this async so that one server doesn't block
|
16
|
+
# the rest of the servers from receiving the messages
|
17
|
+
servers.each do |entry|
|
18
|
+
Net::Client.send(node: entry, message: m)
|
19
|
+
end
|
20
|
+
else
|
21
|
+
Display.warning 'you have no servers'
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
def show_myself(message)
|
26
|
+
Display.chat message.display
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module MeshChat
|
2
|
+
class Command
|
3
|
+
class Emote < Command::Chat
|
4
|
+
def self.description
|
5
|
+
'send an emote to the current chat'
|
6
|
+
end
|
7
|
+
|
8
|
+
def initialize(input)
|
9
|
+
input = input.chomp
|
10
|
+
emote_message = input.gsub(/\A\/me /, '').chomp
|
11
|
+
self._input = emote_message
|
12
|
+
end
|
13
|
+
|
14
|
+
def show_myself(message)
|
15
|
+
Display.info message.display
|
16
|
+
end
|
17
|
+
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
data/lib/meshchat/command/irb.rb
CHANGED
@@ -1,12 +1,13 @@
|
|
1
1
|
module MeshChat
|
2
2
|
class Command
|
3
|
-
def self.description
|
4
|
-
'runs ruby commands (useful for debugging)'
|
5
|
-
end
|
6
3
|
|
7
4
|
# TODO: only include this and awesome_print when booted with
|
8
5
|
# debug=true in the config
|
9
6
|
class IRB < Command::Base
|
7
|
+
def self.description
|
8
|
+
'runs ruby commands (useful for debugging)'
|
9
|
+
end
|
10
|
+
|
10
11
|
def handle
|
11
12
|
begin
|
12
13
|
code = command_args[1..command_args.length].join(' ')
|
data/lib/meshchat/display.rb
CHANGED
@@ -11,6 +11,7 @@ module MeshChat
|
|
11
11
|
def start(*args); current.start(*args); end
|
12
12
|
def add_line(*args); current.add_line(*args); end
|
13
13
|
def info(*args); current.info(*args); end
|
14
|
+
def emote(*args); current.emote(*args); end
|
14
15
|
def warning(*args); current.warning(*args); end
|
15
16
|
def alert(*args); current.alert(*args); end
|
16
17
|
def success(*args); current.success(*args); end
|
@@ -9,6 +9,7 @@ module MeshChat
|
|
9
9
|
delegate :start, to: :_ui
|
10
10
|
delegate :add_line, to: :_ui
|
11
11
|
delegate :info, to: :_ui
|
12
|
+
delegate :emote, to: :_ui
|
12
13
|
delegate :warning, to: :_ui
|
13
14
|
delegate :alert, to: :_ui
|
14
15
|
delegate :success, to: :_ui
|
@@ -36,6 +37,9 @@ module MeshChat
|
|
36
37
|
when Message::Whisper.name
|
37
38
|
whisper result
|
38
39
|
Notify.show(summary: message.sender_name, body: message.message)
|
40
|
+
when Message::Emote.name
|
41
|
+
emote result
|
42
|
+
Notify.show(summary: message.sender_name, body: message.message)
|
39
43
|
when Message::PingReply.name, Message::Ping.name
|
40
44
|
info result
|
41
45
|
when Message::NodeList.name,
|
data/lib/meshchat/message.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
require 'meshchat/message/base'
|
2
2
|
require 'meshchat/message/chat'
|
3
|
+
require 'meshchat/message/emote'
|
3
4
|
require 'meshchat/message/ping'
|
4
5
|
require 'meshchat/message/ping_reply'
|
5
6
|
require 'meshchat/message/disconnect'
|
@@ -12,6 +13,7 @@ require 'meshchat/message/node_list_hash'
|
|
12
13
|
module MeshChat
|
13
14
|
module Message
|
14
15
|
CHAT = 'chat'
|
16
|
+
EMOTE = 'emote'
|
15
17
|
PING = 'ping'
|
16
18
|
PING_REPLY = 'pingreply'
|
17
19
|
WHISPER = 'whisper'
|
@@ -24,6 +26,7 @@ module MeshChat
|
|
24
26
|
|
25
27
|
TYPES = {
|
26
28
|
CHAT => Chat,
|
29
|
+
EMOTE => Emote,
|
27
30
|
WHISPER => Whisper,
|
28
31
|
DISCONNECT => Disconnect,
|
29
32
|
PING => Ping,
|
@@ -7,7 +7,12 @@ module MeshChat
|
|
7
7
|
name = payload['sender']['alias']
|
8
8
|
message = payload['message']
|
9
9
|
|
10
|
-
|
10
|
+
format_display(time_recieved, name, message)
|
11
|
+
end
|
12
|
+
|
13
|
+
|
14
|
+
def format_display(time, name, message)
|
15
|
+
"#{time} #{name} > #{message}"
|
11
16
|
end
|
12
17
|
end
|
13
18
|
end
|
data/lib/meshchat/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: meshchat
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.8.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- L. Preston Sego III
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-01-
|
11
|
+
date: 2016-01-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: sqlite3
|
@@ -192,7 +192,9 @@ files:
|
|
192
192
|
- lib/meshchat/cli/input.rb
|
193
193
|
- lib/meshchat/command/base.rb
|
194
194
|
- lib/meshchat/command/bind.rb
|
195
|
+
- lib/meshchat/command/chat.rb
|
195
196
|
- lib/meshchat/command/config.rb
|
197
|
+
- lib/meshchat/command/emote.rb
|
196
198
|
- lib/meshchat/command/exit.rb
|
197
199
|
- lib/meshchat/command/help.rb
|
198
200
|
- lib/meshchat/command/identity.rb
|
@@ -223,6 +225,7 @@ files:
|
|
223
225
|
- lib/meshchat/message/base.rb
|
224
226
|
- lib/meshchat/message/chat.rb
|
225
227
|
- lib/meshchat/message/disconnect.rb
|
228
|
+
- lib/meshchat/message/emote.rb
|
226
229
|
- lib/meshchat/message/node_list.rb
|
227
230
|
- lib/meshchat/message/node_list_diff.rb
|
228
231
|
- lib/meshchat/message/node_list_hash.rb
|
@@ -262,5 +265,5 @@ rubyforge_project:
|
|
262
265
|
rubygems_version: 2.4.8
|
263
266
|
signing_key:
|
264
267
|
specification_version: 4
|
265
|
-
summary: MeshChat-0.
|
268
|
+
summary: MeshChat-0.8.0
|
266
269
|
test_files: []
|