module Format
Included Modules
- Tourmaline::Helpers
Extended Modules
Defined in:
privateparlor/format.crInstance Method Summary
-
#allow_text?(text : String) : Bool
Checks the content of the message text and determines if it should be relayed.
- #contains_html?(text : String) : Bool
- #format_contact_reply(contact : String | Nil, locale : Locale) : String | Nil
- #format_cooldown_until(expiration : Time | Nil, locale : Locale) : String
-
#format_help(user : Database::User, ranks : Hash(Int32, Rank), locale : Locale) : String
Returns a message containing the commands the user can use.
-
#format_karma_loading_bar(percentage : Float32, locale : Locale) : String
Formats a loading bar for the /karmainfo command
-
#format_karma_say(signature : String) : String
Returns a bolded signature (as terveisin) showing the karma level of the user that sent this message.
-
#format_motd(text : String, entities : Array(Tourmaline::MessageEntity), linked_network : Hash(String, String)) : String
Parses new MOTD for HTML formatting and returns the MOTD in HTML without the command and whitespace that follows it
-
#format_private_channel_forward(name : String, id : Int64, msid : Int64 | Nil) : String
Removes the "-100" prefix for private channels
- #format_private_user_forward(name : String) : String
- #format_pseudonymous_message(text : String | Nil, tripkey : String, salt : String) : String
- #format_reason_log(reason : String | Nil, locale : Locale) : String | Nil
- #format_reason_reply(reason : String | Nil, locale : Locale) : String | Nil
-
#format_smiley(warnings : Int32, smileys : Array(String)) : String
Returns a smiley based on the number of given warnings
-
#format_time(time : Time | Nil, format : String) : String | Nil
Formats a timestamp according to the locale settings
-
#format_timespan(cmp : Time::Span, time_units : Array(String)) : String
Formats a timespan, so the duration is marked by its largest unit ("20m", "3h", "5d", etc)
- #format_tripcode_reply(tripcode : String | Nil, locale : Locale) : String
- #format_tripcode_sign(name : String, tripcode : String) : String
- #format_user_forward(name : String, id : Int64) : String
-
#format_user_reveal(id : Int64, name : String, locale : Locale) : String
Returns a link to a given user's account, for reveal messages
-
#format_user_say(signature : String) : String
Returns a bolded signature showing which type of user sent this message.
-
#format_user_sign(id : Int64, name : String) : String
Returns a link to the given user's account.
-
#format_username_forward(name : String, username : String | Nil, msid : Int64 | Nil = nil) : String
For bots or public channels
-
#format_version : String
Returns a message containing the program version and a link to its Git repo.
- #format_warn_expiry(expiration : Time | Nil, locale : Locale) : String | Nil
-
#generate_tripcode(tripkey : String, salt : String | Nil) : Tuple(String, String)
Generate a 8chan or Secretlounge-ng style tripcode from a given string in the format
name#pass
. -
#get_arg(msg : String | Nil) : String | Nil
Returns arguments found after a command from a message text.
- #get_args(msg : String | Nil, count : Int) : Array(String) | Nil
- #get_forward_header(message : Tourmaline::Message) : String | Nil
-
#regular_forward?(text : String | Nil, entities : Array(Tourmaline::MessageEntity)) : Bool | Nil
Checks the text and entities for a forwarded message to determine if it was relayed as a regular message
-
#remove_entities(entities : Array(Tourmaline::MessageEntity), entity_types : Array(String)) : Array(Tourmaline::MessageEntity)
Strips message entities if they're found in
entity_types
-
#replace_links(text : String, entities : Array(Tourmaline::MessageEntity)) : String
Takes the URL found in an inline link and appends it to the message text.
-
#replace_network_links(text : String, linked_network : Hash(String, String)) : String
Embeds any occurence of a >>>/chat/ link with a link to that chat.
-
#strip_format(text : String, entities : Array(Tourmaline::MessageEntity), entity_types : Array(String), linked_network : Hash(String, String)) : String
Strips HTML format from a message and escapes formatting found in
MessageEntities
. - #strip_forward_header(text : String, entities : Array(Tourmaline::MessageEntity)) : String
-
#substitute_message(msg : String, locale : Locale, variables : Hash(String, String | Nil) = {"" => ""}) : String
Globally substitutes placeholders in message with the given variables
Instance Method Detail
Checks the content of the message text and determines if it should be relayed.
Returns false if the text has mathematical alphanumeric symbols, as they contain bold and italic characters.
Returns a message containing the commands the user can use.
Formats a loading bar for the /karmainfo command
Returns a bolded signature (as terveisin) showing the karma level of the user that sent this message.
Parses new MOTD for HTML formatting and returns the MOTD in HTML without the command and whitespace that follows it
Returns an empty string if no whitespace or command argument could be found.
Removes the "-100" prefix for private channels
Returns a smiley based on the number of given warnings
Formats a timestamp according to the locale settings
Formats a timespan, so the duration is marked by its largest unit ("20m", "3h", "5d", etc)
Returns a link to a given user's account, for reveal messages
Returns a bolded signature showing which type of user sent this message.
Returns a link to the given user's account.
For bots or public channels
Returns a message containing the program version and a link to its Git repo.
Feel free to edit this if you fork the code.
Generate a 8chan or Secretlounge-ng style tripcode from a given string in the format name#pass
.
Returns a named tuple containing the tripname and tripcode.
Returns arguments found after a command from a message text.
Checks the text and entities for a forwarded message to determine if it was relayed as a regular message
Returns true if the forward message was relayed regularly, nil otherwise
Strips message entities if they're found in entity_types
Takes the URL found in an inline link and appends it to the message text.
Embeds any occurence of a >>>/chat/ link with a link to that chat.
Strips HTML format from a message and escapes formatting found in MessageEntities
.
If the message has MessageEntities
, replaces any inline links and removes entities found in entity_types
.