コード例 #1
0
ファイル: dota.py プロジェクト: mathsad/borkedbot
def checktimeout(channel):
    twitchchecktimeout = settings.trygetset('%s_twitch_online_check_timeout' % channel, 15)
    lastonlinecheck = settings.trygetset('%s_twitch_online_last_check' % channel, time.time())
    laststreamingstate = settings.trygetset('%s_last_twitch_streaming_state' % channel, False)

    try:
        if time.time() - int(lastonlinecheck) > twitchchecktimeout:
            is_streaming = twitchapi.is_streaming(channel)
            settings.setdata('%s_last_twitch_streaming_state' % channel, is_streaming, announce=False)
        else:
            return laststreamingstate
    except Exception as e:
        print '[Dota] twitch api check error: ',e
        return False

    if is_streaming:
        if time.time() - int(twitchchecktimeout) > float(lastonlinecheck):
            settings.setdata('%s_twitch_online_last_check' % channel, time.time(), announce=False)
        else:
            return True
    else:
        return False

    laststreamcheck = settings.trygetset('%s_last_is_streaming_check' % channel, time.time())
    streamchecktimeout = settings.trygetset('%s_is_streaming_timeout' % channel, 30)

    if time.time() - int(streamchecktimeout) > float(laststreamcheck):
        getmatchtimeout = settings.trygetset('%s_get_online_match_timeout' % channel, 20)
        settings.setdata('%s_last_is_streaming_check' % channel, time.time(), announce=False)

    getmatchtimeout = settings.trygetset('%s_get_match_timeout' % channel, 30)
    lastmatchfetch = settings.trygetset('%s_last_match_fetch' % channel, time.time())

    return time.time() - int(getmatchtimeout) > float(lastmatchfetch)
コード例 #2
0
ファイル: dota.py プロジェクト: kyroskoh/borkedbot
def notablePlayerBlurb(channel, pages=10, override=False, updatetimers=True):
    playerid = settings.getdata('%s_dota_id' % channel)
    checkstatus = node.get_cached_rich_presence(ID(playerid).steamid)[ID(playerid).steamid]

    if checkstatus:
        userstatus = node.get_rich_presence(ID(playerid).steamid)[ID(playerid).steamid]
        if userstatus and userstatus['status'] in ["#DOTA_RP_HERO_SELECTION", "#DOTA_RP_PRE_GAME", "#DOTA_RP_GAME_IN_PROGRESS", "#DOTA_RP_PLAYING_AS"]:

            if getNotableCheckReady(channel) or override:
                if twitchapi.is_streaming(channel):
                    if userstatus['status'] == '#DOTA_RP_PLAYING_AS':
                        playerheroid = userstatus['param0']
                    else:
                        playerheroid = None

                    print "[Dota-Notable] Doing search for notable players%s" % (' using hero id' if playerheroid else '')
                    players = searchForNotablePlayers(playerid, pages, playerheroid)

                    if any(players):
                        settings.setdata('%s_notable_message_count' % channel, 0, announce=False)
                        settings.setdata('%s_notable_last_check' % channel, time.time(), announce=False)
                        return "Notable players in this game: %s" % ', '.join(['%s (%s)' % (p,h) for p,h in players])
コード例 #3
0
ファイル: dota.py プロジェクト: mathsad/borkedbot
def notablePlayerBlurb(channel, pages=33):
    playerid = settings.getdata('%s_dota_id' % channel)
    userstatus = node.get_user_status(dotaToSteam(playerid))
    if userstatus:
        # print 'Dota status for %s: %s' % (channel, userstatus)

        if userstatus in ["#DOTA_RP_HERO_SELECTION", "#DOTA_RP_PRE_GAME", "#DOTA_RP_GAME_IN_PROGRESS", "#DOTA_RP_PLAYING_AS"]:
            if getNotableCheckReady(channel):
                if twitchapi.is_streaming(channel):
                    if userstatus == '#DOTA_RP_PLAYING_AS':
                        playerheroid = node.get_user_playing_as(dotaToSteam(playerid))
                        playerheroid = getHeroIddict(False)[playerheroid[0]]
                    else:
                        playerheroid = None

                    print "[Dota-Notable] Doing search for notable players%s" % (' using hero id' if playerheroid else '')
                    players = searchForNotablePlayers(playerid, pages, playerheroid)
                    settings.setdata('%s_notable_message_count' % channel, 0, announce=False)

                    if players:
                        return "Notable players in this game: %s" % ', '.join(['%s (%s)' % (p,h) for p,h in players])
        else:
            notable_check_timeout = settings.trygetset('%s_notable_check_timeout' % channel, 600.0)
            settings.setdata('%s_notable_last_check' % channel, time.time() - notable_check_timeout + 60.0, announce=False)
コード例 #4
0
ファイル: recurring.py プロジェクト: mathsad/borkedbot
def _online_check_wrapper(channel, message, bot):
    import twitchapi
    print '[Recurring] Doing call'
    if twitchapi.is_streaming(channel):
        bot.botsay(message)
コード例 #5
0
ファイル: recurring.py プロジェクト: kyroskoh/borkedbot
def _online_check_wrapper(channel, message, bot):
    import twitchapi
    print '[Recurring] Doing call'
    if twitchapi.is_streaming(channel):
        bot.botsay(message)