def wrapper_func(Xfs, sock_id, Raw): func(Xfs, sock_id, Raw) line_split = Raw.line.split(" ") if (Raw.cmd == ".imdb"): cmd_logger.AddLog(Raw.in_nick, Raw.target, Raw.cmd) if (Raw.cmd == Raw.line): Xfs.Notice(sock_id, Raw.in_nick, "Erroare! Sintaxa corecta este: .imdb <titlu> <an=N>* | " + "Exemplu 1: .imdb Pulp Fiction | Exemplu 2: .imdb Star Wars an=2017") else: p_is_year = re.compile(".*\san\=\d\d\d\d$") p_year = re.compile(".*\san\=(\d\d\d\d)$") if (p_is_year.match(Raw.line) is not None): year_r = p_year.search(Raw.line) year = year_r.group(1) p_title = re.compile("^\.imdb\s(.*)\san\=\d\d\d\d$") title_r = p_title.search(Raw.line) title = title_r.group(1) imdb_thread = threading.Thread(target=GetIMDB, args=(Xfs, sock_id, Raw.in_nick, Raw.target, title, year), kwargs={"request_type": "t"}) imdb_thread.start() else: imdb_thread = threading.Thread(target=GetIMDB, args=(Xfs, sock_id, Raw.in_nick, Raw.target, Raw.line[6:]), kwargs={"request_type": "t"}) imdb_thread.start()
def AlphaRawHandler(Xfs, sock_id, Raw): """Interprets and handles alpha raws from socket.""" split_line = Raw.line.split(" ") if (Raw.raw_type == "PRIVMSG"): """PRIVMSG section.""" if (Raw.is_cmd == True): CmdHandler(Xfs, sock_id, Raw) elif (Raw.target == Xfs.nick): if (Raw.line == "help"): cmd_logger.AddLog(Raw.in_nick, Raw.target, "help") help_msg = ( "Comenzi disponibile pe canal: .lingura | .crypto | .btcaddr <address> | .imdb <titlu> <an=N>*" ) Xfs.Msg(sock_id, Raw.in_nick, help_msg) if (Raw.line == "\001VERSION\001"): """Version CTCP.""" Xfs.CTCPVersionReply(sock_id, Raw.in_nick) elif (Raw.line[0] == "\001" and Raw.line[-1] == "\001"): """ACTION section.""" elif (Raw.raw_type == "NOTICE"): """NOTICE section.""" if (Raw.in_nick == "NickServ"): if ("registered" in Raw.line and "protected" in Raw.line): """Auth to NickServ.""" Xfs.Identify(sock_id) elif ("password" in Raw.line and "email" in Raw.line): """Bot is using alt_nick, recover main nick.""" Xfs.RecoverNick(sock_id) elif ("now" in Raw.line and "identified!" in Raw.line): """Run stuff when identified.""" Xfs.AutoJoin(sock_id) Xfs.Msg(sock_id, "System", "invite " + str(Xfs.invite_key))
def CmdHandler(Xfs, sock_id, Raw): """Executes commands.""" split_line = Raw.line.split(" ") split_line_size = len(split_line) if (Raw.in_nick == Xfs.owner and Raw.in_host == Xfs.owner_host): if (Raw.cmd == ".join"): """Join command.""" cmd_logger.AddLog(Raw.in_nick, Raw.target, Raw.cmd) if (split_line_size == 1): Xfs.Msg(sock_id, Raw.target, "ERROR. Syntax is: .join <#chan> <key>*") elif (split_line_size == 2): if (split_line[1][0] != "#"): Xfs.Msg(sock_id, Raw.target, "ERROR. Syntax is: .join <#chan> <key>*") else: Xfs.Join(sock_id, split_line[1]) elif (split_line_size == 3): if (split_line[1][0] != "#"): Xfs.Msg(sock_id, Raw.target, "ERROR. Syntax is: .join <#chan> <key>*") else: Xfs.Join(sock_id, split_line[1], split_line[2]) elif (Raw.cmd == ".part"): """Part command.""" cmd_logger.AddLog(Raw.in_nick, Raw.target, Raw.cmd) if (split_line_size == 1): Xfs.Part(sock_id, Raw.target) elif (split_line_size == 2): if (split_line[1][0] != "#"): Xfs.Msg(sock_id, Raw.target, "ERROR. Syntax is: .part <#chan>*") else: Xfs.Part(sock_id, split_line[1]) elif (Raw.cmd == ".quit"): """Quit command.""" cmd_logger.AddLog(Raw.in_nick, Raw.target, Raw.cmd) if (split_line_size == 1): Xfs.Quit(sock_id) else: Xfs.Quit(sock_id, "".join(split_line[1:])) elif (Raw.cmd == ".restart"): """Restart command.""" cmd_logger.AddLog(Raw.in_nick, Raw.target, Raw.cmd) if (split_line_size == 1): Xfs.RestartBot(sock_id)
def wrapper_func(Xfs, sock_id, Raw): func(Xfs, sock_id, Raw) if (Raw.target == "#filelist" and Raw.cmd == ".lingura" and Raw.line == Raw.cmd): cmd_logger.AddLog(Raw.in_nick, Raw.target, Raw.cmd) """Only owner and rose can show top10.""" if (Raw.in_nick != Xfs.owner and Raw.in_nick != "rose"): ShowLingura(Xfs, sock_id, Raw.target, Raw.in_nick) if (Raw.in_nick == Xfs.owner or Raw.in_nick == "rose"): ShowTopLingura(Xfs, sock_id, Raw.target)
def wrapper_func(Xfs, sock_id, Raw): func(Xfs, sock_id, Raw) if (Raw.cmd == ".btcaddr"): split_line = Raw.line.split(" ") if (len(split_line) == 2 and len(split_line[1]) == 34 and split_line[1].isalnum() == True): cmd_logger.AddLog(Raw.in_nick, Raw.target, Raw.cmd) addr_thread = threading.Thread(target=GetAddr, args=(Xfs, sock_id, Raw.target, split_line[1])) addr_thread.start()
def wrapper_func(Xfs, sock_id, Raw): func(Xfs, sock_id, Raw) if (Raw.in_nick == Xfs.owner and Raw.in_host == Xfs.owner_host and Raw.cmd == ".uploadstats" and Raw.line == Raw.cmd): cmd_logger.AddLog(Raw.in_nick, Raw.target, Raw.cmd) ShowStats(Xfs, sock_id, Raw.target)