Implements core logic stored in "logic.txt" file. More...
#include <string>
#include <vector>
#include <stack>
#include <list>
#include <map>
#include "utils/memleak.h"
#include "utils/my_assert.h"
#include "utils.h"
#include "params.h"
#include "function.h"
#include "proc/c_lines.h"
#include "logic/c_smtp.h"
#include "logic/c_channel_def.h"
#include "logic/c_private.h"
#include "irc/c_flood.h"
#include "logic/c_user.h"
#include "logic/c_channel.h"
#include "proc/c_procedure.h"
Go to the source code of this file.
Defines | |
#define | LOGIC_NO_SERVER -7 |
No irc server in the list. | |
#define | LOGIC_OK 0 |
Ok, no error. | |
#define | LOGIC_PROC_BAD_NUM -3 |
Bad number. | |
#define | LOGIC_PROC_BAD_SYNTAX -4 |
Bad syntax. | |
#define | LOGIC_PROC_BAD_TEXT -2 |
Bad text. | |
#define | LOGIC_PROC_NOT_FOUND -1 |
Procedure not found. | |
#define | LOGIC_RESTART -6 |
Bot wants to be restarted ("restart" command). | |
#define | LOGIC_SOCKET_ERROR -5 |
Socket I/O error. | |
Functions | |
bool | logic_access_to_filesystem (const string &user) |
Check wheter user has access to the filesystem. | |
bool | logic_access_to_partyline (const string &nick, const string &ident, const string &host, const string &fullname, const bool irc_op, string &user_name_as_in_logic) |
Looks up and find user as specified in logic.txt, and checks if user has access to partyline. | |
bool | logic_access_to_partyline (const string &user_name_as_in_logic) |
Checks wheter user (as known in logic.txt) has access to partyline. | |
void | logic_botnet_backup (string who) |
Writes new "logic.txt" file. | |
bool | logic_botnet_get_channel_def (const string &channel_name, c_channel_def &chd) |
Gets channel definition. | |
bool | logic_botnet_get_func (string name, c_function &func) |
Gets function. | |
bool | logic_botnet_get_proc (string name, c_procedure &proc) |
Gets procedure. | |
bool | logic_botnet_get_user (const string &name, c_user &user) |
Gets user definition. | |
bool | logic_botnet_get_user_channels (const string &name, vector< c_channel > &channels) |
Gets channels that user has defined properties to. | |
void | logic_botnet_rehash (string who) |
Rehashes new backed up configuration (should be called from BOTNET) and performs rollback to old backed up file(s) if parse error occurs. | |
void | logic_botnet_remove_channel_def (const string &channel_name) |
Removes channel definition. | |
void | logic_botnet_remove_user (const string &username) |
Removes user. | |
int | logic_call_proc (const char *call_string) |
bool | logic_check_mask (string mask1, string mask2, const string &fnm1, const string &fnm2, bool &was_dns) |
Checks mask to match (advanced with DNS resolution). | |
bool | logic_check_num_agrs (string proc, const size_t mandatory) |
Checks number of arguments in call string. | |
string | logic_eval (c_module *this_module, const string &str, c_var_array *vars, const string &debug) |
Looks up and evalueates variable beginning with '$' sign, if it is possible. | |
void | logic_filesys_got_new (const string &user_name, const string &nick, const string &ident, const string &host, const string &internal_name) |
Executes on_filesys_got_new event. | |
string | logic_find_proc_by_name (const string &name) |
Finds procedure by name (without declatarion). | |
string | logic_find_user (const string &nick, const string &ident, const string &host, const string &fullname, bool irc_op) |
Looks up and find user as specified in logic.txt. | |
string | logic_find_user (const string &nick, const string &ident, string host, const string &fullname, bool irc_op, bool &was_dns) |
Looks up and find user as specified in logic.txt. | |
void | logic_fnc (const string &old_nick, const string &new_nick) |
Executes on_fnc event. | |
string | logic_get_dcc_host (const int dcc_group, const string &user_name_as_in_logic) |
Retrieves host for DCC by DCC gorup and user's name. | |
void | logic_get_flood_limits (const string &channel, const string &user, c_flood &msg_flood, c_flood ¬ice_flood, c_flood &repeat_flood, c_flood &nick_flood, c_flood &join_flood, c_flood &mode_flood, c_flood &ctcp_flood) |
Retrieves flood limits. | |
string | logic_get_host_bot_user_name () |
Gets name of user marked as "host_bot". | |
int | logic_get_priority (const string &class_) |
void | logic_get_pull_chan_defs (const string &botname, vector< c_channel_def > &chans) |
Gets channel definition list to pull. | |
void | logic_get_pull_users (const string &botname, deque< c_user > &users) |
Gets user list to pull. | |
void | logic_get_push_chan_defs (const string &botname, vector< c_channel_def > &chans) |
Gets channel definition list to push. | |
void | logic_get_push_funcs (const string &botname, vector< c_function * > &funcs) |
Gets function list to push. | |
void | logic_get_push_procs (const string &botname, vector< c_procedure > &procs) |
Gets procedure list to push. | |
void | logic_get_push_users (const string &botname, deque< c_user > &users) |
Gets user list to push. | |
bool | logic_is_replication_partner (const string &user_name_as_in_logic) |
Checks wheter user (the bot) is replication partner. | |
void | logic_list_func (string func_name, list< string > &commands, string &declaration, vector< string > &groups, vector< c_replication > &replications, vector< string > &remote_call) |
Lists functions's commands. | |
void | logic_list_proc (string proc_name, list< string > &commands, string &declaration, vector< string > &groups, vector< c_replication > &replications, vector< string > &remote_call) |
Lists procedure's commands. | |
void | logic_loop () |
This should be called in a loop. Executes timers and processes script output with freeing resources. | |
void | logic_loop_identd () |
Checks for IDENT connection (should be called in a loop). | |
void | logic_on_banned (const string &channel, const string &ban_mask, const vector< string > &excepts, const vector< string > &invites, const vector< string > &bans) |
Executes on_banned event (called when bot JOINs the channel and finds out that some user is banned by ban mask) also checks whether user is not +e excepted or +I invited, which overrides the ban mask. | |
void | logic_on_broadcast (string username, const string &nick, const string &ident, const string &host, const string &bcast_mask, const int type, string msg, const string &server, const unsigned short port) |
Raises on_broadcast event. | |
void | logic_on_flood (const string &channel, const string &user, const string &nick, const int type, const int stat_num, const my_time_t stat_sec, const my_time_t stat_sec_of, const vector< string > &flist) |
Executes on_flood event procedure. | |
void | logic_on_internal_event (string type, string flags1, string flags2, string flags3, string flags4, const int severity_numeric, string msg1, string msg2) |
Raises on_intenal_event event. | |
void | logic_on_ircop (const string &channel, const string &nick, const bool on) |
Executes procedure for event on_ircop (when an IRC operator joins / is on after bot's join / left channel). | |
void | logic_on_join (const string &nick, const string &ident, const string &host, const string &fullname, const string &channel, const bool irc_op) |
Executes on_join event (called when someone JOINs the channel). | |
void | logic_on_nick_change (const string &nick, const string &ident, const string &host, const string &fullname, const string &channel, const bool irc_op, const string &old_nick) |
Validates new nick. | |
void | logic_on_nick_validate (const string &nick, const string &ident, const string &host, const string &fullname, const string &channel, const bool irc_op, const bool passive, bool &mod_disp_join_called) |
Validates user after bot has joined / got +o (op) / rehashed. | |
void | logic_on_not_in_reop (const string &channel, const string &mask, const string &user_name) |
Executes on_not_in_reop event (called when bot JOINs the channel and finds out that some user is not in reop list by +R). | |
void | logic_on_not_invited (const string &channel, const string &mask, const string &user_name) |
Executes on_not_invited event (called when bot JOINs the channel and finds out that some user is not invited by +I). | |
void | logic_on_notice (const string &channel, string user, const string &nick, const string &msg) |
Executes on_notice event procedure. | |
void | logic_on_part (const string &channel, const string &nick, const string &msg, const int type) |
Executes on_part event procedure. | |
void | logic_on_privmsg (const string &channel, string user, const string &nick, string msg) |
Executes on_privmsg event procedure. | |
void | logic_on_privmsg_query (string user, const string &nick, string msg) |
Executes on_privmsg event procedure (for query only - not channel). | |
void | logic_on_server_msg (const string &channel, const string &source, const int type, const string &msg, const string &server, const unsigned short port) |
Raises on_server_msg event. | |
bool | logic_parse_func (string &error_reason, int &error_line, list< string > &commands, bool copy_to_r_procedures, string declaration, vector< string > &groups, vector< c_replication > &replications, vector< string > &remote_call) |
Parses and compiles function (for partyline). | |
void | logic_parse_proc (string &error_reason, int &error_line, list< string > &commands, bool copy_to_r_procedures, string declaration, vector< string > &groups, vector< c_replication > &replications, vector< string > &remote_call) |
Parses and compiles procedure (for partyline). | |
void | logic_partyline_access (const string &user, vector< string > &access_to_users, vector< string > &access_to_groups, vector< string > &access_grant_groups, vector< string > &access_to_proc_groups, vector< string > &access_grant_proc_groups, vector< string > &access_grant_proc, vector< string > &access_to_channel, vector< string > &access_grant_channel, bool &access_grant_partyline, vector< string > &access_to_procs, bool &access_to_backup, bool &access_grant_backup, bool &access_to_rehash, bool &access_grant_rehash, bool &access_to_plususer, bool &access_grant_plususer, bool &access_to_plusproc, bool &access_grant_plusproc, c_flood &partyline_msg_flood, bool &access_to_replication, bool &access_grant_replication, vector< string > &access_to_chan_defs, bool &access_to_restart, bool &access_grant_restart, bool &access_to_die, bool &access_grant_die, bool &access_to_filesystem, bool &access_grant_filesystem, bool &access_to_private, bool &access_grant_private, bool &access_to_can_send_all_users, bool &access_grant_can_send_all_users, bool &access_to_can_send_unknown_users, bool &access_grant_can_send_unknown_users, vector< string > &access_usage_proc, vector< string > &access_usage_proc_groups, bool &access_to_upgrade, bool &access_grant_upgrade, bool &access_to_apply, bool &access_grant_apply, vector< string > &access_to_users_also_terminators) |
Retrieves access rights of user on partyline. | |
bool | logic_partyline_add_channel_def (c_channel_def &chd) |
Adds a channel definition. | |
void | logic_partyline_add_user (c_user &user, vector< c_channel > &channels) |
Adds an user with channels definition. | |
void | logic_partyline_backup (c_module *this_module, string who) |
Forces to writes all object to logic.txt file. | |
string | logic_partyline_get_chandef_listing (string ch, const string &lang, const string &eol, vector< string > &access_to_channel) |
Returns string with channel definition properties (for partyline). | |
bool | logic_partyline_get_channel_def (const string &channel_name, c_channel_def &chd) |
Gets channel definition. | |
void | logic_partyline_get_channels (vector< string > &channels) |
Retrieves list of known channels (channel must reflect at least one time in logic.txt). | |
void | logic_partyline_get_user (const string &user_name, c_user &user, vector< c_channel > &channels) |
Retrieves an user with channels. | |
void | logic_partyline_get_user_template (const string &user_name, c_user &user, vector< c_channel > &channels) |
Retrieves an user template with channels. | |
void | logic_partyline_plus_group (const string &username, const string &group) |
Adds privileges to user for new group (".+group" command). | |
string | logic_partyline_rehash (const string &lang, const string &eol, const string &who) |
Rehashes new backed up configuration (should be called from DCC / telnet) and performs rollback to old backed up file(s) if parse error occurs. | |
void | logic_partyline_remove_channel_def (const string &channel_name) |
Deletes channel definition. | |
void | logic_partyline_remove_user (const string &username) |
Removes user or user template defined in logic.txt. | |
bool | logic_partyline_user_exists (string name) |
Checks if such user defined in logic.txt exists. | |
int | logic_partyline_whois (const string &lang, string param1, list< string > &lines) |
Retrieves full whois list for users of mask param1 (".whois" command on partyline). | |
bool | logic_process_line (c_module *this_module, string ln, string &error_reason, int &error_line, bool &b_user2, c_user &user, bool &b_channel, c_channel &channel, bool &b_user, int &i_brackets, bool &b_proc, c_procedure &procedure, deque< c_lines > &lines, bool &b_smtp, c_smtp &smtp, bool &b_smtp_data, vector< c_procedure > &procedures, deque< c_user > &users, vector< c_channel > &channels, c_channel_def &chan, vector< c_channel_def > &channel_defs, bool &b_chan, vector< string > &all_groups, bool &b_groups, bool &b_prv, c_private &prv, deque< c_user > &terminators, map< string, c_function * > &functions, const string &debug) |
Parses and compiles one line from logic.txt. | |
bool | logic_rollback (vector< string > &log, const string &lang) |
Performs rollback to previous configuration from backup, if new logic.txt could not be successfully parsed. | |
void | logic_rollback_startup () |
Tries to rehash (reload and apply new configuration file logic.txt). | |
void | logic_set_dynamic (const string &username, const string &from_user, const char prefix, const char mode) |
Adds/remove new dynamic mode for user on channel, but only when group relationship and setting allows it. | |
string | logic_set_priority (const int priority) |
void | logic_shift_backup (const bool shift_all) |
Shifts backups of "logic.txt". | |
void | logic_user_mode_changing (const string &target_nick, const string &channel, char prefix, char action) |
If we are .upgrade'ing then notifies about mode change for new bot. | |
void | logic_validate (const string &channel, const string &source_user, const string &target_user, const string &source_nick, const string &target_nick, const char prefix, const char action) |
Validates MODE change and, if needed, executes on_XXX event. | |
void | logic_validate_by_mask (const string &channel, const string &source_user, const string &source_nick, const string &mask, const char prefix, const char action) |
Validates MODE change and, if needed, executes on_XXX event. | |
void | logic_validate_chan_key (const string &channel, const string &source_user, const string &source_nick, const char prefix, const string &key) |
Validates the key change (+/-k) for the channel and (if needed) calls event, and adds a key to the history. | |
void | logic_validate_chan_limit (const string &channel, const string &source_user, const string &source_nick, const char prefix, const string &limit) |
Validates the limit change (+/-l) for the channel and (if needed) calls event. | |
void | logic_validate_chan_mode (const string &channel, const string &source_user, const string &source_nick, const char prefix, const char mode) |
Validates the mode change of the channel and (if needed) calls events. | |
void | logic_validate_kick (const string &channel, const string &source_user, const string &target_user, const string &source_nick, const string &target_nick) |
Validates KICK and, if needed, executes on_kick event. | |
void | logic_validate_topic (const string &channel, const string &source_user, const string &source_nick, const string &topic) |
Validates the topic change and (if assigned) calls event. |
Implements core logic stored in "logic.txt" file.
Definition in file logic.h.