예제 #1
0
async def status_changer():
    cshtype = 1
    url = 'https://cricket.yahoo.net/sifeeds/multisport/?methodtype=3&client=24&sport=1&league=0&timezone=0530&language=en&gamestate='+str(cshtype)
    sh = cb.schedule(40, cb.fetch(url))
    t,preid,ie = '', '', True
    for i in sh:
        if 'India' in i[4]:
            preid = i[9]
            break
    if preid == '':
        try:
            preid = sh[0][9]
        except IndexError:
            preid = 'abcd'
            ie=False
    url = 'https://cricket.yahoo.net/sifeeds/cricket/live/json/' + preid + '.json'
    data = cb.fetch(url)
    c=0
    while ie:
        try: 
            s=cb.miniscore(c,data)
            c+=1
        except IndexError:break
        except KeyError: 
            s='No live matches currently'
            break
    try:
        if ie==False:
            raise IndexError
        score = '{0}-{1} ({2})'.format(s[4], s[5], s[6])
        t = '{0} vs {1}'.format(s[7], s[8])
        string = '{0} | {1}'.format(t, score)
    except IndexError: string = 'No matches live currently.'
    await bot.change_presence(activity=discord.Game(name=string))
예제 #2
0
def pshipc_embed_f(match_index,raw_data):
    s = cb.miniscore(0, raw_data)
    teams = raw_data['Teams']
    team_ids = list(teams)
    embed = discord.Embed(title=s[2], color=0x03f8fc)
    embed.add_field(name='{0} vs {1}'.format(s[7], s[8]), value='**Date**: {0}  **Time**:{1}\n**Venue**: {2}'.format(s[0],s[1],s[3]), inline=False)
    embed.add_field(name='Select the inning:', value='1. {0}\n2. {1}'.format(
        teams[team_ids[0]]['Name_Full'], teams[team_ids[1]]['Name_Full']), inline=False)
    embed.set_footer(text='sessionid:PPC-{0}'.format(match_index), inline=True)
    return embed
예제 #3
0
def powerplay_embed_f(raw_data, match_index):
    s = cb.miniscore(0, raw_data)
    teams = raw_data['Teams']
    team_ids = list(teams)
    embed = discord.Embed(title=s[2], color=0x03f8fc)
    embed.add_field(name='{0} vs {1}'.format(s[7], s[8]), value='**Date**: {0}  **Time**:{1}\n**Venue**: {2}'.format(s[0],s[1],s[3]), inline=False)
    embed.add_field(name='React the team no. to get Partnership details', value='1. {0}\n2. {1}'.format(
        teams[team_ids[0]]['Name_Full'], teams[team_ids[1]]['Name_Full']), inline=False)
    embed.set_footer(text='sessionid:PSP-{0}-{1}-{2}'.format(match_index,team_ids[0],team_ids[1]))
    return embed
예제 #4
0
def shotsfig_embed_f(raw_data: dict):
    s = cb.miniscore(0, raw_data)
    teams = raw_data['Teams']
    team_ids = list(teams)
    embed = discord.Embed(title=s[2], color=0x03f8fc)
    embed.add_field(name='{0} vs {1}'.format(
        s[7], s[8]), value='**Date**: {0}  **Time**:{1}\n**Venue**: {2}'.format(s[0], s[1], s[3]), inline=False)
    embed.add_field(name='Select the Inning:', value='1. {0}\n2. {1}'.format(
        teams[team_ids[0]]['Name_Full'], teams[team_ids[1]]['Name_Full']), inline=False)
    return embed
예제 #5
0
def player_againstcard_embed_f(raw_data, n):
    s = cb.miniscore(0, raw_data)
    teams = raw_data['Teams']
    team_ids = list(teams)
    embed = discord.Embed(title=s[2], color=0x03f8fc)
    embed.add_field(name='{0} vs {1}'.format(
        s[7], s[8]), value='**Date**: {0}  **Time**:{1}\n**Venue**: {2}'.format(s[0], s[1], s[3]), inline=False)
    if n == 0:
        embed.add_field(name='Select the inning:', value='1. {0}\n2. {1}'.format(
            teams[team_ids[0]]['Name_Full'], teams[team_ids[1]]['Name_Full']), inline=False)
    else:
        embed.add_field(name='Select player type:', value='1. {0}\n2. {1}'.format('Batsmen', 'Bowlers'), inline=False)
    return embed
예제 #6
0
def score_embed(raw_data, match_index):
    score_string=''
    i=0
    while True:
        try:
            s=cb.miniscore(i,raw_data)
            score_string += '{0} {1}-{2} ({3})\n'.format(s[7],s[4],s[5],s[6])
            i+=1
        except Exception:
            break
    score_string+='**Status**: ***{0}***\n'.format(s[9])
    embed = discord.Embed(title=s[2], color=0x03f8fc)
    embed.add_field(name='{0} vs {1}'.format(s[7], s[8]), value='**Date**: {0}  **Time**:{1}\n**Venue**: {2}'.format(s[0],s[1],s[3]), inline=False)
    embed.add_field(name='**Score**', value=score_string, inline=False)
    embed.set_footer(text='sessionid:MSC-{0}'.format(match_index))
    return embed