Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Spunky Sputniks #9

Open
wants to merge 88 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
88 commits
Select commit Hold shift + click to select a range
6563dbb
Add Code Jam template.
jb3 Jul 9, 2021
d0762d4
Makes Precommit Manager Independent
HassanAbouelela Jul 10, 2021
c04c75f
Adds Project Manager Samples
HassanAbouelela Jul 10, 2021
3d5f617
Merge pull request #2 from python-discord/global-actions
HassanAbouelela Jul 10, 2021
17c5f86
Renames workflow to Lint
onerandomusername Jul 17, 2021
bb83538
Merge pull request #3 from onerandomusername/patch-1
HassanAbouelela Jul 17, 2021
63bbaa0
remove flake8 plugins
shenanigansd Jul 19, 2022
d0c694a
update Python version to 3.10
shenanigansd Jul 19, 2022
4b993de
update flake8 ignores
shenanigansd Jul 19, 2022
1c9a4d0
remove unused flake8 plugins from documentation
shenanigansd Jul 19, 2022
432b93a
remove removed flake8 codes from sample output
shenanigansd Jul 19, 2022
e5d557a
Update lint CI configuration for CJ9
ichard26 Jul 19, 2022
d1c92f6
only run workflow on commit to main branch
shenanigansd Jul 19, 2022
f1e9289
Bump linting tools as Kat suggested
ichard26 Jul 19, 2022
c49d624
Remove D100 from README since we're ignoring it anyway
ichard26 Jul 19, 2022
1ced0aa
Merge pull request #5 from python-discord/update-ci
janine9vn Jul 19, 2022
a926999
Hotfix: bump isort (5.10.1 -> 5.12.0)
ichard26 Aug 28, 2023
3e38115
Replace (and remove) broken images in README
ichard26 Aug 28, 2023
17c8122
Update pre-commit-hooks version
lemonyte Apr 3, 2024
5b70abb
Replace flake8 and isort with ruff
lemonyte Apr 4, 2024
6467281
Update Python version to 3.12
lemonyte Apr 4, 2024
95f2aa4
Update CI github actions
lemonyte Apr 4, 2024
7b0b37c
Clean up comments
lemonyte Apr 4, 2024
057f4d2
Rename LICENSE to LICENSE.txt
lemonyte Jun 25, 2024
bf560ad
Bump dependency versions
lemonyte Jun 25, 2024
a3b49ac
Update README
lemonyte Jun 25, 2024
c45ca52
Ignore redundant docstring lint rule
lemonyte Jun 25, 2024
298dfde
Bump Ruff to v0.5.0
lemonyte Jun 30, 2024
7c1b9c4
Add note about Poetry config
lemonyte Jul 7, 2024
d5fd7be
Merge pull request #8 from lemonyte/update-2024
lemonyte Jul 7, 2024
e9c641c
Initialize Hatch.
ZeroIntensity Jul 18, 2024
b49c131
Add Ruff ignore.
ZeroIntensity Jul 18, 2024
d0e0da1
Use dunder for version and add license.
ZeroIntensity Jul 18, 2024
3169b04
Remove useless dynamic entry.
ZeroIntensity Jul 18, 2024
4b19f8b
Merge pull request #2 from ZeroIntensity/add-hatch
ZeroIntensity Jul 19, 2024
7cb0c00
Add unit testing suite (#6)
ZeroIntensity Jul 19, 2024
7efcce9
CI Hotfix (#10)
ZeroIntensity Jul 20, 2024
53d6272
Database Class (#9)
enskyeing Jul 20, 2024
e7a281a
Setup MkDocs configuration. (#15)
ZeroIntensity Jul 20, 2024
e5ee7f0
Switch login() method to async. (#22)
ZeroIntensity Jul 21, 2024
4260c4a
Support for schemas with Pydantic (#25)
ZeroIntensity Jul 21, 2024
ab7852e
Switch to commands.Bot() instance (#32)
enskyeing Jul 22, 2024
90b47fa
Update build.yml (#35)
ZeroIntensity Jul 22, 2024
6aaea38
Slimmer CI (#36)
ZeroIntensity Jul 22, 2024
49c067b
Sequential Tests (#37)
ZeroIntensity Jul 22, 2024
46d5a8d
Documentation for the current API (#34)
ZeroIntensity Jul 22, 2024
a8ba66c
11 database storage (#42)
Rubiks14 Jul 23, 2024
b0aba0b
Add file for visual slash commands (#27)
Gimpy3887 Jul 23, 2024
a739495
Fix utility slash commands (#45)
Rubiks14 Jul 24, 2024
bb45c80
Replace old implementation of visualization cog (#46)
Gimpy3887 Jul 24, 2024
0f073fa
Delete commands file (#53)
enskyeing Jul 25, 2024
1ac94d4
Table resizing implementation (#51)
ZeroIntensity Jul 26, 2024
ff83c6c
Update documentation for #51. (#58)
ZeroIntensity Jul 26, 2024
5162b47
Implementation of `clean()` method (#61)
ZeroIntensity Jul 26, 2024
0dceca8
Add await to create_invite() (#63)
enskyeing Jul 26, 2024
d36464c
Use timestamp of final message in `_resize_hash` (#65)
Rubiks14 Jul 27, 2024
9e7d129
Hashing implementation (#73)
ZeroIntensity Jul 28, 2024
2949451
Fix docstrings and silence messages (#75)
Rubiks14 Jul 28, 2024
a12caad
Implement the `delete()` method. (#78)
ZeroIntensity Jul 28, 2024
fdd73ec
Add test for `update()` (#79)
Rubiks14 Jul 28, 2024
9167fe0
Partial implementation of caching and structured concurrency (#81)
ZeroIntensity Jul 28, 2024
0a7e3b0
Final(ish) Interface Bot (#82)
enskyeing Jul 28, 2024
a837954
New demobot (#80)
Rubiks14 Jul 28, 2024
0334cc0
Remove usage of free-flying tasks. (#83)
ZeroIntensity Jul 28, 2024
b5f5446
Improve error message for `delete()` on a deleted record. (#85)
ZeroIntensity Jul 28, 2024
41cb641
Add description to `pyproject.toml` (#87)
ZeroIntensity Jul 28, 2024
f1e75d7
Hotfix for cog loading. (#88)
ZeroIntensity Jul 28, 2024
65f1d49
Hotfix for cog loading (again). (#89)
ZeroIntensity Jul 28, 2024
e760467
Use if instead of match. (#90)
ZeroIntensity Jul 28, 2024
c636804
Fix 3.8 support. (#91)
ZeroIntensity Jul 28, 2024
19ea769
Bump the version number. (#92)
ZeroIntensity Jul 28, 2024
f7e787d
Documentation for the Discord interface. (#94)
Gimpy3887 Jul 31, 2024
3d1b59a
Update documentation and add logo to README. (#96)
ZeroIntensity Jul 31, 2024
cd742e3
Fix bold in README and make logo larger. (#97)
ZeroIntensity Jul 31, 2024
64a5144
Discord interface docs re do (#95)
Gimpy3887 Jul 31, 2024
f58633c
Center the README text and enlarge the logo. (#98)
Gimpy3887 Jul 31, 2024
b816fa2
Touch ups for the docs (#99)
ZeroIntensity Jul 31, 2024
254f076
Demonstration Documentation (#100)
Gimpy3887 Aug 1, 2024
e69d2a6
Remove colons from section names. (#101)
ZeroIntensity Aug 1, 2024
fc575e2
Fix docs (#102)
Gimpy3887 Aug 1, 2024
9f39c04
Add the contributions section. (#104)
ZeroIntensity Aug 1, 2024
f568465
Remove the picture tag in the README (#105)
ZeroIntensity Aug 1, 2024
b4b6de0
Add links to GitHub accounts in the contributions section (#106)
ZeroIntensity Aug 1, 2024
1a43c99
Fix last minute typos. (#107)
ZeroIntensity Aug 1, 2024
acd1807
Add spaces around dashes. (#108)
ZeroIntensity Aug 1, 2024
9ae2596
Add the logo to the documentation index. (#109)
ZeroIntensity Aug 1, 2024
e38c275
Last minute typo fix. (#110)
ZeroIntensity Aug 1, 2024
6a23d59
Add 'spunky-sputniks/' from commit 'e38c275f240aabc5a022ec83f48e50d2a…
janine9vn Aug 13, 2024
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
49 changes: 49 additions & 0 deletions spunky-sputniks/.github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
name: Build

on:
push:
tags:
- v*

concurrency:
group: build-${{ github.head_ref }}

jobs:
build:
name: Build wheels and source distribution
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3

- name: Install build dependencies
run: python -m pip install --upgrade build

- name: Build
run: python -m build

- uses: actions/upload-artifact@v3
with:
name: artifacts
path: dist/*
if-no-files-found: error

publish:
name: Publish release
needs:
- build
if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags')
runs-on: ubuntu-latest

steps:
- uses: actions/download-artifact@v3
with:
name: artifacts
path: dist

- name: Push build artifacts to PyPI
uses: pypa/[email protected]
with:
skip_existing: true
user: __token__
password: ${{ secrets.PYPI_API_TOKEN }}
35 changes: 35 additions & 0 deletions spunky-sputniks/.github/workflows/lint.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# GitHub Action workflow enforcing our code style.

name: Lint

# Trigger the workflow on both push (to the main repository, on the main branch)
# and pull requests (against the main repository, but from any repo, from any branch).
on:
push:
branches:
- main
pull_request:

# Brand new concurrency setting! This ensures that not more than one run can be triggered for the same commit.
# It is useful for pull requests coming from the main repository since both triggers will match.
concurrency: lint-${{ github.sha }}

jobs:
lint:
runs-on: ubuntu-latest

env:
# The Python version your project uses. Feel free to change this if required.
PYTHON_VERSION: "3.12"

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Set up Python ${{ env.PYTHON_VERSION }}
uses: actions/setup-python@v5
with:
python-version: ${{ env.PYTHON_VERSION }}

- name: Run pre-commit hooks
uses: pre-commit/[email protected]
41 changes: 41 additions & 0 deletions spunky-sputniks/.github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: Tests

on:
push:
branches:
- main
paths:
- src/discobase/**
pull_request:
branches:
- main
paths:
- src/discobase/**

concurrency:
group: test-${{ github.head_ref }}
cancel-in-progress: true

env:
PYTHONUNBUFFERED: "1"
FORCE_COLOR: "1"
TEST_BOT_TOKEN: ${{ secrets.TEST_BOT_TOKEN }}

jobs:
run-container-matrix:
name: Test matrix on Linux
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3

- name: Set up Python 3.12
uses: actions/setup-python@v4
with:
python-version: "3.12"

- name: Install Hatch
run: pip install --upgrade hatch

- name: Run tests in matrix
run: hatch test --all
35 changes: 35 additions & 0 deletions spunky-sputniks/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# Files generated by the interpreter
__pycache__/
*.py[cod]

# Environment specific
.venv
venv
.env
env

# Unittest reports
.coverage*

# Logs
*.log

# PyEnv version selector
.python-version

# Built objects
*.so
dist/
build/

# IDEs
# PyCharm
.idea/
# VSCode
.vscode/
# MacOS
.DS_Store

# Builds
dist/
test.py
23 changes: 23 additions & 0 deletions spunky-sputniks/.pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Pre-commit configuration.
# See https://github.com/python-discord/code-jam-template/tree/main#pre-commit-run-linting-before-committing

repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.6.0
hooks:
- id: check-toml
- id: check-yaml
- id: end-of-file-fixer
- id: trailing-whitespace
args: [--markdown-linebreak-ext=md]

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.5.3
hooks:
- id: ruff

- repo: https://github.com/pycqa/isort
rev: 5.13.2
hooks:
- id: isort
name: isort (python)
7 changes: 7 additions & 0 deletions spunky-sputniks/LICENSE.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Copyright 2021 Python Discord

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 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.
57 changes: 57 additions & 0 deletions spunky-sputniks/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
<div align="center">
<img alt="discobase logo" src="https://raw.githubusercontent.com/ZeroIntensity/discobase/main/docs/assets/discobase_blurple.png" width=500>
<br><br>
<div align="center"><strong>Python Discord Codejam 2024 Submission: Spunky Sputniks</strong></div>
</div>
<br>

## Installation

### Library

```bash
$ pip install discobase
```

### Demo Bot

You can add the demo bot to a server with [this integration](https://discord.com/oauth2/authorize?client_id=1268247436699238542&permissions=8&integration_type=0&scope=bot), or self-host it using the following commands:

```bash
$ git clone https://github.com/zerointensity/discobase
$ cd discobase/src/demo
$ export DB_BOT_TOKEN="first bot token"
$ export BOOKMARK_BOT_TOKEN="second bot token"
$ python3 main.py
```

## Quickstart

```py
import asyncio
import discobase

db = discobase.Database("My database")

@db.table
class User(discobase.Table):
name: str
password: str

async def main():
async with db.conn("My bot token"):
admin = await User.find(name="admin")
if not admin:
User.save(name="admin", password="admin")

if __name__ == "__main__":
asyncio.run(main())
```

## Documentation

Documentation is available [here](https://discobase.zintensity.dev).

## License

`discobase` is distributed under the `MIT` license.
Binary file added spunky-sputniks/docs/assets/column_cmd.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added spunky-sputniks/docs/assets/delete_cmd.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added spunky-sputniks/docs/assets/demo_bot.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added spunky-sputniks/docs/assets/discobase_white.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added spunky-sputniks/docs/assets/find_cmd.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added spunky-sputniks/docs/assets/insert_cmd.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added spunky-sputniks/docs/assets/reset_cmd.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added spunky-sputniks/docs/assets/schema_cmd.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added spunky-sputniks/docs/assets/table_cmd.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added spunky-sputniks/docs/assets/tablestats_cmd.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added spunky-sputniks/docs/assets/update_cmd.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
20 changes: 20 additions & 0 deletions spunky-sputniks/docs/demonstration.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
---
hide:
- navigation
---

# Demonstration

Now, we know that Discobase's main functionality is just a database for storing data: we're allowing developers to access this "database" to make their own applications.

Quotes are applied around the term database because, as mentioned earlier, the database is actually a Discord server created by the user (or by the Discobase bot in many cases), making Discobase the intermediary to couple this connection.

If we look at the scenairo below, a developer&mdash;from our team&mdash;has programmed a message bookmarking bot that uses the Discord context menu feature `App -> Bookmark` to store away the message onto the database.

![demo_bot](assets/demo_bot.gif)

This bot doesn't use any other database &mdash; no SQL, no MongoDB, nothing! Just our very own library, which stores it on a Discord server.

After storing away our pertinent message to the database, we can use a slash command as per the developer's generous design to get all the bookmarks we've stored away.

If you want to try this for yourself, you can [invite the bookmark bot](https://discord.com/oauth2/authorize?client_id=1268247436699238542&permissions=8&integration_type=0&scope=bot) to your server.
Loading