Esempio n. 1
0
def unfollow(username, message, privileges):
    if message == "!unfollow":
        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 data.has(main_channel_list, "#"+username):
                try:
                    shutil.rmtree(config.PATH+"channel/#"+username)
                    for key in main_channel_list:
                        if key[0] == "#"+username:
                            main_channel_list.remove(key)
                            data.save(config.PATH+"channel/channel.csv", main_channel_list)
                            break
                except OSError:
                    main_whisper.whisper(username, "Something went wrong. Please contact a Bot_Omb developer!")
                for i in range(len(bot_threads)):
                    if "#"+username == bot_threads[i].getName():
                        shutdown(bot_threads[i])
                        break
                main_whisper.whisper(username, "It seems like, it is time to say goodbye!")
            else:
                main_whisper.whisper(username, "First things first. If you want me to unfollow your chat, I have to follow first.")
        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))  
Esempio n. 2
0
def show_follows_other(username, message, privileges):
    if regex.REG_FOLLOWS_OTHER.match(message):
        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:
            check = True
            if username in follow_requests:
                if follow_requests[username].isAlive():
                    check = False
                    main_whisper.whisper(username, "Your request is still in progress, please be patient!")
                else:
                    del follow_requests[username]
            if check:
                follows_name = message[message.find(' ')+1 : len(message)]
                api = TwitchAPI(follows_name)
                aprox_time = int(api.getKraken_Followers() * 0.025)
                main_whisper.whisper(username, "Please be patient, while Bot_Omb is handling your !follows request. It will take approximate "+str(aprox_time)+" seconds.")
                follow_thread = threading.Thread(target=api.show_follows_thread, args=(main_whisper, follows_name, username,))
                follow_requests[username] = follow_thread
                follow_thread.setDaemon(True)
                follow_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))
Esempio n. 3
0
 def guard_remove(self, username, message):
     guard = message[message.rfind(' ')+1:len(message)]
     guard_element = data.get_element(guard, self.__guards)
     if (len(self.__guards) - 1) < 3:
         self.__whisper.whisper(username, self.__languages["lan"]["guard_remove_fail_count"].format(str(self.__guards)))
     elif guard_element is None:
         self.__whisper.whisper(username, self.__languages["lan"]["guard_remove_fail_list"].format(guard))
     else:
         self.__guards.remove(guard_element)
         self.__whisper.whisper(username, self.__languages["lan"]["guard_remove"].format(str(guard_element)))
Esempio n. 4
0
def show_threads(username, message, privileges):
    if message == "!threads":
        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:
            data.show(bot_threads)
        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))
Esempio n. 5
0
def shutdown_all(username, message, privileges):
    if message == "!shutdown":
        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])
            main_whisper.whisper(username, "Every channel is shutdown!")
        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))
Esempio n. 6
0
def show_follows(username, message, privileges):
    if message == "!follows":
        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:
            api = TwitchAPI(username)
            aprox_time = int(api.getKraken_Followers() * 0.025)
            main_whisper.whisper(username, "Please be patient, while Bot_Omb is handling your !follows request. It will take approximate "+str(aprox_time)+" seconds.")
            follow_thread = threading.Thread(target=api.show_follows_thread, args=(main_whisper, username,))
            follow_thread.setDaemon(True)
            follow_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))
Esempio n. 7
0
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))
Esempio n. 8
0
 def run(self):
     while self.__active:
         time.sleep(60)
         if self.__api.getOnlineState(self.__channel_name):
             self.__users = data.load(config.PATH+"channel/"+self.__channel_name+"/users.csv")
             if self.__active:
                 users_chat = self.__api.getChatters(self.__channel_name)
                 if users_chat is not None:
                     for i in range(len(users_chat)):
                         user = data.get_element(users_chat[i].lower(), self.__users)
                         if user is not None:
                             watched = int(user[eUser.watchtime]) + 1
                             if not data.update(users_chat[i].lower(), [None, None, None, None, None, None, None, watched], self.__users):
                                 self.__users.append([users_chat[i].lower(), 0, 100, False, 0, 0, 0, watched])
                         else:
                             watched = 1
                             self.__users.append([users_chat[i].lower(), 0, 100, False, 0, 0, 0, watched])
                     data.save(config.PATH+"channel/"+self.__channel_name+"/users.csv", self.__users)
Esempio n. 9
0
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)) 
Esempio n. 10
0
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))