-
Notifications
You must be signed in to change notification settings - Fork 0
/
Heckwig.py
54 lines (42 loc) · 1.49 KB
/
Heckwig.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
import base64
import base32
import binascii
import codecs
import discord
from discord.ext import commands
bot = commands.Bot(command_prefix='!')
# use the CTFTime API to get a list of upcoming CTF competitions
def get_upcoming_ctfs():
# use the CTFTime API to search for a team and get their ranking information
def get_team_ranking(team):
def convert_string(string, encoding):
if encoding == 'base64':
return base64.b64decode(string)
elif encoding == 'base32':
return base32.b32decode(string)
elif encoding == 'binary':
return binascii.unhexlify(string)
elif encoding == 'rot13':
return codecs.decode(string, 'rot_13')
elif encoding == 'rot47':
return codecs.decode(string, 'rot_47')
else:
return string
@bot.command()
async def ctfnotify(ctx, level: str):
user = ctx.message.author
upcoming_ctfs = get_upcoming_ctfs()
if level:
upcoming_ctfs = [ctf for ctf in upcoming_ctfs if ctf.level == level]
await user.send('Here are the upcoming CTFs that match your interests:')
for ctf in upcoming_ctfs:
await user.send(f'- {ctf.name} ({ctf.date}) - {ctf.url}')
@bot.command()
async def ctfranking(ctx, team: str):
user = ctx.message.author
ranking = get_team_ranking(team)
await user.send(f'Here is the ranking information for the {team} team:')
await user.send(f'Overall Rank: {ranking.overall_rank}')
await user.send(f'Points: {ranking.points}')
await user.send(f'Number of CTFs: {ranking.num_ctfs}')
bot.run('YOUR_BOT_TOKEN_HERE')