Skip to content

Commit

Permalink
board member -> cabinet; update_data -> set_points;
Browse files Browse the repository at this point in the history
  • Loading branch information
vishalnandagopal committed Jan 14, 2024
1 parent e197020 commit d83f7e3
Show file tree
Hide file tree
Showing 5 changed files with 93 additions and 13 deletions.
1 change: 0 additions & 1 deletion .github/workflows/deployment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,3 @@ jobs:
docker build -t ${{ github.event.repository.owner.name }}/${{ github.event.repository.name }}:${{ env.COMMIT_SHORT_SHA }} --quiet .
docker run --detach --name ${{ github.event.repository.name }}-deploy ${{ github.event.repository.owner.name }}/${{ github.event.repository.name }}:${{ env.COMMIT_SHORT_SHA }}
docker container prune --force && docker image prune --all --force
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM python:3.11.7-slim AS requirements-image
FROM python:3.11-slim AS requirements-image

ENV PYTHONUNBUFFERED=1

Expand All @@ -12,7 +12,7 @@ COPY pyproject.toml poetry.lock ./

RUN ["poetry","export","--format","requirements.txt","--output","requirements.txt"]

FROM python:3.11.7-slim AS runtime-image
FROM python:3.11-slim AS runtime-image

LABEL description="CYSCOM VIT's discord bot"

Expand Down
31 changes: 22 additions & 9 deletions bot.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
from distutils.command.check import check
from os import environ, getenv, listdir
from os.path import dirname
from requests import get as requests_get

import discord
import requests
from discord.ext import commands
from dotenv import load_dotenv
from firebase_admin import credentials, db, initialize_app
Expand Down Expand Up @@ -104,7 +104,7 @@ async def ping(ctx):
async def doge(ctx):
"""Return a doge pic"""
try:
doge_pic_url = requests.get(
doge_pic_url = requests_get(
"https://shibe.online/api/shibes?count=1&urls=true"
).json()[0]
await ctx.send(doge_pic_url)
Expand All @@ -121,7 +121,7 @@ async def sum(ctx, numOne: int, numTwo: int):


@bot.command()
@commands.has_any_role("Board Member")
@commands.has_any_role("Cabinet Member")
async def add_data(ctx, name: str, rating: int = 0, contributions: int = 0):
f"""Add data to the leaderboard. Call it by {command_prefix} add_data "name" rating contribution"""
try:
Expand Down Expand Up @@ -172,7 +172,7 @@ async def add_data(ctx, name: str, rating: int = 0, contributions: int = 0):


@bot.command()
@commands.has_any_role("Board Member")
@commands.has_any_role("Cabinet Member")
async def add_recruits(ctx):
f"""Add recruits by reading a members.txt file present in the same folder"""
# Place file in discord-bot folder.
Expand All @@ -199,8 +199,8 @@ async def add_recruits(ctx):


@bot.command()
@commands.has_any_role("Board Member")
async def update_data(ctx, name: str, rating=0, contributions=0):
@commands.has_any_role("Cabinet Member")
async def set_points(ctx, name: str, rating=0, contributions=0):
try:
data = leaderboard_ref.get()
name = name.strip()
Expand Down Expand Up @@ -238,7 +238,7 @@ async def update_data(ctx, name: str, rating=0, contributions=0):


@bot.command()
@commands.has_any_role("Member", "Board Member")
@commands.has_any_role("Member", "Cabinet Member")
async def fetch_data(ctx, name):
"""Fetch data from the leaderboard"""
try:
Expand All @@ -260,7 +260,7 @@ async def fetch_data(ctx, name):


@bot.command()
@commands.has_any_role("Board Member")
@commands.has_any_role("Cabinet Member")
async def delete_data(ctx, name):
"""Delete someone from the leaderboard"""
try:
Expand All @@ -278,7 +278,7 @@ async def delete_data(ctx, name):


@bot.command()
@commands.has_any_role("Leaderboard", "Board Member")
@commands.has_any_role("Leaderboard", "Cabinet Member")
async def contribution(ctx, name, task):
"""Add contribution to a member"""
try:
Expand Down Expand Up @@ -405,4 +405,17 @@ async def on_message(message):
await bot.process_commands(message)


def add_members_to_act(
act_num: int,
member_names: list[str],
discord_roles: list[str],
add_roles_to_discord: bool = False,
):
...


def fetch_spreadsheet(speadsheet_id: str):
...


bot.run(getenv("BOT_TOKEN"))
69 changes: 68 additions & 1 deletion poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ python = "^3.11.6"
firebase-admin = "^6.2.0"
discord-py = "^2.3.2"
python-dotenv = "^1.0.0"
gspread = "^5.12.4"


[build-system]
Expand Down

0 comments on commit d83f7e3

Please sign in to comment.