furmeet-bot/webproj/bot/forms.py
2020-07-11 00:46:39 -03:00

78 lines
3.7 KiB
Python

from . import models
from django.forms import ModelForm
class AntiSpam(ModelForm):
class Meta:
model = models.GroupPreferences
fields = ['combot_anti_spam_use',
'combot_anti_spam_notification',
]
labels = {
'combot_anti_spam_use': 'Use Combot Anti-Spam System (CAS)',
'combot_anti_spam_notification': 'Send message mentioning that a spammer was banned',
}
help_texts = {
'combot_anti_spam_use': 'By doing so, you understand that you will have to comply with their conditions.',
'combot_anti_spam_notification': 'Leave it empty to disable. Use {NAME} to display the known spammer\'s name instead; {GROUP} will be replaced for group\'s name.',
}
error_messages = {
'combot_anti_spam_notification': {
'max_length': "This notification is too long.",
},
}
class CAPTCHA(ModelForm):
class Meta:
model = models.GroupPreferences
fields = ['captcha_use',
'captcha_chars',
'captcha_digits',
'captcha_timeout',
'captcha_attempts',
'captcha_first_message',
'captcha_retry_message',
'captcha_leave_mess',
]
labels = {
'captcha_use': 'Use CAPTCHA on new members',
'captcha_chars': 'Characters that will be used in the CAPTCHA',
'captcha_digits': 'Length (in digits) of your CAPTCHA',
'captcha_timeout': 'Maximum time (in seconds) to wait for someone to solve the CAPTCHA before kicking',
'captcha_attempts': 'Maximum error count before kicking',
'captcha_first_message': 'First CAPTCHA message, shown upon arrival',
'captcha_retry_message': 'CAPTCHA messages, shown after mistaken attempts',
'captcha_leave_mess': 'Do not erase CAPTCHAS and attempts',
}
help_texts = {
'captcha_timeout': 'Failed attempts do not reset such timmer',
'captcha_chars': 'Make sure all characters are distinct, such as lowercase "L", uppercase "i" and the number "1", and "oO0" (2 vowels, 1 number)',
'captcha_first_message': '{NAME} will be replaced for user\'s name; {GROUP} will be replaced for group\'s name; {ATTEMPTS} will be replaced for the number of attempts the user has; {TIMEOUT} will be replaced for amount of seconds an user has to solve the CAPTCHA; up to 1000 characters',
'captcha_retry_message': '{NAME} will be replaced for user\'s name; {GROUP} will be replaced for group\'s name; {ATTEMPTS} will be replaced for the number of remaining attempts the user has; {TIMEOUT} will be replaced for amount of seconds left an user has to solve the CAPTCHA; up to 1000 characters',
'captcha_leave_mess': 'Might be spammy if checked',
}
class Greetings(ModelForm):
class Meta:
model = models.GroupPreferences
fields = ['join_message',
'leave_message',
]
help_texts = {
'join_message': 'Leave blank to disable this feature; {NAME} will be replaced for user\'s name; {GROUP} will be replaced for group\'s name; will be delayed until Anti-Spam and CAPTCHA steps gets either completed or skipped',
'leave_message': 'Leave blank to disable this feature; {NAME} will be replaced for user\'s name; {GROUP} will be replaced for group\'s name',
}
class CannedMessage(ModelForm):
class Meta:
model = models.GroupCannedMessage
fields = ['listen',
'reply_with',
]
help_texts = {
'listen': 'Matches any part in a a larger message',
}