Exemplo n.º 1
0
def user_ratio(user):
    """
    :param user: string representing http://www.twitch.tv/<user>
    :return: the ratio of chatters to viewers in <user>'s channel
    """
    chatters2 = 0
    exceptions = get_exceptions()
    # Don't have to put ^ or $ at the beginning. Just use .* it's more concise.
    for regex in exceptions:
        if regex != '':
            if regex[0] != '^':
                regex = '^' + regex
            if regex[-1] != '$':
                regex += '$'
            if re.match(regex, user, re.I | re.S) != None:
                print user, "is alright :)",
                return 1
    if user in get_frontpage_users():
        print "nope,", user, "is a featured stream (being shown on the frontpage).",
        return 1
    if is_being_hosted(user):
        print "nope,", user, "is being hosted by someone",
        return 1
    if d2l_check:
        d2l_list = get_dota2lounge_list()
        if user in d2l_list:
            print user, "is being embedded in dota2lounge. nogo",
            return 1
    chatters = user_chatters(user)
    if debug:
        chatters2 = get_chatters2(user)
    viewers = user_viewers(user)
    if viewers == -1:  # This means something went wrong with the twitch servers, or internet cut out
        print "RECURSING BECAUSE OF 422 TWITCH ERROR"
        return user_ratio(user)
    if viewers and viewers != 0:  # viewers == 0 => streamer offline
        maxchat = max(chatters, chatters2)
        ratio = float(maxchat) / viewers
        print user + ": " + str(maxchat) + " / " + str(viewers) + " = %0.3f" % ratio,
        if debug:
            print "(%d - %d)" % (chatters2, chatters),
        if chatters != 0:
            if debug:
                diff = abs(chatters2 - chatters)
                error = (100 * (float(diff) / chatters))  # Percent error
        else:
            return 0
        if debug and error > 6:
            print " (%0.0f%% error)!" % error,
            if error < 99 and diff > 10:
                print "!!!!!!!!!!!!!!!!!!!"  # If my chatters module goes wrong, i want to notice it.
            if ratio > 1:
                webbrowser.open("BDB - ratio for " + user + " = %0.3f" % ratio)
                print "????????????"
            else:
                print
    else:
        return 1  # User is offline.
    return ratio
def user_ratio(user):
    global debug
    time.sleep(5)
    print "checking", user, "ratio"
    chatters2 = 0
    if user in get_frontpage_users():
        print "nope,", user, "is on the front page of twitch."
        return 1
    exceptions = get_exceptions()
    # users don't have to put ^ or $ at the beginning. just use .* it's more readable.
    for regex in exceptions:
        if regex != "":
            if regex[0] != "^":
                regex = "^" + regex
            if regex[-1] != "$":
                regex += "$"
            # if the username matches the regex
            if re.match(regex, user, re.I | re.S) != None:
                print user, "is alright :)",
                return 1
    if d2l_check:
        d2l_list = get_dota2lounge_list()
        if user in d2l_list:
            print user, "is being embedded in dota2lounge. nogo"
            return 1
    print "here1"
    chatters = user_chatters(user)
    if debug:
        chatters2 = get_chatters2(user)
    print "here2"
    viewers = user_viewers(user)
    print "here3"
    if viewers and viewers != 0 and viewers != None:
        maxchat = max(chatters, chatters2)
        ratio = float(maxchat) / viewers
        print user + ": " + str(maxchat) + " / " + str(viewers) + " = %0.3f" % ratio,
        if debug:
            print "(%d - %d)" % (chatters2, chatters),
        if chatters != 0:
            if debug:
                diff = abs(chatters2 - chatters)
                error = 100 * (float(diff) / chatters)  # percent error
        else:
            return 0
        if debug and error > 6:
            print " (%0.0f%% error)!" % error,
            if error < 99 and diff > 10:
                print "!!!!!!!!!!!!!!!!!!!"  # if my chatters module goes wrong, i want to notice it.
            if ratio > 1:
                webbrowser.open("BDB - ratio for " + user + " = %0.3f" % (ratio))
                print "????????????"
            else:
                print
        else:
            print
    else:
        return 1  # user is offline
    return ratio
Exemplo n.º 3
0
def user_ratio(user):
    chatters2 = 0
    exceptions = get_exceptions()
    #users don't have to put ^ or $ at the beginning. just use .* it's more readable.
    for regex in exceptions:
        if regex != '':
            if regex[0] != '^':
                regex = '^' + regex
            if regex[-1] != '$':
                regex += '$'
        #if the username matches the regex
            if re.match(regex, user, re.I | re.S) != None:
                print user, "is alright :)",
                return 1
    if user in get_frontpage_users():
        print "nope,", user, "is on the front page of twitch.",
        return 1
    if d2l_check:
        d2l_list = get_dota2lounge_list()
        if user in d2l_list:
            print user, "is being embedded in dota2lounge. nogo",
            return 1
    chatters = user_chatters(user)
    if debug:
        chatters2 = get_chatters2(user)
    viewers = user_viewers(user)
    if viewers == -1:  #this means something went wrong with the twitch servers, or user's internet died
        print "RECURSING BECAUSE OF 422 TWITCH ERROR"
        return user_ratio(user)
    if viewers and viewers != 0:  #viewers == 0 => streamer offline
        maxchat = max(chatters, chatters2)
        ratio = float(maxchat) / viewers
        print user + ": " + str(maxchat) + " / " + str(
            viewers) + " = %0.3f" % ratio,
        if debug:
            print "(%d - %d)" % (chatters2, chatters),
        if chatters != 0:
            if debug:
                diff = abs(chatters2 - chatters)
                error = (100 * (float(diff) / chatters))  #percent error
        else:
            return 0
        if debug and error > 6:
            print " (%0.0f%% error)!" % error,
            if error < 99 and diff > 10:
                print "!!!!!!!!!!!!!!!!!!!"  #if my chatters module goes wrong, i want to notice it.
            if ratio > 1:
                webbrowser.open("BDB - ratio for " + user + " = %0.3f" %
                                (ratio))
                print "????????????"
            else:
                print
    else:
        return 1  # user is offline
    return ratio
