Beispiel #1
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))
Beispiel #2
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))
Beispiel #3
0
 def __init__(self):
     threading.Thread.__init__(self)
     self.__api_Twitter = Twython(
         config.CONSUMER_KEY, config.CONSUMER_SECRET, config.ACCESS_KEY, config.ACCESS_SECRET
     )
     self.__api_Twitch = TwitchAPI()
     self.__channel_status = {}
     self.__status = [
         "belästigt Leute",
         "gurkt rum",
         "langweilt Andere",
         "vergrault Zuschauer",
         "präsentiert sich",
         "sucht den Lichtschalter",
         "sucht den Sinn des Lebens",
         "spielt spaßige Spiele",
         "empört sich",
         "führt Selbstgespräche",
         "macht irgendwas interessantes",
     ]
     last_status = self.__api_Twitter.get_user_timeline(screen_name="RetroTwitch")[0]["text"]
     self.__last_status = last_status[0 : last_status.rfind(" ")]
     self.setDaemon(True)
     self.start()
Beispiel #4
0
class api(threading.Thread):
    
    def __init__(self, channels):
        threading.Thread.__init__(self)
        self.__twitchapi = TwitchAPI()
        self.__channels = channels
        self.__channel = {}
        self.__active = True
        
    def run(self):
        while self.__active:
            for i in range(len(self.__channels)):
                request = self.__channels[i]
                self.__twitchapi.setChannel(request[1:])
                self.__channel[request] = {
                    "Online" : self.__twitchapi.getKraken_isOnline(), 
                    "UpSince" : self.__twitchapi.getKraken_Up_Since(), 
                    "Chatters" : self.__twitchapi.getTMI_Chatters_All(),
                    "Users" : self.__twitchapi.getTMI_Chatters_Users()
                }
            time.sleep(300)
            
    def getOnlineState(self, channel):
        return self.__channel[channel]["Online"]
    
    def getChatters(self, channel):
        return self.__channel[channel]["Chatters"]
    
    def getUsers(self, channel):
        return self.__channel[channel]["Users"]
    
    def getUpSince(self, channel):
        return self.__channel[channel]["UpSince"]

    def finish(self):
        self.__active = False
Beispiel #5
0
class Twitter(threading.Thread):
    def __init__(self):
        threading.Thread.__init__(self)
        self.__api_Twitter = Twython(
            config.CONSUMER_KEY, config.CONSUMER_SECRET, config.ACCESS_KEY, config.ACCESS_SECRET
        )
        self.__api_Twitch = TwitchAPI()
        self.__channel_status = {}
        self.__status = [
            "belästigt Leute",
            "gurkt rum",
            "langweilt Andere",
            "vergrault Zuschauer",
            "präsentiert sich",
            "sucht den Lichtschalter",
            "sucht den Sinn des Lebens",
            "spielt spaßige Spiele",
            "empört sich",
            "führt Selbstgespräche",
            "macht irgendwas interessantes",
        ]
        last_status = self.__api_Twitter.get_user_timeline(screen_name="RetroTwitch")[0]["text"]
        self.__last_status = last_status[0 : last_status.rfind(" ")]
        self.setDaemon(True)
        self.start()

    def run(self):
        while self.isAlive():
            channels = self.__api_Twitch.getJSON(config.TWITTER)
            if channels is not None:
                for channel in channels["stream"]:
                    if channel not in self.__channel_status:
                        self.__channel_status[channel] = {"online": False, "time": 0}
                    self.__api_Twitch.setChannel(channel)
                    actual_time = time.time()
                    if (actual_time - self.__channel_status[channel]["time"]) > 900:
                        if self.__api_Twitch.getKraken_isOnline():
                            if not self.__channel_status[channel]["online"]:
                                self.__channel_status[channel]["online"] = True
                                self.__channel_status[channel]["time"] = time.time()
                                actual_status_id = random.choice(range(len(self.__status)))
                                output = (
                                    channel
                                    + " "
                                    + self.__status[actual_status_id].decode("utf-8")
                                    + " auf Twitch! Schau vorbei unter http://twitch.tv/"
                                    + channel
                                )
                                if self.__last_status == output[0 : output.rfind(" ")]:
                                    if actual_status_id == len(self.__channel_status) - 1:
                                        actual_status_id -= 1
                                    else:
                                        actual_status_id += 1
                                    output = (
                                        channel
                                        + " "
                                        + self.__status[actual_status_id].decode("utf-8")
                                        + " auf Twitch! Schau vorbei unter http://twitch.tv/"
                                        + channel
                                    )
                                self.__last_status = output[0 : output.rfind(" ")]
                                try:
                                    self.__api_Twitter.update_status(status=output)
                                except:
                                    print("Looks like a Twython Error!")
                        else:
                            self.__channel_status[channel]["online"] = False
                            self.__channel_status[channel]["time"] = 0
            time.sleep(60)
Beispiel #6
0
 def __init__(self, channels):
     threading.Thread.__init__(self)
     self.__twitchapi = TwitchAPI()
     self.__channels = channels
     self.__channel = {}
     self.__active = True