Exemple #1
0
async def venue(ctx):
    c = Cricbuzz()
    try:
        match = c.matchinfo(match_id())
    except:
        await ctx.send('abe saale abhi to koi game nahi chal raha hai')
        return
    match = c.matchinfo(match_id())
    await ctx.send(match["venue_name"])
    await ctx.send(match['venue_location'])
Exemple #2
0
def match_info(mid):
    match_info_result = []
    c = Cricbuzz()
    minfo = c.matchinfo(mid)
    print(json.dumps(minfo, indent=4, sort_keys=True))
    match_info_result.append(minfo)
    return jsonify({'match information': match_info_result})
Exemple #3
0
async def toss(ctx):
    c = Cricbuzz()
    try:
        I = c.matchinfo(match_id())
    except:
        await ctx.send('abe saale abhi to koi game nahi chal raha hai')
        return
    await ctx.send(I['toss'])
Exemple #4
0
def matchobjectlist():
    c = Cricbuzz()

    matchobjects = [c.matchinfo(ids[i]) for i in range(len(ids))]

    print(matchobjects)
    with open("ipl.pickle", "wb") as ipl:
        pickle.dump(matchobjects, ipl)
Exemple #5
0
def index():
  c = Cricbuzz()
  match = c.matches()
  mid = (match[0]['id'])
  livescore = c.livescore(mid=mid)
  scorecard = c.scorecard(mid=mid)
  matchinfo = c.matchinfo(mid=mid)
  commentary = c.commentary(mid=mid)

  result = {"matches": match, "livescore": livescore, "scorecard": scorecard, "matchinfo": matchinfo, "commentary": commentary}
  final = jsonify(result)
  return f"{final}"
def match_info(mid):
    c = Cricbuzz()
    minfo = c.matchinfo(mid)
    print('------------------------------------------')
    print(" Match No  : " + minfo["mnum"])
    print(" Match Between : " + minfo["team1"]["name"] + " v/s " + minfo["team2"]["name"] )
    if(minfo["toss"]==""):
        print(" Toss is yet to happen")
    else:
        print(" Toss : " + minfo["toss"])
    print(" Match Location : " + minfo["venue_name"] +" located at " + minfo["venue_location"] )
    print(" Match Status : " + minfo["status"])
Exemple #7
0
def refresh():
    c = Cricbuzz()
    match = c.matches()
    mid = match[1]['id']
    matches = match[1]
    livescore = c.livescore(mid=mid)
    scorecard = c.scorecard(mid=mid)
    matchinfo = c.matchinfo(mid=mid)
    commentary = c.commentary(mid=mid)
    result = {}
    result['matches'] = matches
    result['livescore'] = livescore
    result['scorecard'] = scorecard
    result['matchinfo'] = matchinfo
    result['commentary'] = commentary
    return result
Exemple #8
0
class CricketScores():
    def __init__(self):
        self.c=Cricbuzz()
        self.all_matches = self.c.matches()
    def todays_matches(self):
        pass
    def all_matches_nearby(self):
        for match in self.all_matches:
            print(match['team1']['name'],'vs',match['team2']['name'])
    def all_matches_nearby_with_status(self):
        for match in self.all_matches:
            print(match['team1']['name'],'vs',match['team2']['name'])
            print(match['status'])
    def upcoming_matches(self):
        print('---ALL UPCOMING MATCHES---')
        count=0
        for match in self.all_matches:
            if 'Starts' in match['status']:
                count+=1
                print(match['team1']['name'],'vs',match['team2']['name'])
                print(match['status'])
        if count==0:
            print('No matches nearby')
    def live_scores(self):
        print('---LIVE SCORES---')
        count=0
        for match in reversed(self.all_matches):
            try:
                batting_data=self.c.livescore(match['id'])['batting']
                bowling_data=self.c.livescore(match['id'])['bowling']
                print(batting_data)
                print(batting_data['team'],':',batting_data['score'][0]['runs'],'/',batting_data['score'][0]['wickets'],'Overs:',batting_data['score'][0]['overs'])
                print('versus ',bowling_data['team'])
                print('status:',self.c.matchinfo(match['id'])['status'])
                count+=1
                #print(self.c.scorecard(match['id']))

                innings='second' if batting_data['score'][0]['inning_num']=='2' else 'first'
                assistant.say('match '+batting_data['team']+' versus '+bowling_data['team'])
                assistant.say(innings+' innings '+batting_data['team']+' is batting with score '+batting_data['score'][0]['runs']+' at '+batting_data['score'][0]['wickets'])
                speak('in '+batting_data['score'][0]['overs']+' overs')

            except:
                pass
        if count==0:
            print('NO LIVE MATCHES NOW')
