abstract class PrivateParlorXT::Robot9000
- PrivateParlorXT::Robot9000
- Reference
- Object
Overview
A base class for ROBOT9000 implementations
ROBOT9000 is an algorithm by Randall Munroe designed to reduce noise in large chats and encourage original content.
ROBOT9000 will prevent users from repeating information that has already been posted before. When a user's post is considered unoriginal, the post will not be sent and the user will be cooldowned.
Subclasses of this type should use a Database
to store and query unique texts and media IDs
Direct Known Subclasses
Defined in:
private-parlor-xt/robot9000/robot9000.crInstance Method Summary
-
#add_file_id(id : String) : Nil
Stores the file id to be referenced later
-
#add_line(text : String) : Nil
Stores the stripped line of text to be referenced later
-
#allow_text?(text : String) : Bool
Returns
true
if the given text has valid codepoints or is empty -
#check_forwards? : Bool | Nil
Returns
true
if this module should check forwards for uniqueness -
#check_media? : Bool | Nil
Returns
true
if this module should check media (photos, audio, videos, etc.) for uniqueness -
#check_text? : Bool | Nil
Returns
true
if this module should check text for uniqueness -
#cooldown : Int32
Returns the cooldown duration for unoriginal messages
-
#media_file_id(message : Tourmaline::Message) : String | Nil
Returns a
String
containing the unique file ID from the given message -
#remove_links(text : String, entities : Array(Tourmaline::MessageEntity)) : String
Returns a
String
containing the given text with URLs removed -
#strip_text(text : String, entities : Array(Tourmaline::MessageEntity)) : String
Returns a
String
containing the given text in lower case with the following elements removed: - Links/URLS - Commands - Usernames - Sequences of 3 or more repeating characters (digits can repeat) - Network links/Back links (i.e., ">>>/foo/") - Punctuation and the em-dash - Repeating spaces and newlines - Trailing and leading whitespace -
#unique_media(user : User, message : Tourmaline::Message, services : Services, file_id : String) : String | Nil
Returns the file_id if the message's media is unique
-
#unique_message?(user : User, message : Tourmaline::Message, services : Services, text : String | Nil = nil) : Bool
Checks the message for uniqueness and returns
true
if: - Message is preformatted (message already checked) - Message is a forward, but thisRobot9000
is not configured to check forwards for uniqueness - No media file ID could be found when checking message media - Message is unique -
#unique_text(user : User, message : Tourmaline::Message, services : Services, text : String) : String | Nil
Returns the text if the message's text or caption is unique
-
#unoriginal_media?(id : String) : Bool | Nil
Returns
true
if the given file id has been sent before Returnsfalse
otherwise -
#unoriginal_message(user : User, message : Tourmaline::Message, services : Services) : Nil
Queues a message telling the user that the message was unoriginal, and cooldowns the user if configured to do so
-
#unoriginal_text?(text : String) : Bool | Nil
Returns
true
if the given text has been sent before Returnsfalse
otherwise -
#warn_user? : Bool | Nil
Returns
true
if this module should give the user a warning for unoriginal messages
Instance Method Detail
Stores the stripped line of text to be referenced later
Returns true
if the given text has valid codepoints or is empty
Returns false
if any character/codepoint in the given text is not found in valid_codepoints
Returns true
if this module should check forwards for uniqueness
If true, this module should also check for unique text or media if check_text
or check_media
is toggled, respectively.
Returns false
otherwise
Returns true
if this module should check media (photos, audio, videos, etc.) for uniqueness
Returns false
otherwise
Returns true
if this module should check text for uniqueness
Returns false
otherwise
Returns a String
containing the unique file ID from the given message
Returns a String
containing the given text with URLs removed
Returns a String
containing the given text in lower case with the following elements removed:
- Links/URLS
- Commands
- Usernames
- Sequences of 3 or more repeating characters (digits can repeat)
- Network links/Back links (i.e., ">>>/foo/")
- Punctuation and the em-dash
- Repeating spaces and newlines
- Trailing and leading whitespace
Returns the file_id if the message's media is unique
Returns nil
if the message's media is not unique, and cooldowns the sender if configured to do so
Checks the message for uniqueness and returns true
if:
- Message is preformatted (message already checked)
- Message is a forward, but this
Robot9000
is not configured to check forwards for uniqueness - No media file ID could be found when checking message media
- Message is unique
Returns false
if the message does not pass the text_check
or the media_check
; message is unoriginal
The unique text and/or file_id will be stored to flag future messages of the same kind as unoriginal
Returns the text if the message's text or caption is unique
Returns nil
if the message's text or caption is not unique, and cooldowns the sender if configured to do so
Returns true
if the given file id has been sent before
Returns false
otherwise
Queues a message telling the user that the message was unoriginal, and cooldowns the user if configured to do so
Returns true
if the given text has been sent before
Returns false
otherwise
Returns true
if this module should give the user a warning for unoriginal messages
If true, the unoriginal message cooldown should scale with user warnings
Returns false
otherwise