From 133f252a80230d704cbc659edd9424eea6e38b31 Mon Sep 17 00:00:00 2001 From: spiritlake <32268357+spiritlake@users.noreply.github.com> Date: Mon, 23 Nov 2020 11:29:52 -0500 Subject: [PATCH] Text updates --- plugins/txt/game/config/txt.yml | 11 ++ plugins/txt/plugin/commands/txt_new_scene.rb | 21 ++- plugins/txt/plugin/commands/txt_send_cmd.rb | 67 ++++--- plugins/txt/plugin/help/en/txt.md | 21 ++- plugins/txt/plugin/help/en/txt_tutorial.md | 60 ++++++ plugins/txt/plugin/helpers.rb | 68 +++++-- plugins/txt/plugin/locales/locale_en.yml | 15 +- .../plugin/plugin/commands/txt_color_cmd.rb | 18 ++ .../plugin/plugin/commands/txt_new_scene.rb | 64 +++++++ .../plugin/plugin/commands/txt_reply_cmd.rb | 40 ++++ .../plugin/plugin/commands/txt_send_cmd.rb | 173 +++++++++++++++++ plugins/txt/plugin/plugin/help/en/txt.md | 33 ++++ .../txt/plugin/plugin/help/en/txt_tutorial.md | 60 ++++++ plugins/txt/plugin/plugin/helpers.rb | 78 ++++++++ .../txt/plugin/plugin/locales/locale_en.yml | 34 ++++ plugins/txt/plugin/plugin/public/txt_char.rb | 10 + plugins/txt/plugin/plugin/txt.rb | 38 ++++ .../txt/plugin/plugin/web/add_txt_handler.rb | 134 ++++++++++++++ plugins/txt/plugin/web/add_txt_handler.rb | 175 +++++++----------- .../webportal/components/live-scene-txt.js | 35 ++++ .../templates/components/live-scene-txt.hbs | 1 + plugins/txt/readme.md | 55 +++--- 22 files changed, 1010 insertions(+), 201 deletions(-) create mode 100644 plugins/txt/game/config/txt.yml create mode 100644 plugins/txt/plugin/help/en/txt_tutorial.md create mode 100644 plugins/txt/plugin/plugin/commands/txt_color_cmd.rb create mode 100644 plugins/txt/plugin/plugin/commands/txt_new_scene.rb create mode 100644 plugins/txt/plugin/plugin/commands/txt_reply_cmd.rb create mode 100644 plugins/txt/plugin/plugin/commands/txt_send_cmd.rb create mode 100644 plugins/txt/plugin/plugin/help/en/txt.md create mode 100644 plugins/txt/plugin/plugin/help/en/txt_tutorial.md create mode 100644 plugins/txt/plugin/plugin/helpers.rb create mode 100644 plugins/txt/plugin/plugin/locales/locale_en.yml create mode 100644 plugins/txt/plugin/plugin/public/txt_char.rb create mode 100644 plugins/txt/plugin/plugin/txt.rb create mode 100644 plugins/txt/plugin/plugin/web/add_txt_handler.rb create mode 100644 plugins/txt/plugin/webportal/components/live-scene-txt.js create mode 100644 plugins/txt/plugin/webportal/templates/components/live-scene-txt.hbs diff --git a/plugins/txt/game/config/txt.yml b/plugins/txt/game/config/txt.yml new file mode 100644 index 00000000..05ff9dc5 --- /dev/null +++ b/plugins/txt/game/config/txt.yml @@ -0,0 +1,11 @@ +--- +txt: + use_nick: false + use_only_nick: false + txt_start_marker: ( + txt_end_marker: ) + txt_preface: "TXT" + scene_type: "Text" + location: "Text" + shortcuts: + text: txt diff --git a/plugins/txt/plugin/commands/txt_new_scene.rb b/plugins/txt/plugin/commands/txt_new_scene.rb index 050da5fd..ff942823 100644 --- a/plugins/txt/plugin/commands/txt_new_scene.rb +++ b/plugins/txt/plugin/commands/txt_new_scene.rb @@ -10,14 +10,19 @@ def parse_args self.names = [] else args = cmd.parse_args(ArgParser.arg1_equals_arg2) - self.names = list_arg(args.arg1) - self.names_raw = trim_arg(args.arg1) - self.message = trim_arg(args.arg2) + if (args.arg1 && (args.arg1.include?("http://") || args.arg1.include?("https://")) ) + self.names = [] + else + self.names = list_arg(args.arg1) + self.names_raw = trim_arg(args.arg1) + self.message = trim_arg(args.arg2) + end end end - def required_args - [ self.names, self.message ] + def check_approved + return nil if enactor.is_approved? + return t('dispatcher.not_allowed') end def check_txt_target @@ -35,7 +40,11 @@ def handle end end - scene = Scenes.start_scene(enactor, "Text", true, "Text", true) + scene_type = Global.read_config("txt", "scene_type") + location = Global.read_config("txt", "location") + scene = Scenes.start_scene(enactor, location, true, false, scene_type, true) + + # Scenes.create_scene_temproom(scene) Global.logger.info "Scene #{scene.id} started by #{enactor.name} in Temp Txt Room." diff --git a/plugins/txt/plugin/commands/txt_send_cmd.rb b/plugins/txt/plugin/commands/txt_send_cmd.rb index c1343352..a29a3417 100644 --- a/plugins/txt/plugin/commands/txt_send_cmd.rb +++ b/plugins/txt/plugin/commands/txt_send_cmd.rb @@ -4,7 +4,7 @@ class TxtSendCmd include CommandHandler # Possible commands... txt name=message; txt =message; txt name[/optional scene #]= - attr_accessor :names, :message, :scene_id, :scene, :txt, :txt_recipient + attr_accessor :names, :message, :scene_id, :scene, :txt, :txt_recipient, :use_only_nick def parse_args if (!cmd.args) @@ -45,6 +45,11 @@ def parse_args end end + def check_approved + return nil if enactor.is_approved? + return t('dispatcher.not_allowed') + end + def check_txt_target return t('txt.txt_target_missing') if !self.names || self.names.empty? return nil @@ -55,7 +60,7 @@ def handle # Is scene real and can you text to it? if self.scene_id scene = Scene[self.scene_id] - can_txt_scene = Scenes.can_edit_scene?(enactor, scene) + can_txt_scene = Scenes.can_join_scene?(enactor, scene) if !scene client.emit_failure t('txt.scene_not_found') return @@ -71,24 +76,23 @@ def handle self.scene = scene end - #Are recipients real and online? + #Are recipients real, online, and in the scene? recipients = [] self.names.each do |name| char = Character.named(name) - if !char client.emit_failure t('txt.no_such_character') return elsif (!Login.is_online?(char) && !self.scene) - client.emit_failure t('txt.target_offline_no_scene', :name => name ) + client.emit_failure t('txt.target_offline_no_scene', :name => name.titlecase ) return else recipients.concat [char] end - #Add recipient to scene + #Add recipient to scene if they are not already a participant if self.scene - can_txt_scene = Scenes.can_edit_scene?(char, self.scene) + can_txt_scene = Scenes.can_join_scene?(char, self.scene) if (!can_txt_scene) Scenes.add_to_scene(scene, t('txt.recipient_added_to_scene', :name => char.name ), enactor, nil, true ) @@ -112,31 +116,38 @@ def handle end end - recipient_names = Txt.format_recipient_indicator(recipients) + recipient_display_names = Txt.format_recipient_display_names(recipients) + recipient_names = Txt.format_recipient_names(recipients) + sender_display_name = Txt.format_sender_display_name(enactor) + self.use_only_nick = Global.read_config("txt", "use_only_nick") # If scene, add text to scene if self.scene - scene_txt = t('txt.txt_to_scene_with_recipient', - :txt => Txt.format_txt_indicator(enactor, recipient_names), - :sender => enactor.name, - # :recipients => recipient_names, - :message => message, - :scene_id => self.scene_id ) + if self.use_only_nick + scene_id = "#{self.scene_id} - #{enactor.name}" + else + scene_id = self.scene_id + end + + scene_txt = t('txt.txt_no_scene_id', :txt => Txt.format_txt_indicator(enactor, recipient_display_names), :sender => sender_display_name, :message => message) + + self.txt = t('txt.txt_with_scene_id', :txt => Txt.format_txt_indicator(enactor, recipient_display_names), :sender => sender_display_name, :message => message, :scene_id => scene_id ) Scenes.add_to_scene(self.scene, scene_txt, enactor) Rooms.emit_ooc_to_room self.scene.room, scene_txt - end + else + if self.use_only_nick + self.txt = t('txt.txt_no_scene_id_nick', :txt => Txt.format_txt_indicator(enactor, recipient_display_names), :sender => sender_display_name, :message => message, :sender_char => enactor.name ) + else + self.txt = t('txt.txt_no_scene_id', :txt => Txt.format_txt_indicator(enactor, recipient_display_names), :sender => sender_display_name, :message => message) + end - # If online, send emit to sender and recipients. + end - self.txt = t('txt.txt_to_sender', - :txt => Txt.format_txt_indicator(enactor, recipient_names), - :sender => enactor.name, - # :recipients => recipient_names, - :message => message) + # If online, send emit to sender and recipients if they aren't in the scene's room. #To recipients recipients.each do |char| - if Login.is_online?(char) + if (Login.is_online?(char)) && (!self.scene || char.room != self.scene.room) recipient = char if recipient.page_ignored.include?(enactor) @@ -146,24 +157,22 @@ def handle client.emit_ooc t('page.recipient_do_not_disturb', :name => recipient.name) return end - Txt.txt_recipient(enactor, recipient, recipient_names, self.txt, self.scene_id) + Txt.txt_recipient(enactor, recipient, recipient_display_names, self.txt, scene_id) end end + #To sender - if self.scene_id && (enactor.room.scene_id != self.scene_id) - client.emit "#{self.txt} %xh%xx(Scene #{self.scene_id})" - else + if (!self.scene || enactor_room != self.scene.room) client.emit self.txt end enactor.update(txt_last: list_arg(recipient_names)) enactor.update(txt_scene: self.scene_id) - end + def log_command - # Don't log texts + # Don't log texts end - end end end diff --git a/plugins/txt/plugin/help/en/txt.md b/plugins/txt/plugin/help/en/txt.md index 57bba746..2a22476e 100644 --- a/plugins/txt/plugin/help/en/txt.md +++ b/plugins/txt/plugin/help/en/txt.md @@ -1,30 +1,33 @@ --- -toc: Playing the Game +toc: 4 - Writing the Story summary: How to send texts. aliases: - text - Texting - texts --- +#Texts +Send text messages to other characters. + +> Learn how the text system works in the [Text Tutorial](/help/txt_tutorial). ## Texting from the Web-Portal -There is a "Send Txt" button on any active scene in the web-portal. Texting into a scene will send a message in-game, if the character is connected. Otherwise, it will just send a text into the scene. +There is a "Txt" button on any active scene in the web-portal. Texting into a scene will send a message in-game, if the character is connected. By default, texting on the portal will send a text to all participants of the scene. -`=` - Send a message to a person from the webportal. If the recipient isn't already a participant in the scene, this will add them. +`=` - Send a message to a specific person from the webportal. Adds recipients to scene if not already a participant. -> Keep in mind that someone who's not logged in won't know they've been texted in a scene unless they check! Be courteous! +> **Note:** Someone who's not logged in may not know they've been texted unless they notice their notifications! ## Commands -`txt [ ]=` - Send a message to name(s). -`txt [ ]/=` - Send a text to name + log it in a scene. If the recipient isn't already a participant in the scene, this will add them. +`txt/newscene [ ]=` - Starts a new scene + sends a message to those names + the scene. +`txt [ ]=` - Send a message to name(s) outside of a scene. +`txt [ ]/=` - Send a text to name + add it to a scene. Adds recipients to scene if not already a participant. `txt [=]` - Send a message to your last text target + last scene. `txt/reply` - See who last texted you. `txt/reply ` - Reply to the last text (including all recipients + scene, if there is one) -`txt/newscene [ ]=` - Starts a new scene + sends a message to those names + the scene. - `txt/color ` - Color the (TXT to ) prefix. Use ansi color format for this, ex: \%xh\%xr for red highlight, \%xh\%xg for green highlight. -> If you do not wish to receive txts (in general, or from a specific person), the `page/ignore =` and `page/dnd ` commands will block txts as well. +> **Note:** If you do not wish to receive txts (in general, or from a specific person), the `page/ignore =` and `page/dnd ` commands will block txts as well. diff --git a/plugins/txt/plugin/help/en/txt_tutorial.md b/plugins/txt/plugin/help/en/txt_tutorial.md new file mode 100644 index 00000000..529408b7 --- /dev/null +++ b/plugins/txt/plugin/help/en/txt_tutorial.md @@ -0,0 +1,60 @@ +--- +toc: 4 - Writing the Story +tutorial: true +summary: How to send texts. +--- +# Texts + +The text plugin lets you send text messages to other characters. + +[[toc]] + +##Sending Texts without a Scene + +On the game, you can text characters online by sending a text without specifying a scene number. These texts are not added to any scene and will not be logged or saved unless you do so manually. + +Do `txt =` to send a text without adding it to a scene. + +> **Note:** Texting characters without an attached scene only works when all characters are logged in to the game via telnet; it will not work via the portal. Texting via the portal requires a scene. + +##Sending Texts in a Scene + +###Starting a Scene + +On game, you can start a new text scene in one easy step. + +`txt/newscene [` + +This will start a new scene, set the location and scene type, emit the text to all characters currently online, and add the text to the scene. + +On the portal, you will need to [start a scene](/help/scenes_tutorial#starting-a-scene) and set the location and type manually. + +###Replying to Texts + +####On Game +If someone sends you a text, you can quickly reply to the text using `txt/reply=`. This will send your text to everyone in the recipient list and add it to the scene. To see who last texted you, type `txt/reply` + +On the game, the 'txt' command will remember the last character and scene you texted. If you continue to text the same person, you can simply do `txt [`. + +If you're texting several different recipients or to several different scenes at once, you'll need to specify who you are texting and what scene it should be added to by doing `txt [=`. + +If you text someone who was not previously in that scene, they will automatically be added to the scene. + +####On the Portal +Texts sent from the portal add the texts to the scene and emit to anyone who is online on the game. + +Send texts by using the 'Txt' button next to the 'Add OOC' and 'Add Pose' buttons on the portal. By default, this button texts everyone in the scene. + +To send texts to a different recipient list, do ` [name]=` and use the 'Txt' button. + +##Text Settings + +###Text Color + +You can choose a personal text color to make text scenes more readable. Do `txt/color ` to set your personal color. You can view available colors by doing `colors`, `colors1`, `colors2`, etc. + +Use the full ansi color format for this, ex: \%xh\%xr for red highlight, \%xh\%x46 for bright green highlight, etc. + +###Ignoring or Blocking Texts + +If you do not wish to receive txts (in general, or from a specific person), the `page/ignore =` and `page/dnd ` commands will block txts as well. diff --git a/plugins/txt/plugin/helpers.rb b/plugins/txt/plugin/helpers.rb index a7c4e4db..9d93b7cd 100644 --- a/plugins/txt/plugin/helpers.rb +++ b/plugins/txt/plugin/helpers.rb @@ -3,20 +3,58 @@ module Txt def self.format_txt_indicator(char, names) t('txt.txt_indicator', -# :start_marker => Global.read_config("page", "page_start_marker") || "<", -# :end_marker => Global.read_config("page", "page_end_marker") || "<", - :start_marker => "(", - :recipients => names, - :end_marker => ")", - :color => Txt.txt_color(char) ) + :start_marker => Global.read_config("txt", "txt_start_marker") || "(", :end_marker => Global.read_config("txt", "txt_end_marker") || ")", :preface => Global.read_config("txt", "txt_preface"), :recipients => names, :color => Txt.txt_color(char) ) end - def self.format_recipient_indicator(recipients) - recipient_names = [] + def self.format_recipient_display_names(recipients) + use_nick = Global.read_config("txt", "use_nick") + use_only_nick = Global.read_config("txt", "use_only_nick") + recipient_display_names = [] recipients.each do |char| - recipient_names.concat [char.name] + if use_nick + puts "USE ONLY NICK" + recipient_display_names.concat [char.nick] + elsif use_only_nick + nickname_field = Global.read_config("demographics", "nickname_field") || "" + if (char.demographic(nickname_field)) + recipient_display_names.concat [char.demographic(nickname_field)] + else + recipient_display_names.concat [char.name] + end + else + recipient_display_names.concat [char.name] + end + end + return t('txt.recipient_indicator', :recipients => recipient_display_names.join(" ")) + end + + def self.format_sender_display_name(sender) + use_nick = Global.read_config("txt", "use_nick") + use_only_nick = Global.read_config("txt", "use_only_nick") + if use_nick + sender_display_name = sender.nick + elsif use_only_nick + nickname_field = Global.read_config("demographics", "nickname_field") || "" + if (sender.demographic(nickname_field)) + sender_display_name = sender.demographic(nickname_field) + else + sender_display_name = sender.name + end + else + sender_display_name = sender.name end + return sender_display_name + end + def self.format_recipient_names(recipients) + recipient_names = [] + recipients.each do |char| + if !char + return { error: t('txt.no_such_character') } + else + recipient_names.concat [char.name] + end + end return t('txt.recipient_indicator', :recipients => recipient_names.join(" ")) end @@ -24,17 +62,11 @@ def self.txt_color(char) char.txt_color || "%xh%xy" end - def self.txt_recipient(sender, recipient, recipient_names, message, scene_id) + def self.txt_recipient(sender, recipient, recipient_names, message, scene_id = nil) client = Login.find_client(sender) recipient_client = Login.find_client(recipient) - if scene_id - Login.emit_if_logged_in recipient, "#{message} %xh%xx(Scene #{scene_id})" - Page.send_afk_message(client, recipient_client, recipient) - else - Login.emit_if_logged_in recipient, message - Page.send_afk_message(client, recipient_client, recipient) - end - + Login.emit_if_logged_in recipient, message + Page.send_afk_message(client, recipient_client, recipient) txt_received = "#{recipient_names}" + " #{sender.name}" txt_received.slice! "#{recipient.name}" recipient.update(txt_received: (txt_received.squish)) diff --git a/plugins/txt/plugin/locales/locale_en.yml b/plugins/txt/plugin/locales/locale_en.yml index 475752c4..834850ca 100644 --- a/plugins/txt/plugin/locales/locale_en.yml +++ b/plugins/txt/plugin/locales/locale_en.yml @@ -1,19 +1,18 @@ --- en: txt: + #Text Message Formatting + txt_no_scene_id: "%{txt} %xh%xw %{sender}%xn: %{message}%xn" + txt_no_scene_id_nick: "%{txt} %xh%{sender}%xn: %{message} %xx%xh(%{sender_char})%xn" + txt_with_scene_id: "%{txt} %xh%{sender}%xn: %{message} %xx%xh(Scene %{scene_id})%xn" + txt_target_missing: "Beep boop: To whom shall I send this message?" cant_txt_ignored: "You can't txt %{names} because you're on their ignore list." recipient_do_not_disturb: "%{name} is set 'do not disturb' right now. Please try your text again later." - target_offline_no_scene: "%{name} is not connected and you did not specify a scene." - - txt_to_sender: "%{txt} %{sender}%xn: %{message}%xn" - txt_to_recipient: "%{txt} %{sender}%xn: %{message}%xn" - txt_to_recipient_with_scene: "%{txt} %xh%{sender}%xn: %{message} %xx%xh(Scene %{scene_id})%xn" + target_offline_no_scene: "%{name} is not connected and you did not specify a scene. To send texts to someone who is offline, start a new scene (txt/newscene name=msg)." recipient_added_to_scene: "That text has added %{name} to the scene participants list." - txt_to_scene_with_recipient: "%{txt} %xh%xw %{sender}%xn: %{message}%xn" - txt_to_scene_no_recipient: "%{txt} %xh%xw %{sender}%xn: %{message}%xn" no_such_character: "No character found by that name." no_one_to_reply_to: "Looks like no one's txt'd you recently. Sorry." @@ -22,7 +21,7 @@ en: recipient_indicator: "%{recipients}" - txt_indicator: "%{color}%{start_marker}TXT to %{recipients}%{color}%{end_marker}%xn" + txt_indicator: "%{color}%{start_marker}%{preface} to %{recipients}%{color}%{end_marker}%xn" color_set: "Txts will now appear with this marker: %{option}%%%xn" diff --git a/plugins/txt/plugin/plugin/commands/txt_color_cmd.rb b/plugins/txt/plugin/plugin/commands/txt_color_cmd.rb new file mode 100644 index 00000000..0ef41b32 --- /dev/null +++ b/plugins/txt/plugin/plugin/commands/txt_color_cmd.rb @@ -0,0 +1,18 @@ +module AresMUSH + module Txt + class TxtColorCmd + include CommandHandler + + attr_accessor :option + + def parse_args + self.option = trim_arg(cmd.args) + end + + def handle + enactor.update(txt_color: self.option) + client.emit_success t('txt.color_set', :option => self.option) + end + end + end +end diff --git a/plugins/txt/plugin/plugin/commands/txt_new_scene.rb b/plugins/txt/plugin/plugin/commands/txt_new_scene.rb new file mode 100644 index 00000000..981ef24b --- /dev/null +++ b/plugins/txt/plugin/plugin/commands/txt_new_scene.rb @@ -0,0 +1,64 @@ +module AresMUSH + module Txt + class TxtNewSceneCmd + include CommandHandler + + attr_accessor :names, :names_raw, :message, :scene_id + + def parse_args + if (!cmd.args) + self.names = [] + else + args = cmd.parse_args(ArgParser.arg1_equals_arg2) + if (args.arg1 && (args.arg1.include?("http://") || args.arg1.include?("https://")) ) + self.names = [] + else + self.names = list_arg(args.arg1) + self.names_raw = trim_arg(args.arg1) + self.message = trim_arg(args.arg2) + end + end + end + + def check_txt_target + return t('txt.txt_new_scene_target_missing') if !self.names || self.names.empty? + return nil + end + + def handle + + self.names.each do |name| + result = Character.named(name) + if !result + client.emit_failure t('txt.no_such_character') + return + end + end + + scene_type = Global.read_config("txt", "scene_type") + location = Global.read_config("txt", "location") + scene = Scenes.start_scene(enactor, location, true, false, scene_type, true) + + # Scenes.create_scene_temproom(scene) + + Global.logger.info "Scene #{scene.id} started by #{enactor.name} in Temp Txt Room." + + # Checks if the names are valid. If so, starts a scene. + Global.dispatcher.queue_command(client, Command.new("txt #{self.names_raw}/#{scene.id}=#{self.message}")) + + scene.participants.add enactor + + self.names.each do |name| + char = Character.named(name) + if (!scene.participants.include?(char)) + scene.participants.add char + end + if (!scene.watchers.include?(char)) + scene.watchers.add char + end + end + + end + end + end +end diff --git a/plugins/txt/plugin/plugin/commands/txt_reply_cmd.rb b/plugins/txt/plugin/plugin/commands/txt_reply_cmd.rb new file mode 100644 index 00000000..52cf5419 --- /dev/null +++ b/plugins/txt/plugin/plugin/commands/txt_reply_cmd.rb @@ -0,0 +1,40 @@ +module AresMUSH + module Txt + class TxtReplyCmd + include CommandHandler + + attr_accessor :names, :names_raw, :message, :scene_id + + def parse_args + self.message = cmd.args + end + + def check_received_txts + unless enactor.txt_received + client.emit_failure t('txt.no_one_to_reply_to') + return + end + end + + def handle + if !self.message + #Tell what the last text recieved was + if enactor.txt_received_scene + client.emit_success t('txt.reply_scene', :names => enactor.txt_received, :scene => enactor.txt_received_scene) + else + client.emit_success t('txt.reply', :names => enactor.txt_received ) + end + elsif enactor.txt_received_scene + Global.dispatcher.queue_command(client, Command.new("txt #{enactor.txt_received}/#{enactor.txt_received_scene}=#{self.message}")) + else + Global.dispatcher.queue_command(client, Command.new("txt #{enactor.txt_received}=#{self.message}")) + end + end + + def log_command + # Don't log texts + end + + end + end +end diff --git a/plugins/txt/plugin/plugin/commands/txt_send_cmd.rb b/plugins/txt/plugin/plugin/commands/txt_send_cmd.rb new file mode 100644 index 00000000..f2172627 --- /dev/null +++ b/plugins/txt/plugin/plugin/commands/txt_send_cmd.rb @@ -0,0 +1,173 @@ +module AresMUSH + module Txt + class TxtSendCmd + include CommandHandler +# Possible commands... txt name=message; txt =message; txt name[/optional scene #]= + + attr_accessor :names, :message, :scene_id, :scene, :txt, :txt_recipient, :use_only_nick + + def parse_args + if (!cmd.args) + self.names = [] + + elsif (cmd.args.start_with?("=")) + self.names = enactor.txt_last + self.scene_id = enactor.txt_scene + self.message = cmd.args.after("=") + + elsif (cmd.args.include?("=")) + args = cmd.parse_args(ArgParser.arg1_equals_arg2) + # Catch the common mistake of last-paging someone a link. + # p http://stuff.com/stuff=this.file + if (args.arg1 && (args.arg1.include?("http://") || args.arg1.include?("https://")) ) + self.names = enactor.txt_last + self.message = "#{args.arg1}=#{args.arg2}" + + elsif ( args.arg1.include?("/") ) + if args.arg1.rest("/").is_integer? + self.scene_id = args.arg1.rest("/") + self.names = list_arg(args.arg1.first("/")) + self.message = trim_arg(args.arg2) + elsif args.arg1.rest("/").chr.casecmp?("s") + self.scene_id = enactor.room.scene_id + self.names = list_arg(args.arg1.first("/")) + self.message = trim_arg(args.arg2) + end + else + self.names = list_arg(args.arg1) + self.message = trim_arg(args.arg2) + end + + else + self.names = enactor.txt_last + self.scene_id = enactor.txt_scene + self.message = cmd.args + end + end + + def check_txt_target + return t('txt.txt_target_missing') if !self.names || self.names.empty? + return nil + end + + + def handle + # Is scene real and can you text to it? + if self.scene_id + scene = Scene[self.scene_id] + can_txt_scene = Scenes.can_join_scene?(enactor, scene) + if !scene + client.emit_failure t('txt.scene_not_found') + return + elsif scene.completed + client.emit_failure t('txt.scene_not_running') + return + elsif !scene.room + raise "Trying to pose to a scene that doesn't have a room." + elsif !can_txt_scene + client.emit_failure t('txt.scene_no_access') + return + end + self.scene = scene + end + + #Are recipients real, online, and in the scene? + recipients = [] + self.names.each do |name| + char = Character.named(name) + if !char + client.emit_failure t('txt.no_such_character') + return + elsif (!Login.is_online?(char) && !self.scene) + client.emit_failure t('txt.target_offline_no_scene', :name => name.titlecase ) + return + else + recipients.concat [char] + end + + #Add recipient to scene if they are not already a participant + if self.scene + can_txt_scene = Scenes.can_join_scene?(char, self.scene) + if (!can_txt_scene) + Scenes.add_to_scene(scene, t('txt.recipient_added_to_scene', :name => char.name ), + enactor, nil, true ) + Rooms.emit_ooc_to_room self.scene.room, t('txt.recipient_added_to_scene', + :name => char.name ) + + if (enactor.room != self.scene.room) + client.emit_success t('txt.recipient_added_to_scene', + :name =>char.name ) + end + + if (!scene.participants.include?(char)) + scene.participants.add char + end + + if (!scene.watchers.include?(char)) + scene.watchers.add char + end + + end + end + end + + recipient_display_names = Txt.format_recipient_display_names(recipients) + recipient_names = Txt.format_recipient_names(recipients) + sender_display_name = Txt.format_sender_display_name(enactor) + + self.use_only_nick = Global.read_config("txt", "use_only_nick") + # If scene, add text to scene + if self.scene + if self.use_only_nick + scene_id = "#{self.scene_id} - #{enactor.name}" + else + scene_id = self.scene_id + end + + scene_txt = t('txt.txt_no_scene_id', :txt => Txt.format_txt_indicator(enactor, recipient_display_names), :sender => sender_display_name, :message => message) + + self.txt = t('txt.txt_with_scene_id', :txt => Txt.format_txt_indicator(enactor, recipient_display_names), :sender => sender_display_name, :message => message, :scene_id => scene_id ) + + Scenes.add_to_scene(self.scene, scene_txt, enactor) + Rooms.emit_ooc_to_room self.scene.room, scene_txt + else + if self.use_only_nick + self.txt = t('txt.txt_no_scene_id_nick', :txt => Txt.format_txt_indicator(enactor, recipient_display_names), :sender => sender_display_name, :message => message, :sender_char => enactor.name ) + else + self.txt = t('txt.txt_no_scene_id', :txt => Txt.format_txt_indicator(enactor, recipient_display_names), :sender => sender_display_name, :message => message) + end + + end + + # If online, send emit to sender and recipients if they aren't in the scene's room. + #To recipients + recipients.each do |char| + if (Login.is_online?(char)) && (!self.scene || char.room != self.scene.room) + recipient = char + + if recipient.page_ignored.include?(enactor) + client.emit_failure t('txt.cant_txt_ignored', :names => recipient.name) + return + elsif (recipient.page_do_not_disturb) + client.emit_ooc t('page.recipient_do_not_disturb', :name => recipient.name) + return + end + Txt.txt_recipient(enactor, recipient, recipient_display_names, self.txt, scene_id) + end + end + + #To sender + if (!self.scene || enactor_room != self.scene.room) + client.emit self.txt + end + + enactor.update(txt_last: list_arg(recipient_names)) + enactor.update(txt_scene: self.scene_id) + end + + def log_command + # Don't log texts + end + end + end +end diff --git a/plugins/txt/plugin/plugin/help/en/txt.md b/plugins/txt/plugin/plugin/help/en/txt.md new file mode 100644 index 00000000..2a22476e --- /dev/null +++ b/plugins/txt/plugin/plugin/help/en/txt.md @@ -0,0 +1,33 @@ +--- +toc: 4 - Writing the Story +summary: How to send texts. +aliases: +- text +- Texting +- texts +--- +#Texts +Send text messages to other characters. + +> Learn how the text system works in the [Text Tutorial](/help/txt_tutorial). + +## Texting from the Web-Portal +There is a "Txt" button on any active scene in the web-portal. Texting into a scene will send a message in-game, if the character is connected. By default, texting on the portal will send a text to all participants of the scene. + +`=` - Send a message to a specific person from the webportal. Adds recipients to scene if not already a participant. + +> **Note:** Someone who's not logged in may not know they've been texted unless they notice their notifications! + +## Commands +`txt/newscene [ ]=` - Starts a new scene + sends a message to those names + the scene. + +`txt [ ]=` - Send a message to name(s) outside of a scene. +`txt [ ]/=` - Send a text to name + add it to a scene. Adds recipients to scene if not already a participant. +`txt [=]` - Send a message to your last text target + last scene. + +`txt/reply` - See who last texted you. +`txt/reply ` - Reply to the last text (including all recipients + scene, if there is one) + +`txt/color ` - Color the (TXT to ) prefix. Use ansi color format for this, ex: \%xh\%xr for red highlight, \%xh\%xg for green highlight. + +> **Note:** If you do not wish to receive txts (in general, or from a specific person), the `page/ignore =` and `page/dnd ` commands will block txts as well. diff --git a/plugins/txt/plugin/plugin/help/en/txt_tutorial.md b/plugins/txt/plugin/plugin/help/en/txt_tutorial.md new file mode 100644 index 00000000..529408b7 --- /dev/null +++ b/plugins/txt/plugin/plugin/help/en/txt_tutorial.md @@ -0,0 +1,60 @@ +--- +toc: 4 - Writing the Story +tutorial: true +summary: How to send texts. +--- +# Texts + +The text plugin lets you send text messages to other characters. + +[[toc]] + +##Sending Texts without a Scene + +On the game, you can text characters online by sending a text without specifying a scene number. These texts are not added to any scene and will not be logged or saved unless you do so manually. + +Do `txt =` to send a text without adding it to a scene. + +> **Note:** Texting characters without an attached scene only works when all characters are logged in to the game via telnet; it will not work via the portal. Texting via the portal requires a scene. + +##Sending Texts in a Scene + +###Starting a Scene + +On game, you can start a new text scene in one easy step. + +`txt/newscene [` + +This will start a new scene, set the location and scene type, emit the text to all characters currently online, and add the text to the scene. + +On the portal, you will need to [start a scene](/help/scenes_tutorial#starting-a-scene) and set the location and type manually. + +###Replying to Texts + +####On Game +If someone sends you a text, you can quickly reply to the text using `txt/reply=`. This will send your text to everyone in the recipient list and add it to the scene. To see who last texted you, type `txt/reply` + +On the game, the 'txt' command will remember the last character and scene you texted. If you continue to text the same person, you can simply do `txt [`. + +If you're texting several different recipients or to several different scenes at once, you'll need to specify who you are texting and what scene it should be added to by doing `txt [=`. + +If you text someone who was not previously in that scene, they will automatically be added to the scene. + +####On the Portal +Texts sent from the portal add the texts to the scene and emit to anyone who is online on the game. + +Send texts by using the 'Txt' button next to the 'Add OOC' and 'Add Pose' buttons on the portal. By default, this button texts everyone in the scene. + +To send texts to a different recipient list, do ` [name]=` and use the 'Txt' button. + +##Text Settings + +###Text Color + +You can choose a personal text color to make text scenes more readable. Do `txt/color ` to set your personal color. You can view available colors by doing `colors`, `colors1`, `colors2`, etc. + +Use the full ansi color format for this, ex: \%xh\%xr for red highlight, \%xh\%x46 for bright green highlight, etc. + +###Ignoring or Blocking Texts + +If you do not wish to receive txts (in general, or from a specific person), the `page/ignore =` and `page/dnd ` commands will block txts as well. diff --git a/plugins/txt/plugin/plugin/helpers.rb b/plugins/txt/plugin/plugin/helpers.rb new file mode 100644 index 00000000..9d93b7cd --- /dev/null +++ b/plugins/txt/plugin/plugin/helpers.rb @@ -0,0 +1,78 @@ +module AresMUSH + module Txt + + def self.format_txt_indicator(char, names) + t('txt.txt_indicator', + :start_marker => Global.read_config("txt", "txt_start_marker") || "(", :end_marker => Global.read_config("txt", "txt_end_marker") || ")", :preface => Global.read_config("txt", "txt_preface"), :recipients => names, :color => Txt.txt_color(char) ) + end + + def self.format_recipient_display_names(recipients) + use_nick = Global.read_config("txt", "use_nick") + use_only_nick = Global.read_config("txt", "use_only_nick") + recipient_display_names = [] + recipients.each do |char| + if use_nick + puts "USE ONLY NICK" + recipient_display_names.concat [char.nick] + elsif use_only_nick + nickname_field = Global.read_config("demographics", "nickname_field") || "" + if (char.demographic(nickname_field)) + recipient_display_names.concat [char.demographic(nickname_field)] + else + recipient_display_names.concat [char.name] + end + else + recipient_display_names.concat [char.name] + end + end + return t('txt.recipient_indicator', :recipients => recipient_display_names.join(" ")) + end + + def self.format_sender_display_name(sender) + use_nick = Global.read_config("txt", "use_nick") + use_only_nick = Global.read_config("txt", "use_only_nick") + if use_nick + sender_display_name = sender.nick + elsif use_only_nick + nickname_field = Global.read_config("demographics", "nickname_field") || "" + if (sender.demographic(nickname_field)) + sender_display_name = sender.demographic(nickname_field) + else + sender_display_name = sender.name + end + else + sender_display_name = sender.name + end + return sender_display_name + end + + def self.format_recipient_names(recipients) + recipient_names = [] + recipients.each do |char| + if !char + return { error: t('txt.no_such_character') } + else + recipient_names.concat [char.name] + end + end + return t('txt.recipient_indicator', :recipients => recipient_names.join(" ")) + end + + def self.txt_color(char) + char.txt_color || "%xh%xy" + end + + def self.txt_recipient(sender, recipient, recipient_names, message, scene_id = nil) + client = Login.find_client(sender) + recipient_client = Login.find_client(recipient) + Login.emit_if_logged_in recipient, message + Page.send_afk_message(client, recipient_client, recipient) + txt_received = "#{recipient_names}" + " #{sender.name}" + txt_received.slice! "#{recipient.name}" + recipient.update(txt_received: (txt_received.squish)) + recipient.update(txt_received_scene: scene_id) + end + + + end +end diff --git a/plugins/txt/plugin/plugin/locales/locale_en.yml b/plugins/txt/plugin/plugin/locales/locale_en.yml new file mode 100644 index 00000000..834850ca --- /dev/null +++ b/plugins/txt/plugin/plugin/locales/locale_en.yml @@ -0,0 +1,34 @@ +--- +en: + txt: + #Text Message Formatting + txt_no_scene_id: "%{txt} %xh%xw %{sender}%xn: %{message}%xn" + txt_no_scene_id_nick: "%{txt} %xh%{sender}%xn: %{message} %xx%xh(%{sender_char})%xn" + txt_with_scene_id: "%{txt} %xh%{sender}%xn: %{message} %xx%xh(Scene %{scene_id})%xn" + + + txt_target_missing: "Beep boop: To whom shall I send this message?" + cant_txt_ignored: "You can't txt %{names} because you're on their ignore list." + recipient_do_not_disturb: "%{name} is set 'do not disturb' right now. Please try your text again later." + target_offline_no_scene: "%{name} is not connected and you did not specify a scene. To send texts to someone who is offline, start a new scene (txt/newscene name=msg)." + + recipient_added_to_scene: "That text has added %{name} to the scene participants list." + no_such_character: "No character found by that name." + + no_one_to_reply_to: "Looks like no one's txt'd you recently. Sorry." + reply_scene: "Last txt came from: %{names}; Scene: %{scene}" + reply: "Last txt came from: %{names}" + + recipient_indicator: "%{recipients}" + + txt_indicator: "%{color}%{start_marker}%{preface} to %{recipients}%{color}%{end_marker}%xn" + + color_set: "Txts will now appear with this marker: %{option}%%%xn" + + scene_not_running: "That scene isn't running. You'll need to restart it if you want to txt into it." + scene_no_access: "You do not have access to txt into that scene. Ask the participants to add you. (Try: scene/addchar #=character )" + scene_not_found: "No scene found by that number." + + incorrect_format: "That's not the correct format. Please use `name(s)=message`" + + txt_new_scene_target_missing: "Please specify a target and message. Ex: txt/newscene Name=Message" diff --git a/plugins/txt/plugin/plugin/public/txt_char.rb b/plugins/txt/plugin/plugin/public/txt_char.rb new file mode 100644 index 00000000..310133f9 --- /dev/null +++ b/plugins/txt/plugin/plugin/public/txt_char.rb @@ -0,0 +1,10 @@ +module AresMUSH + class Character + attribute :txt_last, :type => DataType::Array, :default => [] + attribute :txt_last_scene, :type => DataType::Array, :default => [] + attribute :txt_received + attribute :txt_received_scene + attribute :txt_color + attribute :txt_scene + end + end \ No newline at end of file diff --git a/plugins/txt/plugin/plugin/txt.rb b/plugins/txt/plugin/plugin/txt.rb new file mode 100644 index 00000000..92a173e0 --- /dev/null +++ b/plugins/txt/plugin/plugin/txt.rb @@ -0,0 +1,38 @@ +$:.unshift File.dirname(__FILE__) + +module AresMUSH + module Txt + def self.plugin_dir + File.dirname(__FILE__) + end + + def self.shortcuts + Global.read_config("txt", "shortcuts") + end + + def self.get_cmd_handler(client, cmd, enactor) + case cmd.root + when "txt" + case cmd.switch + when "color" + return TxtColorCmd + when "newscene" + return TxtNewSceneCmd + when "reply" + return TxtReplyCmd + when nil + return TxtSendCmd + end + end + return nil + end + + def self.get_web_request_handler(request) + case request.cmd + when "addTxt" + return AddTxtRequestHandler + end + nil + end + end +end \ No newline at end of file diff --git a/plugins/txt/plugin/plugin/web/add_txt_handler.rb b/plugins/txt/plugin/plugin/web/add_txt_handler.rb new file mode 100644 index 00000000..dd8fd88d --- /dev/null +++ b/plugins/txt/plugin/plugin/web/add_txt_handler.rb @@ -0,0 +1,134 @@ +module AresMUSH + module Txt + class AddTxtRequestHandler + + def handle(request) + scene_id = request.args[:scene_id] + scene = Scene[request.args[:scene_id]] + enactor = request.enactor + pose = request.args[:pose] + + # if !enactor.txt_last_scene + # enactor.update(txt_last_scene: []) + # end + + if (!scene) + return { error: t('webportal.not_found') } + end + + error = Website.check_login(request) + return error if error + + if (!Scenes.can_join_scene?(enactor, scene)) + return { error: t('scenes.access_not_allowed') } + end + + if (scene.completed) + return { error: t('scenes.scene_already_completed') } + end + + if (!scene.room) + raise "Trying to pose to a scene that doesn't have a room." + end + + pose = Website.format_input_for_mush(pose) + + if pose.start_with?("=") + message = pose.after("=") + recipients = scene.participants + elsif pose.include?("=") + if (!pose.rest("=").blank? && (pose.first("=").include?("http://") || pose.first("=").include?("https://") ) ) + recipients = scene.participants + message = pose + else + names = pose.first("=") ? pose.first("=").split(" ") : nil + recipients = [] + names.each do |name| + char = Character.named(name) + if !char + return { error: t('txt.no_such_character') } + else + recipients.concat [char] + end + end + message = pose.rest("=") + end + else + recipients = scene.participants + message = pose + end + + recipients_minus = recipients.delete(enactor) + recipient_names = Txt.format_recipient_names(recipients) + recipient_display_names = Txt.format_recipient_display_names(recipients) + sender_display_name = Txt.format_sender_display_name(enactor) + scene_room = scene.room + use_only_nick = Global.read_config("txt", "use_only_nick") + if use_only_nick + scene_id = "#{scene_id} - #{enactor.name}" + else + scene_id = scene_id + end + + recipients.each do |char| + can_txt_scene = Scenes.can_join_scene?(char, scene) + #If they aren't in the scene currently, add them + if (!can_txt_scene) + Scenes.add_to_scene(scene, t('txt.recipient_added_to_scene', + :name => char.name ), + enactor, nil, true ) + + Rooms.emit_ooc_to_room scene_room,t('txt.recipient_added_to_scene', + :name => char.name ) + + if (!scene.participants.include?(char)) + scene.participants.add char + end + + if (!scene.watchers.include?(char)) + scene.watchers.add char + end + end + + #Emit to online players + + + if Login.is_online?(char) + recipient_txt = t('txt.txt_with_scene_id', + :txt => Txt.format_txt_indicator(enactor, recipient_display_names), + :sender => sender_display_name, + :message => message, + :scene_id => scene_id) + + if (char.page_do_not_disturb) + nil + elsif char.room.scene_id != scene_id + client = Login.find_client(char) + client.emit recipient_txt + else + nil + end + end + end + + scene_txt = t('txt.txt_no_scene_id', + :txt => Txt.format_txt_indicator(enactor, recipient_display_names), + :sender => sender_display_name, + :message => message ) + Scenes.add_to_scene(scene, scene_txt, enactor) + + room_txt = t('txt.txt_with_scene_id', + :txt => Txt.format_txt_indicator(enactor, recipient_display_names), + :sender => sender_display_name, + :message => message, + :scene_id => scene_id) + + Rooms.emit_ooc_to_room scene_room,room_txt + + + { + } + end + end + end +end diff --git a/plugins/txt/plugin/web/add_txt_handler.rb b/plugins/txt/plugin/web/add_txt_handler.rb index 377a3cc1..dd8fd88d 100644 --- a/plugins/txt/plugin/web/add_txt_handler.rb +++ b/plugins/txt/plugin/web/add_txt_handler.rb @@ -2,17 +2,15 @@ module AresMUSH module Txt class AddTxtRequestHandler - attr_accessor :scene_txt - def handle(request) scene_id = request.args[:scene_id] scene = Scene[request.args[:scene_id]] enactor = request.enactor pose = request.args[:pose] - if !enactor.txt_last_scene - enactor.update(txt_last_scene: []) - end + # if !enactor.txt_last_scene + # enactor.update(txt_last_scene: []) + # end if (!scene) return { error: t('webportal.not_found') } @@ -21,7 +19,7 @@ def handle(request) error = Website.check_login(request) return error if error - if (!Scenes.can_edit_scene?(enactor, scene)) + if (!Scenes.can_join_scene?(enactor, scene)) return { error: t('scenes.access_not_allowed') } end @@ -36,138 +34,101 @@ def handle(request) pose = Website.format_input_for_mush(pose) if pose.start_with?("=") - names = enactor.txt_last_scene - # recipient_names = Txt.format_recipient_indicator(names) message = pose.after("=") + recipients = scene.participants elsif pose.include?("=") if (!pose.rest("=").blank? && (pose.first("=").include?("http://") || pose.first("=").include?("https://") ) ) - names = enactor.txt_last_scene + recipients = scene.participants message = pose else - # recipient_names = pose.first("=") names = pose.first("=") ? pose.first("=").split(" ") : nil + recipients = [] + names.each do |name| + char = Character.named(name) + if !char + return { error: t('txt.no_such_character') } + else + recipients.concat [char] + end + end message = pose.rest("=") end else - names = enactor.txt_last_scene - - # recipient_names = Txt.format_recipient_indicator(names) - message = pose + recipients = scene.participants + message = pose end - if ( !names || names.empty? ) - { error: t('txt.txt_target_missing') } + recipients_minus = recipients.delete(enactor) + recipient_names = Txt.format_recipient_names(recipients) + recipient_display_names = Txt.format_recipient_display_names(recipients) + sender_display_name = Txt.format_sender_display_name(enactor) + scene_room = scene.room + use_only_nick = Global.read_config("txt", "use_only_nick") + if use_only_nick + scene_id = "#{scene_id} - #{enactor.name}" + else + scene_id = scene_id end - # recipient_names = InputFormatter.titlecase_arg(recipient_names) - #Making 'Names Raw' take actual character names instead of aliases. - # names_array = recipient_names.split(/ /) - recipient_names = [] - names.each do |name| - char = Character.named(name) - if !char - return { error: t('txt.no_such_character') } - else - recipient_names.concat [char.name] - end - end - recipient_names = recipient_names.join(" ") + recipients.each do |char| + can_txt_scene = Scenes.can_join_scene?(char, scene) + #If they aren't in the scene currently, add them + if (!can_txt_scene) + Scenes.add_to_scene(scene, t('txt.recipient_added_to_scene', + :name => char.name ), + enactor, nil, true ) - scene_room = scene.room - recipients = [] - if !names.empty? - names.each do |name| - char = Character.named(name) - - if !char - return { error: t('txt.no_such_character') } - else - recipients.concat [char.name] - end + Rooms.emit_ooc_to_room scene_room,t('txt.recipient_added_to_scene', + :name => char.name ) - can_txt_scene = Scenes.can_edit_scene?(char, scene) - if (!can_txt_scene) - Scenes.add_to_scene(scene, t('txt.recipient_added_to_scene', - :name => char.name ), - enactor, nil, true ) + if (!scene.participants.include?(char)) + scene.participants.add char + end - Rooms.emit_ooc_to_room scene_room,t('txt.recipient_added_to_scene', - :name => char.name ) + if (!scene.watchers.include?(char)) + scene.watchers.add char + end + end - if (!scene.participants.include?(char)) - scene.participants.add char - end + #Emit to online players - if (!scene.watchers.include?(char)) - scene.watchers.add char - end - end - end - #Emit to online players - names_plus = recipients << enactor.name - - names_plus.each do |name| - recipient = Character.named(name) - - if Login.is_online?(recipient) - recipient_txt = t('txt.txt_to_recipient_with_scene', - :txt => Txt.format_txt_indicator(enactor, recipient_names), - :sender => enactor.name, - # :recipients => recipient_names, - :message => message, - :scene_id => scene_id) - - if (recipient.page_do_not_disturb) - nil - elsif ( scene_id && ( recipient.room.scene_id != scene_id ) ) - client = Login.find_client(recipient) - client.emit recipient_txt - else - nil - end - - txt_received = "#{recipient_names}" + " #{enactor.name}" - txt_received.slice! "#{recipient.name}" - - recipient.update(txt_received: (txt_received.squish)) - recipient.update(txt_received_scene: scene_id) - end + + if Login.is_online?(char) + recipient_txt = t('txt.txt_with_scene_id', + :txt => Txt.format_txt_indicator(enactor, recipient_display_names), + :sender => sender_display_name, + :message => message, + :scene_id => scene_id) + + if (char.page_do_not_disturb) + nil + elsif char.room.scene_id != scene_id + client = Login.find_client(char) + client.emit recipient_txt + else + nil end + end end - if names.empty? - self.scene_txt = t('txt.txt_to_scene_no_recipient', - :txt => Txt.format_txt_indicator(enactor, recipient_names), - :sender => enactor.name, - :message => message ) - else - self.scene_txt = t('txt.txt_to_scene_with_recipient', - :txt => Txt.format_txt_indicator(enactor, recipient_names), - :sender => enactor.name, - # :recipients => recipient_names, - :message => message ) - end + scene_txt = t('txt.txt_no_scene_id', + :txt => Txt.format_txt_indicator(enactor, recipient_display_names), + :sender => sender_display_name, + :message => message ) + Scenes.add_to_scene(scene, scene_txt, enactor) - room_txt = t('txt.txt_to_recipient_with_scene', - :txt => Txt.format_txt_indicator(enactor, recipient_names), - :sender => enactor.name, + room_txt = t('txt.txt_with_scene_id', + :txt => Txt.format_txt_indicator(enactor, recipient_display_names), + :sender => sender_display_name, :message => message, :scene_id => scene_id) Rooms.emit_ooc_to_room scene_room,room_txt - recipients.delete(enactor.name) - enactor.update(txt_last_scene: recipients) - - Scenes.add_to_scene(scene, self.scene_txt, enactor) { } end - - def log_command - # Don't log texts - end end end end diff --git a/plugins/txt/plugin/webportal/components/live-scene-txt.js b/plugins/txt/plugin/webportal/components/live-scene-txt.js new file mode 100644 index 00000000..d99e2133 --- /dev/null +++ b/plugins/txt/plugin/webportal/components/live-scene-txt.js @@ -0,0 +1,35 @@ +import Component from '@ember/component'; +import { inject as service } from '@ember/service'; + +export default Component.extend({ + gameApi: service(), + flashMessages: service(), + scenePose: '', + gameSocket: service(), + session: service(), + tagName: '', + + + actions: { + + addTxt() { + let pose = this.get('scenePose'); + if (pose.length === 0) { + this.get('flashMessages').danger("You haven't entered anything."); + return; + } + let api = this.get('gameApi'); + this.set('scenePose', ''); + api.requestOne('addTxt', { scene_id: this.get('scene.id'), + pose: pose }, null) + .then( (response) => { + if (response.error) { + this.get('flashMessages').error(response.error); + return; + } + }); + } + + + } +}); diff --git a/plugins/txt/plugin/webportal/templates/components/live-scene-txt.hbs b/plugins/txt/plugin/webportal/templates/components/live-scene-txt.hbs new file mode 100644 index 00000000..dac4083c --- /dev/null +++ b/plugins/txt/plugin/webportal/templates/components/live-scene-txt.hbs @@ -0,0 +1 @@ + diff --git a/plugins/txt/readme.md b/plugins/txt/readme.md index 2426b7c1..3166525b 100644 --- a/plugins/txt/readme.md +++ b/plugins/txt/readme.md @@ -1,10 +1,18 @@ -#TXT +# Text System -##Credit -This plugin was originally coded by skew @ Ares Central, with a few updates and packaging by Tat @ Ares Central. +## Credit +This plugin has been updated and is now maintained by Tat @ Ares Central. Original credit for the code goes to skew @ Ares Central. + +## Overview + +A command designed to mimic real world texting. It sends texts or other private messages from one person to multiple people. + +It can send as a simple person-to-person emit (like pages), as a scene emit, or as a person-to-person emit that also logs to a scene. + +Allows users to choose their text color, reply to their previous text, and start new scenes with a text. ## Installation -In the game, run plugin/install txt. +In the game, run `plugin/install `. ### Page Command @@ -12,34 +20,33 @@ This plugin references the default AresMUSH page command. If that is not install See additional setup instructions below. -##Overview -A command designed to mimic real world texting. It sends texts from one person to multiple people. +## Configuring -It can send as a simple person-to-person emit (like pages), as a scene emit, or as a person-to-person emit that also logs to a scene. +### Message format -Allows users to choose their text color, reply to their previous text, start new scenes with a text. +The text preface, start, and end markers are configurable in txt.yml. By default, texts display as: -## Configuring +`(TXT to Tat) Skew : Hello there!` -### Message format +You can further adjust the text format if you like. The message format is contained in `/aresmush/plugins/txt/locales/local_en.yml`. + +###Nicknames + +If you'd like nicknames to appear in the sender and recipient fields, you can toggle `use_nick` or `use_only_nick` true. Only mark ONE of these options as true. + +Note that texts must still be SENT using the character's name and not their nickname. -The message format is contained in `/aresmush/plugins/txt/locales/local_en.yml`. There are two lines, in case you want to make sender and receiver see different things. By default, they are both set to: `%xh%xg%xn (From %{sender}) -> %{recipients}%{message}` +`use_nick` - Changes the sender and recipient display to your nickname display as set up in `nickname_format` in demographics.yml. +`use_only_nick` - Changes the sender and recipient display to your nickname. Displays the sender's character name after the text, with the scene number. -This outputs as: ` From Skew -> (to Pikachu) Hello there!` +###Location and Scene Type +Sets the defaults for `txt/newscene` to autofill the location and scene type of text scenes. Be sure that scene type matches one of your scene_types as set in scenes.yml. -##Web Portal -In addition to the included web portal files, you'll want to add a line of code to `/app/templates/components/live-scene-control.hbs` if you want to enable texting from portal scenes. +## Uninstalling -Insert the following with the other pose buttons: +Removing the plugin requires some code fiddling. See [Uninstalling Plugins](https://www.aresmush.com/tutorials/code/extras.html#uninstalling-plugins). -`{{live-scene-txt scenePose=scenePose scene=scene}}` -For example: +## License -`{{#if (not scene.completed)}} - {{live-scene-txt scenePose=scenePose scene=scene}} - - - - -{{/if}}` +Same as [AresMUSH](https://aresmush.com/license).