class PrivateParlorXT::SpamHandler

Overview

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

Included Modules

Defined in:

private-parlor-xt/spam/spam_handler.cr

Constructors

Instance Method Summary

Constructor Detail

def self.new(ctx : YAML::ParseContext, node : YAML::Nodes::Node) #

[View source]
def self.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) #

[View source]

Instance Method Detail

def decay_amount : Int32 #

The amount at which spam scores decay


[View source]
def downvote_last_used : Hash(UserID, Time) #

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


[View source]
def expire : Nil #

Subtracts the #decay_amount from the scores of each user in #scores


[View source]
def score_animation : Int32 #

Amount added to the score for each animation


[View source]
def score_audio : Int32 #

Amount added to the score for each audio


[View source]
def score_character : Int32 #

Amount added to the score for each character in text


[View source]
def score_contact : Int32 #

Amount added to the score for each contact


[View source]
def score_document : Int32 #

Amount added to the score for each document


[View source]
def score_forwarded_message : Int32 #

Amount added to the score for each forwarded message


[View source]
def score_line : Int32 #

Amount added to the score for each line in text


[View source]
def score_location : Int32 #

Amount added to the score for each location


[View source]
def score_media_group : Int32 #

Amount added to the score for each album


[View source]
def score_photo : Int32 #

Amount added to the score for each photo


[View source]
def score_poll : Int32 #

Amount added to the score for each poll


[View source]
def score_sticker : Int32 #

Amount added to the score for each sticker


[View source]
def score_text : Int32 #

Amount added to the score for each text message


[View source]
def score_venue : Int32 #

Amount added to the score for each venue


[View source]
def score_video : Int32 #

Amount added to the score for each video


[View source]
def score_video_note : Int32 #

Amount added to the score for each video note


[View source]
def score_voice : Int32 #

Amount added to the score for each voice message


[View source]
def scores : Hash(UserID, Int32) #

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


[View source]
def sign_last_used : Hash(UserID, Time) #

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


[View source]
def spam_limit : Int32 #

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


[View source]
def spammy_album?(user : UserID) : Bool #

Returns true if the album was spammy

Returns false otherwise


[View source]
def spammy_animation?(user : UserID) : Bool #

Returns true if the animation was spammy

Returns false otherwise


[View source]
def spammy_audio?(user : UserID) : Bool #

Returns true if the audio was spammy

Returns false otherwise


[View source]
def spammy_contact?(user : UserID) : Bool #

Returns true if the contact was spammy

Returns false otherwise


[View source]
def spammy_document?(user : UserID) : Bool #

Returns true if the document was spammy

Returns false otherwise


[View source]
def 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.


[View source]
def spammy_forward?(user : UserID) : Bool #

Returns true if the forwarded message was spammy

Returns false otherwise


[View source]
def spammy_location?(user : UserID) : Bool #

Returns true if the location was spammy

Returns false otherwise


[View source]
def spammy_photo?(user : UserID) : Bool #

Returns true if the photo was spammy

Returns false otherwise


[View source]
def spammy_poll?(user : UserID) : Bool #

Returns true if the poll was spammy

Returns false otherwise


[View source]
def 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.


[View source]
def spammy_sticker?(user : UserID) : Bool #

Returns true if the sticker was spammy

Returns false otherwise


[View source]
def spammy_text?(user : UserID, text : String) : Bool #

Returns true if the text message was spammy

Returns false otherwise


[View source]
def 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.


[View source]
def spammy_venue?(user : UserID) : Bool #

Returns true if the venue was spammy

Returns false otherwise


[View source]
def spammy_video?(user : UserID) : Bool #

Returns true if the video was spammy

Returns false otherwise


[View source]
def spammy_video_note?(user : UserID) : Bool #

Returns true if the video note was spammy

Returns false otherwise


[View source]
def spammy_voice?(user : UserID) : Bool #

Returns true if the voice message was spammy

Returns false otherwise


[View source]
def upvote_last_used : Hash(UserID, Time) #

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


[View source]