-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
139 lines (102 loc) · 3.26 KB
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
import os
import time
import discord
from discord.ext import commands
from fpl import get_fixture, SHORT_TEAMS, get_team_fixture, get_live_stats, get_team_details, fpl_team_info
from scorecard import get_score
from ipl import get_ipl_table, get_yester_match_result, get_fixture_ipl
from standings import get_table
from cricket import get_cricket_score
intents = discord.Intents.default()
client = commands.Bot(command_prefix="!", intents=intents)
@client.event
async def on_ready():
print(f"Bot ready")
@client.event
async def on_typing(channel, user, when):
print("Someone typing")
await channel.send("Lekin kyu what's the purpose")
@client.command()
async def hello(ctx):
text = None
with open('README.md', 'r') as op:
text = op.read()
await ctx.send(text.replace('# ', '***'))
@client.command()
async def fplLive(ctx):
try:
await ctx.send(f"```{get_live_stats()}```")
except:
await ctx.send("No live match in progress")
@client.command()
async def iplTable(ctx):
table = get_ipl_table()
await ctx.send(f"```{table}```")
@client.command()
async def iplFixtures(ctx):
table = get_fixture_ipl()
await ctx.send(f"```{table}```")
@client.command()
async def iplLastMatch(ctx):
summary, scoreBoard, maxStatsBatsmen, maxStatsBowler = get_yester_match_result()
await ctx.send(summary+"\n")
await ctx.send(scoreBoard+"\n")
# await ctx.send(maxStatsBatsmen+"\n")
# await ctx.send(maxStatsBowler)
@client.command()
async def cricScore(ctx, *, arg):
try:
await ctx.send(get_cricket_score(arg))
except:
await ctx.send("try passing something else as parameter")
@client.command()
async def fplTeamInfo(ctx, id: int):
# try:
mi, gw, cl, h2h = fpl_team_info(id)
await ctx.send(f"```{mi}```")
await ctx.send(f"```{gw[:1961]}```")
await ctx.send(f"```{gw[1961:]}```")
await ctx.send(f"```{cl}```")
await ctx.send(f"```{h2h}```")
# except:
# await ctx.send("Re-check Team id")
@client.command()
async def fplTeamDetail(ctx, id: int):
try:
await ctx.send(get_team_details(id))
except:
await ctx.send("Re-check Team id")
@client.command()
async def gwFixture(ctx, gw: int = None):
if gw:
await ctx.send(f"```{get_fixture(gw)}```")
else:
await ctx.send(f"```{get_fixture()}```")
@client.command()
async def teamFixture(ctx, team: str, gw: int = 5):
await ctx.send("\n".join(get_team_fixture(team, gw)))
@client.command()
async def getTeams(ctx):
teams = "\n".join(SHORT_TEAMS.values())
await ctx.send(teams)
@client.command()
async def getTable(ctx, *, arg):
try:
await ctx.send(f"```{get_table(arg)}```")
except:
await ctx.send("""
Valid league names :
- epl : English Premier League (England)
- bundesliga : Bundesliga (Germany)
- la-liga : La Liga (Spain)
- serie a : Serie A (Italy)
- efl : EFL Championship (England Tier 2)
- isl : Indian Super League (India)
""")
@client.command()
async def liveScore(ctx, *, arg):
try:
await ctx.send(get_score(arg))
except:
await ctx.send(f"No match in progress for {arg}.\nTry adding Football club if you are sure there is an ongoing match.")
client.run(os.environ.get('DISCORD_TOKEN'))