Exemple #9
0
async def teams(ctx):
    c = Cricbuzz()
    try:
        I = c.matchinfo(match_id())
    except:
        await ctx.send('abe saale abhi to koi game nahi chal raha hai')
        return
    embed1 = discord.Embed(title=I['team1']['name'],
                           colour=discord.Colour.blue())
    for X, J in enumerate(I['team1']['squad']):
        embed1.add_field(name=J, value=f'{X+1}', inline=False)
    embed2 = discord.Embed(title=I['team2']['name'],
                           colour=discord.Colour.gold())
    for X, J in enumerate(I['team2']['squad']):
        embed2.add_field(name=J, value=f'{X+1}', inline=False)
    await ctx.send(embed=embed1)
    await ctx.send(embed=embed2)
Exemple #10
0
def cricket():
    c = Cricbuzz()
    match = c.matches()
    mid = (match[0]['id'])
    livescore = c.livescore(mid=mid)
    scorecard = c.scorecard(mid=mid)
    matchinfo = c.matchinfo(mid=mid)
    commentary = c.commentary(mid=mid)

    result = [{
        "matches": match,
        "livescore": livescore,
        "scorecard": scorecard,
        "matchinfo": matchinfo,
        "commentary": commentary
    }]
    return result
def match_info(mid):
    c = Cricbuzz()
    minfo = c.matchinfo(mid)
    print(json.dumps(minfo, indent=4, sort_keys=True))
