Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#example of ignoring .git and python cache folder
.git
__pycache__
.vscode
.vscode
2 changes: 1 addition & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
"files.associations": {
"*.env*": "properties"
},
}
}
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
SOFTWARE.
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# PyRVA Bots
This is the PyRVA bot used in the pyrva discord server.
This is the PyRVA bot used in the pyrva discord server.

Join the server here: https://discord.gg/PThzSm3n

## Cogs
| COG | Description | Status | Owner |
| COG | Description | Status | Owner |
|-----|-------------|--------|-------|
| fun | show some examples and general fun stuff | On-Going | Richard |
| utilities | these are some practical utilites that are helpful | On-Going | Richard |
Expand Down Expand Up @@ -37,7 +37,7 @@ Join the server here: https://discord.gg/PThzSm3n
- [X] create a list of who is present in meeting
- [ ] create tool that automatically assigns a given badge based on presence

> 💡If someone can think of a way to write unit tests / pytests to test things like the raffle cog in particular I am all ears. My best case solution is to setup a Dev/Prod dynamic for testing but that feels like more work than its worth.
> 💡If someone can think of a way to write unit tests / pytests to test things like the raffle cog in particular I am all ears. My best case solution is to setup a Dev/Prod dynamic for testing but that feels like more work than its worth.

## Deployment:

