class

PrivateParlorXT::Robot9000

Inherits Reference < Object

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

Instance methods

add_file_id(id : String) : Nil

Stores the file id to be referenced later

Source
add_line(text : String) : Nil

Stores the stripped line of text to be referenced later

Source
allow_text?(text : String) : Bool

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

Source
check_forwards?

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

Source
check_media?

Returns true if this module should check media (photos, audio, videos, etc.) for uniqueness

Returns false otherwise

Source
check_text?

Returns true if this module should check text for uniqueness

Returns false otherwise

Source
cooldown

Returns the cooldown duration for unoriginal messages

Source
media_file_id(message : Tourmaline::Message) : String | Nil

Returns a String containing the unique file ID from the given message

Source
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
Source
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

Returns nil if the message's media is not unique, and cooldowns the sender if configured to do so

Source
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 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

Source
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

Returns nil if the message's text or caption is not unique, and cooldowns the sender if configured to do so

Source
unoriginal_media?(id : String) : Bool | Nil

Returns true if the given file id has been sent before Returns false otherwise

Source
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

Source
unoriginal_text?(text : String) : Bool | Nil

Returns true if the given text has been sent before Returns false otherwise

Source
warn_user?

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

Source