-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathdiscord_bot.py
57 lines (46 loc) · 1.63 KB
/
discord_bot.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
import asyncio
import os
import discord
import discord.ext.commands
import discord.ext.tasks
import dotenv
dotenv.load_dotenv()
DISCORD_TOKEN = os.getenv('DISCORD_TOKEN')
CHANNEL_ID = int(os.getenv('CHANNEL_ID'))
bot = discord.ext.commands.Bot(command_prefix='fuzz ', intents=discord.Intents.all())
@bot.command()
async def ping(ctx):
await ctx.send('pong')
@discord.ext.tasks.loop(hours=24 * 14)
async def cron():
channel = bot.get_channel(CHANNEL_ID)
fuzzing = await asyncio.create_subprocess_shell('bash run.sh develop')
await fuzzing.wait()
message = await asyncio.create_subprocess_shell(
'cd deps/ckb-vm && git log -1 --pretty=\'%s\'',
stdout=asyncio.subprocess.PIPE,
stderr=asyncio.subprocess.STDOUT
)
message = await message.communicate()
message = message[0].decode()
if fuzzing.returncode == 0:
await channel.send('Develop branch passed' + '\n* ' + message)
else:
await channel.send('Develop branch failed' + '\n* ' + message)
fuzzing = await asyncio.create_subprocess_shell('bash run.sh release-0.24')
await fuzzing.wait()
message = await asyncio.create_subprocess_shell(
'cd deps/ckb-vm && git log -1 --pretty=\'%s\'',
stdout=asyncio.subprocess.PIPE,
stderr=asyncio.subprocess.STDOUT
)
message = await message.communicate()
message = message[0].decode()
if fuzzing.returncode == 0:
await channel.send('Release branch passed' + '\n* ' + message)
else:
await channel.send('Release branch failed' + '\n* ' + message)
@bot.listen()
async def on_ready():
cron.start()
bot.run(DISCORD_TOKEN)