Skip to content

Commit

Permalink
Release v1.1.0 (#16)
Browse files Browse the repository at this point in the history
* added github workflow to build docker images on PR file

- added `.github` folder and `workflow` folder to house github actions
- setup workflow to build docker image for jainy_bot with date

* added github action for building and publishing jobs

- added workflow for publishing tagged docker images
- added workflow for testing builds with git commit hash (short variant)

* changing secrets path to see if path was wrong

- removed secret name and used env var defined in secret instead

* changing secrets path to see if path was wrong

- added back secret name and used env var defined in secret instead

* changing secrets path to see if path was wrong

- removed secret name, and in github settings made each secret separate input

* added new bot command to track uptime and tidied up some code (#5)

- fixed type hint for ctx in borb.py
- added new uptime class cog
- updated commands package __init__.py to include cogs list for use in auto registration with bot.py
- updated bot.py to auto register cogs

* added new github action to handle tagging (#6)

- added github-tag-action to handle tagging version
- removed env declaration and tag variable

* Create LICENSE

* added feature request template for issues, and updated LICENSE template with name and copyright year (#7)

- added LICENSE template details
- added git issue template for features

* Adding moderation cog and commands (#8)

* added moderation cog with kick command, added new configuration properties to borb_bot config

- updated commands cog list to include new cog
- added moderation cog with kick command and embed message helper
- updated borb_bot config to include moderator roles and audit channel id

* added ban, unban, clean, invite commands, and added custom exception

- added ban, unban, clean, invite commands to moderation cog
- updated doc strings
- added helper functions to make embed messages for auditing
- created custom exception for when user unauthorized to use command

* refactored clean command to properly purge msg by user and correct amount

- refactored clean command to correctly purge messages by user
- set default limit of 1000 messages to look through
- added bot reply for cleaned messages

* added docstrings, refactored helper functions in to util file to be shared across cogs

- added docstrings to methods and functions
- refactored helpers from moderation cog to util file for shared use

* General Cleanup (#9)

* tidied up code to match return signatures and doc strings

- updated return signatures to match doc string and type hints
- removed unused imports

* tidied up code to match return signatures and doc strings

- updated return signatures to match doc string and type hints
- removed unused imports

* updated configuration and corrected null check

- fixed null check to check for correct env var for MOD_AUDIT_CHANNEL_ID and made moderator_roles into env var

* added changelog with notes on release

* fixed casing on moderator_roles to MODERATOR_ROLES

* updated readme

- updated `.env` file variables

* removed logging.py in favor of env var setup for loguru logger, added more exception handling

- removed logging.py in favor of using loguru environment variables to set the logging level
- updated kick command to check for UserNotFound exception thrown by commands object

* Release/v1.0.0 (#11)

* updated readme

- added loguru env var for setting log level

* fixed small error being thrown when initial bot command msg gets deleted before cleanup

* cleaned up unused variables, and added more logging

- removed unused os.environ from react_roles since var isn't used
- added logging to uptime command

* Bump aiohttp from 3.9.3 to 3.9.4 (#13)

Bumps [aiohttp](https://github.com/aio-libs/aiohttp) from 3.9.3 to 3.9.4.
- [Release notes](https://github.com/aio-libs/aiohttp/releases)
- [Changelog](https://github.com/aio-libs/aiohttp/blob/master/CHANGES.rst)
- [Commits](aio-libs/aiohttp@v3.9.3...v3.9.4)

---
updated-dependencies:
- dependency-name: aiohttp
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Bump idna from 3.6 to 3.7 (#12)

Bumps [idna](https://github.com/kjd/idna) from 3.6 to 3.7.
- [Release notes](https://github.com/kjd/idna/releases)
- [Changelog](https://github.com/kjd/idna/blob/master/HISTORY.rst)
- [Commits](kjd/idna@v3.6...v3.7)

---
updated-dependencies:
- dependency-name: idna
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Dalle Feature (#15)

* updated requirements.txt and added dalle command and config.

- added dalle command to generate random images
- added config file for dalle api communication
- added requests dep for network api calls

* cleaned up dockerfile

- removed env vars since they get defined in compose

* cleaned up moderation py to use audit channel and updated dalle to let user know prompt successful

- dalle command lets user know prompt was received now
- moderation command uses the audit channel in addition to native discord audit of mod commands

---------

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
  • Loading branch information
seekheart and dependabot[bot] authored May 4, 2024
1 parent 500c4c4 commit a3a66bb
Show file tree
Hide file tree
Showing 8 changed files with 80 additions and 16 deletions.
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
# Jainy Bot Changelog

## Version v1.1.0

**Features**

- Added dalle command to generate images via ai

**Dev Deps**

- added requests for api calls

## Version v1.0.0
**Features**
- Moderation commands like kick, ban, unban, etc with audit log posted in a channel (configurable)
Expand Down
4 changes: 0 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,6 @@ COPY requirements.txt .
COPY app.py .
COPY ./jainy_bot ./jainy_bot

ENV DISCORD_BOT_TOKEN=DISCORD_TOKEN_HERE
ENV LOG_LEVEL=LOG_LEVEL_HERE
ENV BOT_GUILD_ID=BOT_GUILD_ID_HERE

RUN pip install -r requirements.txt
RUN rm requirements.txt

Expand Down
1 change: 1 addition & 0 deletions config/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
from .borb_bot import *
from .dalle_api_config import *
6 changes: 6 additions & 0 deletions config/dalle_api_config.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import os

DALLE_API_URL = os.environ.get('DALLE_API_URL')

if not DALLE_API_URL:
raise AttributeError('DALLE_API_URL environment variable not set!')
5 changes: 3 additions & 2 deletions jainy_bot/commands/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
from .borb import *
from .uptime import *
from .dalle import *
from .moderation import *
from .uptime import *

cogs = [Borb, Uptime, Moderation]
cogs = [Borb, Uptime, Moderation, Dalle]

__all__ = [Borb, Uptime, Moderation, cogs]
48 changes: 48 additions & 0 deletions jainy_bot/commands/dalle.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
import base64
from io import BytesIO

import discord
import requests
from discord.ext import commands
from loguru import logger

from config import DALLE_API_URL


class Dalle(commands.Cog, name="Dalle"):
def __init__(self, bot: commands.bot):
self.bot = bot

@commands.command()
async def dalle(self, ctx: commands.Context, prompt: str):
"""Create a Dalle generated image with a prompt"""
logger.info(f"Creating a Dalle image with prompt: {prompt} requested by user {ctx.author}")

payload = {
'prompt': prompt
}

await ctx.send(f'{ctx.author.mention} hang tight I\'m checking with Dall-E')
response = requests.post(DALLE_API_URL, json=payload)

if response.status_code == 200:
logger.info(f"Dalle image created successfully")
await ctx.send(f'{ctx.author.mention} generating image please wait')
data = response.json()
images = data['images']
files = []

for idx, img in enumerate(images):
file_bytes = BytesIO(base64.b64decode(img))
file = discord.File(file_bytes, filename=f"{prompt}_{idx}.jpg")
files.append(file)

await ctx.send(
files=files,
mention_author=True,
embed=discord.Embed(title=f'{prompt} requested by {ctx.author}')
)
else:
logger.error(
f'Error creating a Dalle image with prompt: {prompt} server responded with status = {response.status_code}')
await ctx.send('Could not generate images')
13 changes: 11 additions & 2 deletions jainy_bot/commands/moderation.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import discord
from discord.ext import commands
from loguru import logger

from config import MODERATOR_ROLES
from jainy_bot.exceptions import UnauthorizedUserException
from .util import make_general_card, make_offender_card, send_audit_message, send_reply_message
import discord


class Moderation(commands.Cog, name="Moderation"):
Expand Down Expand Up @@ -160,7 +161,8 @@ async def invite(self, ctx: commands.Context) -> None:
)
except discord.HTTPException or discord.Forbidden as e:
logger.error(e.text)
return ctx.send(f'Unable to create invite link')
await ctx.send(f'Unable to create invite link')
return

await send_reply_message(ctx, f'Invite link created: {invite.url}')
await send_audit_message(guild=ctx.guild, embed=embed)
Expand Down Expand Up @@ -188,4 +190,11 @@ async def clean(self, ctx: commands.Context, user: discord.Member, num_msg: int)
deleted.append(msg)
await msg.delete()

embed = make_general_card(
title=f'{ctx.author.display_name} cleaned up last {num_msg} messages by user = {user.display_name}',
author=ctx.author,
thumbnail_url=ctx.author.avatar.url
)

await send_reply_message(ctx, f'Deleted last {len(deleted)} messages by user = {user.display_name}')
await send_audit_message(guild=ctx.guild, embed=embed)
9 changes: 1 addition & 8 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,10 +1,3 @@
aiohttp==3.9.3
aiosignal==1.3.1
attrs==23.2.0
discord==2.3.2
discord.py==2.3.2
frozenlist==1.4.1
idna==3.6
loguru==0.7.2
multidict==6.0.5
yarl==1.9.4
requests~=2.31.0

0 comments on commit a3a66bb

Please sign in to comment.