Expand All @@ -46,7 +46,7 @@ fire and forget:
sudo docker-compose up -d
```

if you want to use the docker-compose during development be sure to destroy/increment the image or the docker-compose will just use the same image over and over.
if you want to use the docker-compose during development be sure to destroy/increment the image or the docker-compose will just use the same image over and over.
```
sudo docker-compose down --rmi all
```
Expand All @@ -56,7 +56,7 @@ sudo docker-compose down --rmi all
---
# RSB Notes

## Special Thanks go to:
## Special Thanks go to:
- https://github.com/Crambin/Orderbot
- https://github.com/Xarlos89/ZorakBot
## Helpful Docs:
Expand Down
2 changes: 1 addition & 1 deletion docs/00_simple_examples/command_example/.env-sample
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# .env
DISCORD_TOKEN={your-bot-token}

target_channel_id = 984475649521639434 # bot-playground
target_channel_id = 984475649521639434 # bot-playground
3 changes: 2 additions & 1 deletion docs/00_simple_examples/slash_cogs/Simple.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ def __init__(self, bot):
@commands.slash_command(description="ping -> pong")
async def ping(self, ctx: discord.ApplicationContext):
await ctx.respond("pong!")

@commands.slash_command(description="Say something and the bot will respond!")
@option(
name="text",
Expand All @@ -21,5 +21,6 @@ async def ping(self, ctx: discord.ApplicationContext):
async def say_something(self, ctx: discord.ApplicationContext, text: str):
await ctx.respond(f"You said '{text}'!")


def setup(bot):
bot.add_cog(Simple(bot))
17 changes: 13 additions & 4 deletions docs/00_simple_examples/slash_cogs/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import discord
from dotenv import load_dotenv
from discord.commands import SlashCommandGroup

load_dotenv()


Expand All @@ -21,6 +22,7 @@
# With discord.Bot you can use @bot.command as an alias
# of @bot.slash_command but this is overridden by commands.Bot.


@bot.slash_command() # Create a slash command
async def hello(ctx: discord.ApplicationContext):
"""Say hello to the bot""" # The command description can be supplied as the docstring
Expand All @@ -31,20 +33,27 @@ async def hello(ctx: discord.ApplicationContext):


@bot.slash_command(name="hi")
async def global_command(ctx: discord.ApplicationContext, num: int): # Takes one integer parameter
async def global_command(
ctx: discord.ApplicationContext, num: int
): # Takes one integer parameter
await ctx.respond(f"This is a global command, {num}!")


@bot.slash_command()
@discord.default_permissions(
administrator=True,
) # Only members with this permission can use this command.
async def admin_only(ctx: discord.ApplicationContext):
await ctx.respond(f"Hello {ctx.author}, you are an administrator.")

util = SlashCommandGroup("util", "utility commands")

util = SlashCommandGroup("util", "utility commands")


@util.command()
async def ping(ctx: discord.ApplicationContext):
await ctx.respond('pong!')

await ctx.respond("pong!")


# To learn how to add descriptions and choices to options, check slash_options.py
bot.run(os.getenv("DISCORD_TOKEN"))
18 changes: 11 additions & 7 deletions docs/00_simple_examples/test_connect/bot.py
Original file line number Diff line number Diff line change
@@ -1,26 +1,30 @@
# bot.py
import logging
import os

import discord
from dotenv import load_dotenv

load_dotenv()
TOKEN = os.getenv('DISCORD_TOKEN')
TOKEN = os.getenv("DISCORD_TOKEN")

# https://discordpy.readthedocs.io/en/stable/logging.html
import logging

logger = logging.getLogger('discord')
logger = logging.getLogger("discord")
logger.setLevel(logging.DEBUG)
handler = logging.FileHandler(filename='discord.log', encoding='utf-8', mode='w')
handler.setFormatter(logging.Formatter('%(asctime)s:%(levelname)s:%(name)s: %(message)s'))
handler = logging.FileHandler(filename="discord.log", encoding="utf-8", mode="w")
handler.setFormatter(
logging.Formatter("%(asctime)s:%(levelname)s:%(name)s: %(message)s")
)
logger.addHandler(handler)

client = discord.Client()


@client.event
async def on_ready():
print(f'{client.user} has connected to Discord!')
print(f"{client.user} has connected to Discord!")


if __name__ == "__main__":
client.run(TOKEN)
client.run(TOKEN)
7 changes: 3 additions & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ dependencies = []

[tool.ruff]
# Enable Pyflakes `E` and `F` codes by default.
select = ["E", "F"]
ignore = ["E501"]
select = ["ALL"]
ignore = ['ANN', 'D103', 'PTH', 'T20', 'D']

# Allow autofix for all enabled rules (when `--fix`) is provided.
fixable = ["B", "C", "D", "E", "F", "W", "COM"]
fixable = ["ALL"]
unfixable = []

# Exclude a variety of commonly ignored directories.
Expand Down Expand Up @@ -46,7 +46,6 @@ line-length = 88
# Allow unused variables when underscore-prefixed.
dummy-variable-rgx = "^(_+|(_+[a-zA-Z0-9_]*[a-zA-Z0-9]+?))$"

# Assume Python 3.10.
target-version = "py311"

[tool.ruff.mccabe]
Expand Down
2 changes: 1 addition & 1 deletion src/cogs/fun/futurama.json
Original file line number Diff line number Diff line change
Expand Up @@ -344,4 +344,4 @@
"Bender: Life is hilariously cruel.",
"Bender: I mean, being a robot's great, but we don't have emotions, and sometimes that makes me very sad. [ Sniffles ]",
"Bender: My Story Is A Lot Like Yours, Only More Interesting 'Cause It Involves Robots."
]
]
2 changes: 1 addition & 1 deletion src/cogs/fun/zen_of_python.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@ Now is better than never.
Although never is often better than *right* now.
If the implementation is hard to explain, it's a bad idea.
If the implementation is easy to explain, it may be a good idea.
Namespaces are one honking great idea -- let's do more of those!
Namespaces are one honking great idea -- let's do more of those!
2 changes: 1 addition & 1 deletion src/cogs/meetup/eventList.json

Large diffs are not rendered by default.

13 changes: 8 additions & 5 deletions src/cogs/meetup/meetup_rest_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,10 @@ def _get_upcoming():
print("well where'd you leave it ya dingus?")
old_list = open(f"{filepath}", "w+")

ignore_list = ["Monthly online lecture night", "Monthly Coding Night (ONLINE!!!)"] #TODO: might want to parameterize this
ignore_list = [
"Monthly online lecture night",
"Monthly Coding Night (ONLINE!!!)",
] # TODO: might want to parameterize this

# compare old and new list
if new_list != old_list:
Expand All @@ -44,11 +47,11 @@ def _get_upcoming():
with open(f"{filename}", "w") as f:
json.dump(new_list, f)


#TODO select the events worth posting to discord and return only them
# TODO select the events worth posting to discord and return only them
## Check the channel for Id's / keys of events already posted?

return event_info
return event_info


def _get_next():
response = r.get(_url("events"))
Expand All @@ -58,6 +61,6 @@ def _get_next():


if __name__ == "__main__":
#_get_upcoming()
# _get_upcoming()

print(_get_next())