def restart_all(username, message, privileges): if message == "!restart all": user = data.get_element(username, main_users) if user is not None: user_privileges = int(user[eUser.privileges]) else: user_privileges = 0 if user_privileges >= privileges: for i in range(len(bot_threads)): shutdown(bot_threads[i]) bot_thread = Bot_Omb([bot_threads[i].getName()]) bot_thread.setName(bot_threads[i].getName()) bot_threads[i] = bot_thread bot_thread.start() else: main_whisper.whisper(username, "Your privileges level is not high enough to perform this command! You need at least a level of {0}.".format(privileges))
def restart(username, message, privileges): if message == "!restart": user = data.get_element(username, main_users) if user is not None: user_privileges = int(user[eUser.privileges]) else: user_privileges = 0 if user_privileges >= privileges: for i in range(len(bot_threads)): if "#"+username == bot_threads[i].getName(): shutdown(bot_threads[i]) del bot_threads[i] bot_thread = Bot_Omb(["#"+username]) bot_thread.setName("#"+username) bot_threads.append(bot_thread) bot_thread.start() main_whisper.whisper(username, "The Bot was restarted. Bot_Omb should be in your Stream again!") else: main_whisper.whisper(user, "The Bot can not be restarted, because Bet_Omb is not following your Stream!") else: main_whisper.whisper(username, "Your privileges level is not high enough to perform this command! You need at least a level of {0}.".format(privileges))
def follow(username, message, privileges): if message == "!follow": user = data.get_element(username, main_users) if user is not None: user_privileges = int(user[eUser.privileges]) else: user_privileges = 0 if user_privileges >= privileges: if not data.has(main_channel_list, "#"+username): try: os.mkdir(config.PATH+"channel/"+"#"+username) os.mkdir(config.PATH+"channel/"+"#"+username+"/bank") files = [ {"file_name" : "quotes.csv", "file_path" : config.PATH+"channel/#"+username+"/", "file_data" : ""}, {"file_name" : "guards.csv", "file_path" : config.PATH+"channel/#"+username+"/bank/", "file_data" : "Karl;20\nMark;50\nLisa;40\n"}, {"file_name" : "whitelist.csv", "file_path" : config.PATH+"channel/#"+username+"/", "file_data" : "bot_omb\nnightbot\ntipeeebot\nwizebot\nmikuia\nmoobot\n"}, {"file_name" : "commands.csv", "file_path" : config.PATH+"channel/#"+username+"/", "file_data" : ""}, {"file_name" : "announcements.csv", "file_path" : config.PATH+"channel/#"+username+"/", "file_data" : ""}, {"file_name" : "greetings.csv", "file_path" : config.PATH+"channel/#"+username+"/", "file_data" : ""}, {"file_name" : "settings.csv", "file_path" : config.PATH+"channel/#"+username+"/", "file_data" : "language_chat;english\nwarning_url;False\nwarning_caps;False\nwarning_long_text;False\ngreetings;False\ngreetings_interval;60\ncommand_mode;True\nbet_mode;True\nfollow_mode;True\nannounce_mode;True\nsmm_mode;True\npoll_mode;True\nrank_mode;True\nbank_mode;True\nwhitelist_mode;True\nwatchtime_mode;False\nquote_mode;False\nhelp;0\ncoins;0\ncommand_add;99\ncommand_remove;99\ncommand_show;99\nprivileges;99\nsetting;99\nsetting_show;99\nurl;99\nbet;0\nbet_start;99\nbet_stop;99\nbet_reset;99\nfollow;0\nfollow_member;0\nfollow_member_other;99\nunfollow;0\ninfo;0\nannounce_add;99\nannounce_remove;99\nannounce_show;99\nsmm_level_submit;99\nsmm_level_submit_other;99\nsmm_level_show;99\nsmm_level_next;99\npoll_start;99\npoll_vote;99\npoll_result;99\nlanguage;99\nupsince;0\nrank_add;99\nrank_remove;99\nrank_show;99\nrank_show_me;0\nbank_robbery;99\nbank_spy;99\nbank_robbery_flee;99\nbank_guard_add;99\nbank_guard_remove;99\nbank_guard_show;99\nwhitelist_add;99\nwhitelist_remove;99\nwhitelist_show;99\nclam_ask;99\nroulette;99\nwatchtime_me;99\nhug_random;99\nhug_other;99\nquote_add;99\nquote_remove;99\nquote_show;99\n"}, {"file_name" : "users.csv", "file_path" : config.PATH+"channel/#"+username+"/", "file_data" : username+";100;100;False;0;0;0\n"}, {"file_name" : "ranks.csv", "file_path" : config.PATH+"channel/#"+username+"/", "file_data" : ""} ] data.create(files) main_channel_list.append(["#"+username]) data.save(config.PATH+"channel/channel.csv", main_channel_list) except OSError: main_whisper.whisper(username, "Something went wrong. Please contact a Bot_Omb developer!") new_bot_thread = Bot_Omb(["#"+username]) new_bot_thread.setName("#"+username) new_bot_thread.setDaemon(True) bot_threads.append(new_bot_thread) new_bot_thread.start() main_whisper.whisper(username, "I joined your stream! If you want to use my full power, you just need to make me a Mod. Otherwise the auto moderation function will not work.") else: main_whisper.whisper(username, "I already joined your Chat!") else: main_whisper.whisper(username, "Your privileges level is not high enough to perform this command! You need at least a level of {0}.".format(privileges))
main_whisper.whisper(username, "Your privileges level is not high enough to perform this command! You need at least a level of {0}.".format(privileges)) if __name__ == '__main__': main_name = "#bot_omb" main_channel = irc(config.HOST, config.PORT_CHAT, config.NICK, config.PASS, [main_name]) main_whisper = irc(config.HOST, config.PORT_WHISPER, config.NICK, config.PASS) main_users = data.load(config.PATH+"channel/"+main_name+"/users.csv") main_settings = data.load(config.PATH+"channel/"+main_name+"/settings.csv") main_commands = data.load(config.PATH+"channel/"+main_name+"/commands.csv") main_channel_list = data.load(config.PATH+"channel/channel.csv") with open(config.PATH+"channel/channel.csv", 'r') as loaded: lines = loaded.readlines() bot_threads = [] for i in range(len(lines)): lines[i] = lines[i][:len(lines[i])-1] bot_thread = Bot_Omb([lines[i]]) bot_thread.setName(lines[i].replace("\n","")) bot_thread.setDaemon(True) bot_threads.append(bot_thread) bot_thread.start() twitter = Twitter() main_whisper.whisper('serdrad0x', 'The Bot was successfully started!') while True: response_channel = main_channel.receive(1024) if response_channel == "PING :tmi.twitch.tv\r\n": main_channel.pong() main_whisper.pong() else: username = re.search(r"\w+", response_channel) if username is not None: username = username.group(0)