def user_ratio(user):
    chatters2 = 0
    exceptions = get_exceptions()
#users don't have to put ^ or $ at the beginning. just use .* it's more readable.
    for regex in exceptions:
        if regex != '':
            if regex[0] != '^':
                regex = '^' + regex
            if regex[-1] != '$':
                regex += '$'
           #if the username matches the regex 
            if re.match(regex, user, re.I|re.S) != None: 
                print user, "is alright :)",
                return 1
    if user in get_frontpage_users():
        print "nope,", user, "is on the front page of twitch.",
        return 1
    if d2l_check:
        d2l_list = get_dota2lounge_list()
        if user in d2l_list:
            print user, "is being embedded in dota2lounge. nogo",
            return 1
    chatters = user_chatters(user)
    if debug:
        chatters2 = get_chatters2(user)
    viewers = user_viewers(user)
    if viewers == -1: #this means something went wrong with the twitch servers, or user's internet died
        print "RECURSING BECAUSE OF 422 TWITCH ERROR"
        return user_ratio(user)
    if viewers and viewers != 0: #viewers == 0 => streamer offline
        maxchat = max(chatters, chatters2)
        ratio = float(maxchat) / viewers
        print user + ": " + str(maxchat) + " / " + str(viewers) + " = %0.3f" %ratio,
        if debug:
            print "(%d - %d)" %(chatters2, chatters),
        if chatters != 0:
            if debug:
                diff = abs(chatters2 - chatters)
                error = (100 * (float(diff) / chatters)) #percent error 
        else:
            return 0
        if debug and error > 6:
            print " (%0.0f%% error)!" %error,
            if error < 99 and diff > 10:
                print "!!!!!!!!!!!!!!!!!!!" #if my chatters module goes wrong, i want to notice it.
            if ratio > 1:
                webbrowser.open("BDB - ratio for "+user+" = %0.3f" %(ratio))
                print "????????????"
            else:
                print
    else: 
        return 1 # user is offline
    return ratio
    from chat_count import chat_count

global_sum = 0
global_cnt = 0

#lists of Botters passed around all over the place, represents who's currently botting.
suspicious = []
confirmed = []

# these users are known to have small chat to viewer ratios for valid reasons
# NOTE: Regexes, not only strings (though strings will work too)
#       You don't have to put ^ or $ at the beginning/end. just use .* -- it's more readable.
# example: chat disabled, or chat hosted not on the twitch site, or mainly viewed on 
#          front page of twitch
# type: list of REGEXes: example: ["destiny", "scg_live.*", ".*twitch.*"]
exceptions = get_exceptions()

#get_chatters2:
#   gets the number of chatters in user's Twitch chat, via chat_count
#   Essentially, chat_count is my experimental method that goes directly to 
#   a user's IRC channel and counts the viewers there. It is not yet proven to be 
#   correct 100% of the time.
#user is a string representing http://www.twitch.tv/<user>
def get_chatters2(user):
    chatters2 = 0
    try:
        chatters2 = chat_count(user)
    except socket.error as error:
        print ":((( get_chatters2 line 37 on twitch_chatters"
        return get_chatters2(user)
    return chatters2
Exemplo n.º 6
0
    from chat_count import chat_count

global_sum = 0
global_cnt = 0

# Lists of Botters passed around all over the place, represents who's currently botting.
suspicious = []
confirmed = []

# These users are known to have small chat to viewer ratios for valid reasons
# NOTE: Regexes, not only strings (though strings will work too)
#       You don't have to put ^ or $ at the beginning/end. just use .* -- it's more readable.
# example: chat disabled, or chat hosted not on the twitch site, or mainly viewed on 
#          front page of twitch
# type: list of REGEXes: example: ["destiny", "scg_live.*", ".*twitch.*"]
exceptions = get_exceptions()


def get_chatters2(user):
    """
    gets the number of chatters in user's Twitch chat, via chat_count
    Essentially, chat_count is my experimental method that goes directly to
    a user's IRC channel and counts the viewers there. It is not yet proven to be
    correct 100% of the time.
    """
    chatters2 = 0
    try:
        chatters2 = chat_count(user)
    except socket.error as error:
        print ":((( get_chatters2 line 37 on twitch_chatters"
        return get_chatters2(user)