Skip to content

Commit

Permalink
Discord bot (#9)
Browse files Browse the repository at this point in the history
  • Loading branch information
mohanson authored Jan 30, 2024
1 parent b962d9a commit 49f034b
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,5 @@ Cargo.lock
# MSVC Windows builds of rustc generate these, which store debugging information
*.pdb

.env
deps/ckb-vm
57 changes: 57 additions & 0 deletions discord_bot.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,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)

0 comments on commit 49f034b

Please sign in to comment.