ecasbot  1.3.1
EC AntiSpam bot for Telegram messenger
ecasbot.settings.Settings Class Reference

Public Member Functions

None __init__ (self, schid)
 
None add_stopword (self, str stopword)
 
None add_watch (self, int userid, int chatid)
 
list admins (self)
 
int bantime (self)
 
str chkrgx (self)
 
int fmterr (self)
 
int fmtlog (self)
 
str get_cfgpath (self)
 
list get_watchers (self, int chatid)
 
None load (self)
 
str logtofile (self)
 
int maxemoji (self)
 
int maxname (self)
 
int msggoal (self)
 
int nickgoal (self)
 
None remove_stopword (self, str stopword)
 
None remove_watch (self, int userid, int chatid)
 
list restent (self)
 
list restricted_languages (self)
 
None save (self)
 
list stopwords (self)
 
str stwrgx (self)
 
str tgkey (self)
 
str urlrgx (self)
 
list watches (self)
 

Static Public Member Functions

int get_logging_level ()
 

Private Member Functions

bool __check_schema (self, schid)
 
def __check_watchers (self, int chatid)
 
None __find_cfgfile (self)
 

Private Attributes

 __appname
 
 __cfgfile
 
 __data
 

Constructor & Destructor Documentation

◆ __init__()

None ecasbot.settings.Settings.__init__ (   self,
  schid 
)
Main constructor of Settings class.
:param schid: Required schema version.

Member Function Documentation

◆ __check_schema()

bool ecasbot.settings.Settings.__check_schema (   self,
  schid 
)
private
Check JSON config schema version.
:param schid: New schema version.
:return: True if equal.

◆ __check_watchers()

def ecasbot.settings.Settings.__check_watchers (   self,
int  chatid 
)
private
Check if specified chat ID listed in watch list.
:param chatid: Chat ID.
:return: Generator object.

◆ __find_cfgfile()

None ecasbot.settings.Settings.__find_cfgfile (   self)
private
Get fully-qualified path to main configuration file.

◆ add_stopword()

None ecasbot.settings.Settings.add_stopword (   self,
str  stopword 
)
Add a new stopword to the list of restricted words.
:param stopword: Restricted word to add.

◆ add_watch()

None ecasbot.settings.Settings.add_watch (   self,
int  userid,
int  chatid 
)
Add new watch for reports feature.
:param userid: User ID.
:param chatid: Chat ID.

◆ admins()

list ecasbot.settings.Settings.admins (   self)
Get bot admins list. This users can execute any bot command and even
control supergroups using special bot actions.
:return: Bot admins list.

◆ bantime()

int ecasbot.settings.Settings.bantime (   self)
Get user ban time (in seconds). Bot will restrict new users for
this time.
:return: Restriction time.

◆ chkrgx()

str ecasbot.settings.Settings.chkrgx (   self)
Get regular expression for checking user names on joining supergroups.
:return: Regex for user names checking.

◆ fmterr()

int ecasbot.settings.Settings.fmterr (   self)
Get custom formatter for stderr (journald) logs.
:return: Custom formatter for stderr logs.

◆ fmtlog()

int ecasbot.settings.Settings.fmtlog (   self)
Get custom formatter for file logs.
:return: Custom formatter for text logs.

◆ get_cfgpath()

str ecasbot.settings.Settings.get_cfgpath (   self)
Get directory where bot's configuration are stored.
User can override this setting by exporting CFGPATH
environment option.
:return: Full directory path.

◆ get_logging_level()

int ecasbot.settings.Settings.get_logging_level ( )
static
Get current log level. User can override this setting by exporting
LOGLEVEL environment option.
:return:

◆ get_watchers()

list ecasbot.settings.Settings.get_watchers (   self,
int  chatid 
)
Get watchers of specified chat.
:param chatid: Chat ID.
:return: List of watchers.

◆ load()

None ecasbot.settings.Settings.load (   self)
Load settings from JSON file.

◆ logtofile()

str ecasbot.settings.Settings.logtofile (   self)
Get log file name. If not set or empty, stderr will be used.
:return: Log file name.

◆ maxemoji()

int ecasbot.settings.Settings.maxemoji (   self)
Get maximum allowed emoji count in messages of new users. Bot
will remove messages exceeding this limit.
:return: Maximum emoji count in messages.

◆ maxname()

int ecasbot.settings.Settings.maxname (   self)
Get maximum allowed length of name. Bot will score users with
very long names.
:return: Maximum username length.

◆ msggoal()

int ecasbot.settings.Settings.msggoal (   self)
Get number of score points after message checks required to
delete it.
:return: Maximum score points required.

◆ nickgoal()

int ecasbot.settings.Settings.nickgoal (   self)
Get number of score points after nickname checks required to
block new joined user.
:return: Maximum score points required.

◆ remove_stopword()

None ecasbot.settings.Settings.remove_stopword (   self,
str  stopword 
)
Remove stopword from the list of restricted words.
:param stopword: Restricted word to remove.

◆ remove_watch()

None ecasbot.settings.Settings.remove_watch (   self,
int  userid,
int  chatid 
)
Add watch for reports feature.
:param userid: User ID.
:param chatid: Chat ID.

◆ restent()

list ecasbot.settings.Settings.restent (   self)
Get list of forbidden entitles for new users. Bot will remove any
messages from restricted users contains any of it.
:return: List of forbidden entitles.

◆ restricted_languages()

list ecasbot.settings.Settings.restricted_languages (   self)
Get list of restricted languages.
:return: Blocked langs list.

◆ save()

None ecasbot.settings.Settings.save (   self)
Save current settings to JSON file.

◆ stopwords()

list ecasbot.settings.Settings.stopwords (   self)
Get list of forbidden words in nicknames of new users. Bot will
score such users.
:return: List of forbidden words in user names.

◆ stwrgx()

str ecasbot.settings.Settings.stwrgx (   self)
Get regular expression for checking forbidden words in nicknames
or new messages.
:return: Regex with forbidden words.

◆ tgkey()

str ecasbot.settings.Settings.tgkey (   self)
Get Telegram Bot API token.
:return: Bot API token.

◆ urlrgx()

str ecasbot.settings.Settings.urlrgx (   self)
Get regular expression for checking if string contains any URLs.
:return: Regex for URL checking.

◆ watches()

list ecasbot.settings.Settings.watches (   self)
Get watch list for reports feature.
:return: Watch list.