25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
|
# File 'lib/mchat/commands/channel_new.rb', line 25
def channel_new_command_run(channel_name = nil)
if !channel_name
content << "/channel_new <new_channel_name>\n".style.warn
content << "new_channel_name should not be nil\n".style.warn
_puts content
else
resp = _api.create_channel(channel_name)
code = resp.fetch("code")
if code == StatusCode::RecordHaveExist
content = "#{"Mchat Channel:".style.primary} #{channel_name}\n"
content << "channel <#{channel_name}> have exist. use follow create new channel.\n"
content << "type `/channel_new <new_channel_name>`"
content << "you can also find all channels:"
content << "type `/channel`"
_puts content
return
elsif code == StatusCode::Success
data = resp.fetch("data")
online_users = data["online_users"]
_mchat_action("you create channel: #{channel_name}")
_puts "create channel: #{channel_name} success. try auto join."
_dispatch(:join_command_run, channel_name)
end
end
end
|