-
Notifications
You must be signed in to change notification settings - Fork 0
/
discord_decode_binary.py
66 lines (55 loc) · 1.76 KB
/
discord_decode_binary.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
"""
CSEC 791 MS Project
Grace Lombardi
Discord Covert Channel
Decode Binary
"""
import re
import discord
from discord.ext import commands
import discord_config
intents = discord.Intents.default()
intents.message_content = True
client = commands.Bot(command_prefix='!', intents=intents)
@client.event
async def on_ready():
"""
Returns a message when there is a successful connection.
"""
print('We have logged in as {0.user}'.format(client))
@client.event
async def on_message(message):
"""
Waits for a message that says "history" then checks for thumbs up or thumbs down and decodes
the message.
"""
history = []
if message.author == client.user:
return
if message.content.startswith('history'):
channel = discord.utils.get(message.guild.text_channels, name="general")
messages = channel.history(limit=500)
async for message in messages:
if not message.attachments:
thumbsup = [x for x in message.reactions if
str(x.emoji) == '👍'] # replace the emoji with the one you want
thumbsdown = [x for x in message.reactions if
str(x.emoji) == '👎'] # replace the emoji with the one you want
if thumbsup:
history.append('1')
if thumbsdown:
history.append('0')
mes = []
binary = ''.join(history)
history = re.findall('........', binary)
for i in history:
mes.append(chr(int(i, 2)))
decoded_message = ''.join(mes)
print("Message Successfully Decoded: ", decoded_message)
def main():
"""
This is the main decoding function.
"""
client.run(discord_config.token)
if __name__ == '__main__':
main()