Exemple #12
0
class Cricket:
    def __init__(self):
        self.cb = Cricbuzz()
        self.all_matches = self.cb.matches()
        self.run = True
        
    def live_matches(self):
        msg = "*  🏏 All live matches  *\n\n"
        for match in self.all_matches:
            if match['mchstate'] == 'inprogress':
                msg += match["team1"]["name"]+" v/s " + match["team2"]["name"]+ "," \
                     + match["srs"] + " - " + match["mnum"] + "\n\n"
            else:
                msg += "No live matches"
        return msg
            
    def commentary(self, match_id):
        commentary = self.cb.commentary(match_id)
        msg = f"Live commentary - {match_id}\n\n"
        for com in commentary["commentary"]:
            msg += com['comm'].replace("<b>","").replace("</b>","").replace("<br/>","\n") + "\n"
        return msg
                    
        
    def score_card(self, match_id):
        match = self.cb.matchinfo(match_id)
        score = self.cb.scorecard(match_id)
        msg = f"<code>{match['team1']['name']} v/s {match['team2']['name']}-Scorecard</code>\n"
        for scr in reversed(score["scorecard"]):
            batcard = "".join([f"Name: {batcard['name']}\n Runs: {batcard['runs']}\n Balls: {batcard['balls']}\n Fours: {batcard['fours']}\n Six: {batcard['six']}\n Dismissal: {batcard['dismissal']}\n" for batcard in scr['batcard']])
            bowlcard = "".join([f"Name: {bowlcard['name']}\n Overs: {bowlcard['overs']}\n Maidens: {bowlcard['maidens']}\n Runs: {bowlcard['runs']}\n Six: {bowlcard['wickets']}\n Wides: {bowlcard['wides']}\n No Balls: {bowlcard['nballs']}\n" for bowlcard in scr['bowlcard']])
            msg += f"INN: {scr['inng_num']}\n" \
                   f" Batteam: {scr['batteam']}\n" \
                   f" {scr['runs']}/{scr['wickets']} in {scr['overs']} overs\n" \
                   f" Bowlteam: {scr['bowlteam']}\n" \
                   "\n\n"
        return msg
                   
    def players(self, match_id):
        match = self.cb.matchinfo(match_id)
        msg = f'Team 1: {match["team1"]["name"]}\n'
        msg += "Squad:\n " + " ".join([squad + "\n" for squad in match["team1"]["squad"]])
        msg += f'\n\nTeam 2: {match["team2"]["name"]}\n'
        msg += "Squad:\n " + " ".join([squad + "\n" for squad in match["team2"]["squad"]])
        return msg
            
            
                             
    def match_info(self, match_id):
        match = self.cb.matchinfo(match_id)
        msg = "*Series:* _" + match["srs"] + "_\n" \
              "*Match No:* _" + match["mnum"] + "_\n" \
              "*Type:* _" + match["type"] + "_\n" \
              "*State:* _" + match["mchstate"] + "_\n" \
              "*Status:* _" + match["status"] +"_\n" \
              "*Venue:* _" + match["venue_name"] + " " + match["venue_location"] + "_\n" \
              "*Toss:* _" + match["toss"] + "_\n" \
              "*Team 1:* _" + match["team1"]["name"] + "_\n" \
              "*Team 2:* _" + match["team2"]["name"] + "_\n" \
              f"*Officials:*\n _umpire 1: {match['official']['umpire1']['name']}\n umpire 2: {match['official']['umpire2']['name']}\n umpire 3: {match['official']['umpire3']['name']}\n referee: {match['official']['referee']['name']}_\n" \
              "*Start Time:* _" + match["start_time"] + "_\n" \
              "*Team 1:* _" + match["team1"]["name"] + "_\n" \
              "*Team 2:* _" +  match["team2"]["name"] + "_\n"              
        return msg
        
    def live_score(self, message, match_id):
        then = time.time()
        while self.run:
            elapsed = time.time() - then
            if elapsed > 10800:
                message.delete()
                break
            match_info = self.cb.matchinfo(match_id)
            live_score = self.cb.livescore(match_id)
            last_updated = datetime.utcnow() + timedelta(minutes=30, hours=5)
            batting, bowling = live_score["batting"], live_score["bowling"]
            msg = ''
            msg += match_info['srs'] + '\n' + match_info['status'] + '\n\n'
            msg += batting['team'] + "\n"
            for score in batting['score']:
                msg += f" INN: {score['inning_num']} {score['runs']}/{score['wickets']} in {score['overs']} overs\n"
                
            for bts in batting['batsman']:
                msg += f" {bts['name']} : {bts['runs']}({bts['balls']}) \n"
            
            msg += bowling['team'] + "\n"
            for score in bowling['score']:
                msg += f" INN: {score['inning_num']} {score['runs']}/{score['wickets']} in {score['overs']} overs\n"
                
            for balls in bowling['bowler']:
                msg += f" {balls['name'].strip('*')} : {balls['wickets']}/{balls['runs']} \n"
            msg += f"\n_Last updated: {last_updated.strftime('%I:%M:%S %P')} [IST]_"
            try:
                message.edit_text(
                   text = msg,
                   parse_mode="markdown",
                   reply_markup = InlineKeyboardMarkup([
                    [ InlineKeyboardButton(text=f"Stop",callback_data=f"stop"),
                      InlineKeyboardButton(text=f"Force Refresh",callback_data=f"force_ref-{match_id}")
                     ]
                  ])
                )
            except:
                pass
            time.sleep(60)
            
        else:   
            self.run = True
            message.edit_text("Terminating...")
            time.sleep(2)
            message.delete()
            
    def list_matches_buttons(self, cb_data):        
        btns = []
        for match in self.all_matches:
            btns.append([InlineKeyboardButton(text=f" {match['team1']['name']} v/s {match['team2']['name']} ",callback_data=f"{cb_data}-{match['id']}")])
        btns.append([ InlineKeyboardButton(text=f"<<< Go back to home",callback_data=f"back_to_home")])
        return btns
