spotted.scripts namespace
Submodules
spotted.scripts.f_crypto module
spotted.scripts.run_sql module
- class spotted.scripts.run_sql.Config[source]
Bases:
objectConfigurations
- AUTOREPLIES_PATH = 'autoreplies.yaml'
- DEFAULT_AUTOREPLIES_PATH = '/opt/hostedtoolcache/Python/3.14.3/x64/lib/python3.14/site-packages/spotted/config/yaml/autoreplies.yaml'
- DEFAULT_SETTINGS_PATH = '/opt/hostedtoolcache/Python/3.14.3/x64/lib/python3.14/site-packages/spotted/config/yaml/settings.yaml'
- SETTINGS_PATH = 'settings.yaml'
- classmethod autoreplies_get(*keys, default=None)[source]
Get the value of the specified key in the autoreplies configuration dictionary. If the key is a tuple, it will return the value of the nested key. If the key is not present, it will return the default value.
- classmethod debug_get(key, default=None)[source]
Get the value of the specified key in the configuration under the ‘debug’ section. If the key is not present, it will return the default value.
- Parameters:
- Returns:
Any– value of the key or default value
- classmethod override_settings(config)[source]
Overrides the settings with the configuration provided in the config dict.
- Parameters:
config (
dict) – configuration dict used to override the current settings
- classmethod post_get(key, default=None)[source]
Get the value of the specified key in the configuration under the ‘post’ section. If the key is not present, it will return the default value.
- Parameters:
key (
Literal['community_group_id','channel_id','channel_tag','comments','admin_group_id','n_votes','remove_after_h','report','report_wait_mins','replace_anonymous_comments','delete_anonymous_comments','blacklist_messages','max_n_warns','warn_expiration_days','mute_default_duration_days','autoreplies_per_page','reject_after_autoreply']) – key to getdefault (
Any, default:None) – default value to return if the key is not present
- Returns:
Any– value of the key or default value
- classmethod reload(force_reload=False)[source]
Reset the configuration. The next time a setting parameter is required, the whole configuration will be reloaded. If force_reload is True, the configuration will be reloaded immediately.
- Parameters:
force_reload (
bool, default:False) – if True, the configuration will be reloaded immediately
- class spotted.scripts.run_sql.DbManager[source]
Bases:
objectClass that handles the management of databases
- classmethod count_from(table_name, select='*', where='', where_args=None)[source]
Returns the number of rows found with the query. Executes “SELECT COUNT(select) FROM table_name [WHERE where (with where_args)]”
- Parameters:
- Returns:
int– number of rows
- classmethod delete_from(table_name, where='', where_args=None)[source]
Deletes the rows from the specified table, where the condition, when set, is satisfied. Executes “DELETE FROM table_name [WHERE where (with where_args)]”
- classmethod get_db()[source]
Creates the connection to the database. It can be sqlite or postgres
- Returns:
tuple[Connection,Cursor] – sqlite database connection and cursor
- classmethod insert_into(table_name, values, columns='', multiple_rows=False)[source]
Inserts the specified values in the database. Executes “INSERT INTO table_name ([columns]) VALUES (placeholders)”
- Parameters:
table_name (
str) – name of the table used in the INSERT INTOvalues (
tuple) – values to be inserted. If multiple_rows is true, tuple of tuples of values to be insertedcolumns (
tuple|str, default:'') – columns that will be inserted, as a tuple of stringsmultiple_rows (
bool, default:False) – whether or not multiple rows will be inserted at the same time
- classmethod query_from_file(*file_path)[source]
Commits all the queries in the specified file. The queries must be separated by a —– string Should not be used to select something
- Parameters:
file_path (
str) – path of the text file containing the queries
- classmethod query_from_string(*queries)[source]
Commits all the queries in the string Should not be used to select something
- Parameters:
queries (
str) – tuple of queries
- static register_adapters_and_converters()[source]
Registers the adapter and converters for the datetime type. Needed from python 3.12 onwards, as the default option has been deprecated
- classmethod select_from(table_name, select='*', where='', where_args=None, group_by='', order_by='')[source]
Returns the results of a query. Executes “SELECT select FROM table_name [WHERE where (with where_args)] [GROUP_BY group_by] [ORDER BY order_by]”
- Parameters:
table_name (
str) – name of the table used in the FROMselect (
str, default:'*') – columns considered for the querywhere (
str, default:'') – where clause, with %s placeholders for the where_argswhere_args (
tuple|None, default:None) – args used in the where clausegroup_by (
str, default:'') – group by clauseorder_by (
str, default:'') – order by clause
- Returns:
list– rows from the select
- classmethod update_from(table_name, set_clause, where='', args=None)[source]
Updates the rows from the specified table, where the condition, when set, is satisfied. Executes “UPDATE table_name SET set_clause (with args) [WHERE where (with args)]”
- Parameters:
table_name (
str) – name of the table used in the DELETE FROMset_clause (
str) – set clause, with %s placeholderswhere (
str, default:'') – where clause, with %s placeholders for the where argsargs (
tuple|None, default:None) – args used both in the set clause and in the where clause, in this order