class

PrivateParlorXT::SpamHandler

Inherits YAML::Serializable < Reference < Object

A module used for keeping track of the frequency of a user's message posting in order to prevent spam

Constructors

new(ctx : YAML::ParseContext, node : YAML::Nodes::Node)
Source
new(scores : Hash(UserID, Int32) = {} of UserID => Int32, sign_last_used : Hash(UserID, Time) = {} of UserID => Time, upvote_last_used : Hash(UserID, Time) = {} of UserID => Time, downvote_last_used : Hash(UserID, Time) = {} of UserID => Time, spam_limit : Int32 = 10000, decay_amount : Int32 = 1000, score_character : Int32 = 3, score_line : Int32 = 100, score_text : Int32 = 2000, score_animation : Int32 = 3000, score_audio : Int32 = 3000, score_document : Int32 = 3000, score_video : Int32 = 3000, score_video_note : Int32 = 5000, score_voice : Int32 = 5000, score_photo : Int32 = 3000, score_media_group : Int32 = 6000, score_poll : Int32 = 6000, score_forwarded_message : Int32 = 3000, score_sticker : Int32 = 3000, score_venue : Int32 = 5000, score_location : Int32 = 5000, score_contact : Int32 = 5000)
Source
new(*, __context_for_yaml_serializable ctx : YAML::ParseContext, __node_for_yaml_serializable node : YAML::Nodes::Node)
Source

Instance methods

decay_amount

The amount at which spam scores decay

Source
downvote_last_used

Returns a hash of UserID to Time, contaning the time each user last downvoted

Source
expire

Subtracts the decay_amount from the scores of each user in scores

Source
score_animation

Amount added to the score for each animation

Source
score_audio

Amount added to the score for each audio

Source
score_character

Amount added to the score for each character in text

Source
score_contact

Amount added to the score for each contact

Source
score_document

Amount added to the score for each document

Source
score_forwarded_message

Amount added to the score for each forwarded message

Source
score_line

Amount added to the score for each line in text

Source
score_location

Amount added to the score for each location

Source
score_media_group

Amount added to the score for each album

Source
score_photo

Amount added to the score for each photo

Source
score_poll

Amount added to the score for each poll

Source
score_sticker

Amount added to the score for each sticker

Source
score_text

Amount added to the score for each text message

Source
score_venue

Amount added to the score for each venue

Source
score_video

Amount added to the score for each video

Source
score_video_note

Amount added to the score for each video note

Source
score_voice

Amount added to the score for each voice message

Source
scores

Returns a hash of UserID to Int32, contaning the scores for each user

Source
sign_last_used

Returns a hash of UserID to Time, contaning the time each user last signed

Source
spam_limit

The limit for spam scores that, when hit, prevents the user from sending another message until it decays

Source
spammy_album?(user : UserID) : Bool

Returns true if the album was spammy

Returns false otherwise

Source
spammy_animation?(user : UserID) : Bool

Returns true if the animation was spammy

Returns false otherwise

Source
spammy_audio?(user : UserID) : Bool

Returns true if the audio was spammy

Returns false otherwise

Source
spammy_contact?(user : UserID) : Bool

Returns true if the contact was spammy

Returns false otherwise

Source
spammy_document?(user : UserID) : Bool

Returns true if the document was spammy

Returns false otherwise

Source
spammy_downvote?(user : UserID, interval : Int32) : Bool

Check if user has downvoted within an interval of time

Returns true if so (user is downvoting too often), false otherwise.

Source
spammy_forward?(user : UserID) : Bool

Returns true if the forwarded message was spammy

Returns false otherwise

Source
spammy_location?(user : UserID) : Bool

Returns true if the location was spammy

Returns false otherwise

Source
spammy_photo?(user : UserID) : Bool

Returns true if the photo was spammy

Returns false otherwise

Source
spammy_poll?(user : UserID) : Bool

Returns true if the poll was spammy

Returns false otherwise

Source
spammy_sign?(user : UserID, interval : Int32) : Bool

Check if user has signed within an interval of time

Returns true if so (user is sign spamming), false otherwise.

Source
spammy_sticker?(user : UserID) : Bool

Returns true if the sticker was spammy

Returns false otherwise

Source
spammy_text?(user : UserID, text : String) : Bool

Returns true if the text message was spammy

Returns false otherwise

Source
spammy_upvote?(user : UserID, interval : Int32) : Bool

Check if user has upvoted within an interval of time

Returns true if so (user is upvoting too often), false otherwise.

Source
spammy_venue?(user : UserID) : Bool

Returns true if the venue was spammy

Returns false otherwise

Source
spammy_video?(user : UserID) : Bool

Returns true if the video was spammy

Returns false otherwise

Source
spammy_video_note?(user : UserID) : Bool

Returns true if the video note was spammy

Returns false otherwise

Source
spammy_voice?(user : UserID) : Bool

Returns true if the voice message was spammy

Returns false otherwise

Source
upvote_last_used

Returns a hash of UserID to Time, contaning the time each user last upvoted

Source