def match_info(mid):
    c = Cricbuzz()
    minfo = c.matchinfo(mid)
    return(json.dumps(minfo,indent=1))
Exemple #14
0
from pycricbuzz import Cricbuzz

c = Cricbuzz()
matches = c.matches()
for match in matches:
    #print (match)
    if (match['mchstate'] != 'nextlive'):
        #match1= (c.livescore(match['id']))
        #print (c.commentary(match['id']))
        print c.matchinfo(match['id'])
        #
        #print (c.scorecard(match['id']))
        """
		if 'batting' in match1.keys():
		
			a=(match1['batting']['score'])[0]
			#print(match1['batting']['team'],a['runs'],'/',a['wickets'] ,'in',a['overs'])

			#print('==')
			#print(match1['batting'])
			#print((match1['batting']['batsman'])[0])
			break"""
Exemple #15
0
def reply():
    msg_text = request.form.get("Body")
    # x=collection.find_one({"NUMBER":num})
    # try:
    #     status=x["status"]
    # except:
    #     pass
    # if (bool(num)==False):
    # collection.insert_one({"NUMBER":num,"status":"first"})
    msg = MessagingResponse()
    resp = msg.message(
        """Hello & welcome ,myself IPL BOT ,a bot for knowing live score updates for ipl matches.
please read and select from the below options:
enter *1* to get live score for an ongoing match,
enter *2* to get sull score updates for an ongoing match,
enter *3* to get complete match information for an ongoing match.
""")
    return (str(msg))

    # if(status=="first"):
    #     msg=msg=MessagingResponse()
    if (msg_text == "1"):
        c = Cricbuzz()
        matches = c.matches()
        match_data = []
        for match in matches:
            if match["srs"] == "Indian Premier League 2020" and not (
                    match["mchstate"] == "preview"):
                match_data.append(match)
        if (len(match_data) == 1):
            match_id = match_data[0]["id"]
        livescore = c.livescore(mid=match_id)
        batting_team = livescore["batting"]["team"]
        batting_inn = livescore["batting"]["score"][0]["inning_num"]
        batting_score = livescore["batting"]["score"][0]["runs"]
        battig_overs = livescore["batting"]["score"][0]["overs"]
        batting_wickets = livescore["batting"]["score"][0]["wickets"]
        livescore = f"""Currently innings no {batting_inn} is going on , {batting_team} is doing the batting.
Cuurent score is {batting_score} runs  at the end of {battig_overs} overs with the loss of {batting_wickets} wickets."""
        resp = msg.message(livescore)
        return (str(msg))
    elif (msg_text == "2"):
        c = Cricbuzz()
        matches = c.matches()
        match_data = []
        for match in matches:
            if match["srs"] == "Indian Premier League 2020" and not (
                    match["mchstate"] == "preview"):
                match_data.append(match)
        if (len(match_data) == 1):
            match_id = match_data[0]["id"]
        fullscore = c.scorecard(mid=match_id)
        resp = msg.message(fullscore)
        return (str(msg))

    elif (msg_text == "3"):
        c = Cricbuzz()
        matches = c.matches()
        match_data = []
        for match in matches:
            if match["srs"] == "Indian Premier League 2020" and not (
                    match["mchstate"] == "preview"):
                match_data.append(match)
        if (len(match_data) == 1):
            match_id = match_data[0]["id"]
        info = c.matchinfo(mid=match_id)
        info = json.dumps(info)
        resp = msg.message(info)
        return (str(msg))
    else:
        resp = msg.message("""Sorry you have entered invalid option.
please read and select from the below options:
enter *1* to get live score for an ongoing match,
enter *2* to get sull score updates for an ongoing match,
enter *3* to get complete match information for an ongoing match.
""")
        return (str(msg))