module PrivateParlorXT::Format
Overview
A general use module for formatting text and Tourmaline::MessageEntity
Included Modules
- Tourmaline::Helpers
Extended Modules
Defined in:
private-parlor-xt/format.crInstance Method Summary
-
#allow_text?(text : String) : Bool
Checks the content of the message text and determines if it should be relayed.
-
#check_text(text : String, user : User, message : Tourmaline::Message, services : Services) : Bool
Checks the given text for invalid characters
-
#contact(contact : String | Nil, replies : Replies) : String | Nil
Format the given contact for blacklist contact replies
-
#escape_mdv2(text : String | Nil)
A simple wrapper for
Tourmaline::Helpers.escape_md
that defaults to escaping text according to Telegram's MarkdownV2 -
#flag_sign(name : String, entities : Array(Tourmaline::MessageEntity)) : Tuple(String, Array(Tourmaline::MessageEntity))
Format the flag sign header for tripcode messages when flag signs are enabled
-
#format_text(text : String, entities : Array(Tourmaline::MessageEntity), preformatted : Bool | Nil, services : Services) : Tuple(String, Array(Tourmaline::MessageEntity))
Removes formatting from the given text and entities
-
#generate_tripcode(tripkey : String, services : Services) : Tuple(String, String)
Generate a 2channel or secure 8chan style tripcode from a given string in the format
name#pass
. -
#get_arg(text : String | Nil) : String | Nil
Returns the argument following a given text, usually a command where the argument comes after the first whitespace
-
#get_args(text : String | Nil, count : Int) : Array(String) | Nil
Returns count number of args after a given text, usually a command where the command precedes the first whitespace.
-
#offset_entities(entities : Array(Tourmaline::MessageEntity), offset : Int32) : Array(Tourmaline::MessageEntity)
Add the given offset to the offset of each message entity
-
#prepend_pseudonym(text : String, entities : Array(Tourmaline::MessageEntity), user : User, message : Tourmaline::Message, services : Services) : Tuple(String | Nil, Array(Tourmaline::MessageEntity))
Prepend the user's tripcode to the message
-
#reason(reason : String | Nil, replies : Replies) : String | Nil
Format the reason for system message replies
-
#reason_log(reason : String | Nil, logs : Logs) : String | Nil
Format the reason for log messages
-
#remove_entities(entities : Array(Tourmaline::MessageEntity), strip_types : Array(String)) : Array(Tourmaline::MessageEntity)
Removes message entities if their types are found in strip_types
-
#replace_links(text : String, entities : Array(Tourmaline::MessageEntity)) : String
Replaces appends links contained in text link entities to the end of the given text
-
#reset_entities(entities : Array(Tourmaline::MessageEntity), amount : Int32) : Array(Tourmaline::MessageEntity)
Subtract the given amount from the offset of each message entity
-
#strip_format(text : String, entities : Array(Tourmaline::MessageEntity), strip_types : Array(String), linked_network : Hash(String, String)) : Tuple(String, Array(Tourmaline::MessageEntity))
Resturns text and message entities with formatting stripped, such as text_links and stripped entities, and formats network links
-
#substitute_message(msg : String, variables : Hash(String, String | Nil) = {"" => ""}) : String
Globally substitutes placeholders in message with the given variables
-
#substitute_reply(msg : String, variables : Hash(String, String | Nil) = {"" => ""}) : String
Globally substitutes placeholders in reply with the given variables Excapes placeholders according to MarkdownV2
-
#text_and_entities(message : Tourmaline::Message, user : User, services : Services) : Tuple(String | Nil, Array(Tourmaline::MessageEntity))
Gets the text and message entities from a given message
-
#time(time : Time | Nil, format : String) : String | Nil
Formats a given
Time
based on the given format -
#time_span(time : Time::Span, locale : Locale) : String
Format a time span using localized time units
-
#tripcode_sign(name : String, tripcode : String, entities : Array(Tourmaline::MessageEntity)) : Tuple(String, Array(Tourmaline::MessageEntity))
Format the tripcode header for tripcode signs
-
#update_network_links(text : String, entities : Array(Tourmaline::MessageEntity), linked_network : Hash(String, String)) : Array(Tourmaline::MessageEntity)
Returns a text link message entities corresponding to the network links in text, linking to their respective chats
-
#validate_text_and_entities(message : Tourmaline::Message, user : User, services : Services) : Tuple(String | Nil, Array(Tourmaline::MessageEntity))
Checks the text and entities from the given message for validity.
Instance Method Detail
Checks the content of the message text and determines if it should be relayed.
Returns true
if the text is empty or permitted, false
if the text has mathematical alphanumeric symbols, as they contain bold and italic characters.
Checks the given text for invalid characters
Format the given contact for blacklist contact replies
A simple wrapper for Tourmaline::Helpers.escape_md
that defaults to escaping text according to Telegram's MarkdownV2
Format the flag sign header for tripcode messages when flag signs are enabled
Removes formatting from the given text and entities
Generate a 2channel or secure 8chan style tripcode from a given string in the format name#pass
.
Returns a named tuple containing the tripname and tripcode.
Using procedures based on code by Fredrick R. Brennan and Tinyboard Development Group
8chan secure tripcode: Copyright (c) 2010-2014 Tinyboard Development Group
github.com/ctrlcctrlv/infinity/blob/1535f2c976bdc503c12b5e92e605ee665e3239e7/inc/functions.php#L2755
2channel tripcode: Copyright (c) Fredrick R. Brennan, 2020
github.com/ctrlcctrlv/tripkeys/blob/33dcb519a8c08185aecba15eee9aa80760dddc87/doc/2ch_tripcode_annotated.pl
Returns the argument following a given text, usually a command where the argument comes after the first whitespace
Returns count number of args after a given text, usually a command where the command precedes the first whitespace.
Add the given offset to the offset of each message entity
Prepend the user's tripcode to the message
Format the reason for system message replies
Format the reason for log messages
Removes message entities if their types are found in strip_types
Replaces appends links contained in text link entities to the end of the given text
Subtract the given amount from the offset of each message entity
Resturns text and message entities with formatting stripped, such as text_links and stripped entities, and formats network links
Globally substitutes placeholders in message with the given variables
Globally substitutes placeholders in reply with the given variables Excapes placeholders according to MarkdownV2
Gets the text and message entities from a given message
Formats a given Time
based on the given format
Format a time span using localized time units
Format the tripcode header for tripcode signs
Returns a text link message entities corresponding to the network links in text, linking to their respective chats
Checks the text and entities from the given message for validity.
Used for signature commands where the text should not be formatted or given a tripcode header if pseudonymous mode is enabled