class PrivateParlorXT::SpamHandler
- PrivateParlorXT::SpamHandler
- Reference
- Object
Overview
A module used for keeping track of the frequency of a user's message posting in order to prevent spam
Included Modules
- YAML::Serializable
Defined in:
private-parlor-xt/spam/spam_handler.crConstructors
- .new(ctx : YAML::ParseContext, node : YAML::Nodes::Node)
- .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)
Instance Method Summary
-
#decay_amount : Int32
The amount at which spam scores decay
-
#downvote_last_used : Hash(UserID, Time)
Returns a hash of
UserID
toTime
, contaning the time each user last downvoted -
#expire : Nil
Subtracts the
#decay_amount
from the scores of each user in#scores
-
#score_animation : Int32
Amount added to the score for each animation
-
#score_audio : Int32
Amount added to the score for each audio
-
#score_character : Int32
Amount added to the score for each character in text
-
#score_contact : Int32
Amount added to the score for each contact
-
#score_document : Int32
Amount added to the score for each document
-
#score_forwarded_message : Int32
Amount added to the score for each forwarded message
-
#score_line : Int32
Amount added to the score for each line in text
-
#score_location : Int32
Amount added to the score for each location
-
#score_media_group : Int32
Amount added to the score for each album
-
#score_photo : Int32
Amount added to the score for each photo
-
#score_poll : Int32
Amount added to the score for each poll
-
#score_sticker : Int32
Amount added to the score for each sticker
-
#score_text : Int32
Amount added to the score for each text message
-
#score_venue : Int32
Amount added to the score for each venue
-
#score_video : Int32
Amount added to the score for each video
-
#score_video_note : Int32
Amount added to the score for each video note
-
#score_voice : Int32
Amount added to the score for each voice message
-
#scores : Hash(UserID, Int32)
Returns a hash of
UserID
toInt32
, contaning the scores for each user -
#sign_last_used : Hash(UserID, Time)
Returns a hash of
UserID
toTime
, contaning the time each user last signed -
#spam_limit : Int32
The limit for spam scores that, when hit, prevents the user from sending another message until it decays
-
#spammy_album?(user : UserID) : Bool
Returns
true
if the album was spammy -
#spammy_animation?(user : UserID) : Bool
Returns
true
if the animation was spammy -
#spammy_audio?(user : UserID) : Bool
Returns
true
if the audio was spammy -
#spammy_contact?(user : UserID) : Bool
Returns
true
if the contact was spammy -
#spammy_document?(user : UserID) : Bool
Returns
true
if the document was spammy -
#spammy_downvote?(user : UserID, interval : Int32) : Bool
Check if user has downvoted within an interval of time
-
#spammy_forward?(user : UserID) : Bool
Returns
true
if the forwarded message was spammy -
#spammy_location?(user : UserID) : Bool
Returns
true
if the location was spammy -
#spammy_photo?(user : UserID) : Bool
Returns
true
if the photo was spammy -
#spammy_poll?(user : UserID) : Bool
Returns
true
if the poll was spammy -
#spammy_sign?(user : UserID, interval : Int32) : Bool
Check if user has signed within an interval of time
-
#spammy_sticker?(user : UserID) : Bool
Returns
true
if the sticker was spammy -
#spammy_text?(user : UserID, text : String) : Bool
Returns
true
if the text message was spammy -
#spammy_upvote?(user : UserID, interval : Int32) : Bool
Check if user has upvoted within an interval of time
-
#spammy_venue?(user : UserID) : Bool
Returns
true
if the venue was spammy -
#spammy_video?(user : UserID) : Bool
Returns
true
if the video was spammy -
#spammy_video_note?(user : UserID) : Bool
Returns
true
if the video note was spammy -
#spammy_voice?(user : UserID) : Bool
Returns
true
if the voice message was spammy -
#upvote_last_used : Hash(UserID, Time)
Returns a hash of
UserID
toTime
, contaning the time each user last upvoted
Constructor Detail
Instance Method Detail
Returns a hash of UserID
to Time
, contaning the time each user last downvoted
Returns a hash of UserID
to Int32
, contaning the scores for each user
Returns a hash of UserID
to Time
, contaning the time each user last signed
The limit for spam scores that, when hit, prevents the user from sending another message until it decays
Returns true
if the album was spammy
Returns false
otherwise
Returns true
if the animation was spammy
Returns false
otherwise
Returns true
if the audio was spammy
Returns false
otherwise
Returns true
if the contact was spammy
Returns false
otherwise
Returns true
if the document was spammy
Returns false
otherwise
Check if user has downvoted within an interval of time
Returns true if so (user is downvoting too often), false otherwise.
Returns true
if the forwarded message was spammy
Returns false
otherwise
Returns true
if the location was spammy
Returns false
otherwise
Returns true
if the photo was spammy
Returns false
otherwise
Returns true
if the poll was spammy
Returns false
otherwise
Check if user has signed within an interval of time
Returns true if so (user is sign spamming), false otherwise.
Returns true
if the sticker was spammy
Returns false
otherwise
Returns true
if the text message was spammy
Returns false
otherwise
Check if user has upvoted within an interval of time
Returns true if so (user is upvoting too often), false otherwise.
Returns true
if the venue was spammy
Returns false
otherwise
Returns true
if the video was spammy
Returns false
otherwise
Returns true
if the video note was spammy
Returns false
otherwise
Returns true
if the voice message was spammy
Returns false
otherwise
Returns a hash of UserID
to Time
, contaning the time each user last upvoted