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

Version 0.2.0 #147

Open
wants to merge 145 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
Commits
Show all changes
145 commits
Select commit Hold shift + click to select a range
1107a6a
token move env
iach526526 Aug 27, 2024
03095c5
api in class
iach526526 Aug 27, 2024
58da1a4
do not use! chore: Refactor API class and handle errors in get_user m…
iach526526 Aug 27, 2024
d3ff30c
resolve conflict ->force push
iach526526 Aug 28, 2024
41af296
Format "resolve conflict ->force push" using Black
github-actions[bot] Aug 28, 2024
2a3bce4
recover api change
iach526526 Aug 28, 2024
3dc904a
Merge branch
iach526526 Aug 28, 2024
e7d2c87
Format "Merge branch" using Black
github-actions[bot] Aug 28, 2024
901e7a5
chore: Update Discord API endpoint for checking user membership in guild
iach526526 Aug 28, 2024
9233c52
Merge branch development from GitHub action
iach526526 Aug 28, 2024
291c285
Format "Merge branch development from GitHub action" using Black
github-actions[bot] Aug 28, 2024
82b070b
chore: Update Discord API
iach526526 Aug 28, 2024
dc03bf5
Format "chore: Update Discord API" using Black
github-actions[bot] Aug 28, 2024
ea5161b
feat: Add new Gift class for sending gifts via Discord API
iach526526 Aug 28, 2024
0c686f6
Merge branch into development
iach526526 Aug 28, 2024
cafaa82
Format "Merge branch into development" using Black
github-actions[bot] Aug 28, 2024
5a23a76
feat: Add gift_type and gift_amount parameters to send() function(not…
iach526526 Aug 28, 2024
f981ff3
Format "feat: Add gift_type and gift_amount parameters to send() func…
github-actions[bot] Aug 28, 2024
9522153
Add Merge CI
winstonsung Aug 28, 2024
4faede0
Fix Black CI
winstonsung Aug 28, 2024
1eca025
Fix lint issues
winstonsung Aug 28, 2024
ecff220
Introduce maintenance scripts
winstonsung Aug 28, 2024
64f3014
Packaging: Move to src/
winstonsung Aug 28, 2024
5c79deb
Merge branch main into development
winstonsung Aug 28, 2024
76c8a8f
Add build/lib/ to .gitignore
winstonsung Aug 28, 2024
1666a6f
Update Black CI
winstonsung Aug 28, 2024
9995f0b
Bump idna from 3.7 to 3.8
dependabot[bot] Aug 28, 2024
e86e0ef
Add support for system messages
winstonsung Aug 13, 2024
4f6062e
now :gift command :MySQL server has gone away. flask is ok
iach526526 Aug 29, 2024
9f84b73
send gift ok and oop reload
iach526526 Aug 29, 2024
28e949b
Fix Black CI
winstonsung Aug 30, 2024
b49e5ac
Format "Fix Black CI" using Black
github-actions[bot] Aug 30, 2024
cb243f7
Fix Black CI
winstonsung Aug 30, 2024
3416f96
Fix lint issues
winstonsung Aug 30, 2024
8be7454
Bump yarl from 1.9.4 to 1.9.7
dependabot[bot] Sep 2, 2024
3583070
Bump certifi from 2024.7.4 to 2024.8.30
dependabot[bot] Sep 2, 2024
e74365b
Bump pylint from 3.2.6 to 3.2.7
dependabot[bot] Sep 2, 2024
6369070
Bump yarl from 1.9.7 to 1.9.10
dependabot[bot] Sep 5, 2024
19e87d3
Bump platformdirs from 4.2.2 to 4.3.2
dependabot[bot] Sep 9, 2024
559d50f
Bump yarl from 1.9.10 to 1.11.0
dependabot[bot] Sep 9, 2024
417319c
Bump multidict from 6.0.5 to 6.1.0
dependabot[bot] Sep 10, 2024
10fa7e9
Bump yarl from 1.11.0 to 1.11.1
dependabot[bot] Sep 10, 2024
3d5ce91
Bump pytest from 8.3.2 to 8.3.3
dependabot[bot] Sep 11, 2024
101280e
Add draft of RELEASE-NOTES-0.1
winstonsung Sep 11, 2024
53af08f
Complete release notes for 0.1.0
winstonsung Sep 11, 2024
a9474ec
Added draft of release notes for 0.1.1
winstonsung Sep 11, 2024
df05ba9
Bump urllib3 from 2.2.2 to 2.2.3
dependabot[bot] Sep 13, 2024
bef06d8
Bump idna from 3.8 to 3.10
dependabot[bot] Sep 16, 2024
d30362e
Bump py-cord from 2.6.0 to 2.6.1
dependabot[bot] Sep 16, 2024
fef4eef
Bump platformdirs from 4.3.2 to 4.3.3
dependabot[bot] Sep 16, 2024
b15750b
Bump platformdirs from 4.3.3 to 4.3.6
dependabot[bot] Sep 18, 2024
11302f7
Fix README formatting
winstonsung Sep 20, 2024
d38a290
docs: Update database schema
winstonsung Sep 20, 2024
fa775bc
docs: Create tables_diagram_layout.json
winstonsung Sep 20, 2024
61d225b
docs: Add database_layout.html
winstonsung Sep 20, 2024
2ae86dc
docs: Update database_layout.html
winstonsung Sep 21, 2024
aec6521
docs: Update README
winstonsung Sep 21, 2024
aedb576
Bump pylint from 3.2.7 to 3.3.0, astroid from 3.2.4 to 3.3.3
dependabot[bot] Sep 23, 2024
04782b5
Disable Pylint too-many-positional-arguments for slash_command
winstonsung Sep 23, 2024
a372437
Bump yarl from 1.11.1 to 1.12.1
dependabot[bot] Sep 24, 2024
b1507d9
Bump astroid from 3.3.3 to 3.3.4
dependabot[bot] Sep 24, 2024
8ba6ced
Bump pylint from 3.3.0 to 3.3.1
dependabot[bot] Sep 25, 2024
206276c
Bump aiohttp from 3.10.5 to 3.10.6
dependabot[bot] Sep 25, 2024
f361717
Packaging: Prepare src layout migration
winstonsung Sep 25, 2024
6ac0961
docs: Update RELEASE-NOTES-0.1
winstonsung Sep 25, 2024
84f9b23
Bump aiohappyeyeballs from 2.4.0 to 2.4.2
dependabot[bot] Sep 27, 2024
6b179fb
Bump yarl from 1.12.1 to 1.13.0
dependabot[bot] Sep 27, 2024
3755a08
Bump dill from 0.3.8 to 0.3.9
dependabot[bot] Sep 30, 2024
475bebf
Bump aiohttp from 3.10.6 to 3.10.8
dependabot[bot] Sep 30, 2024
3fe9a15
Bump yarl from 1.13.0 to 1.13.1
dependabot[bot] Sep 30, 2024
6bebb6e
Bump aiohappyeyeballs from 2.4.2 to 2.4.3
dependabot[bot] Oct 6, 2024
cad7850
Bump astroid from 3.3.4 to 3.3.5
dependabot[bot] Oct 7, 2024
6b42493
Bump aiohttp from 3.10.8 to 3.10.9
dependabot[bot] Oct 7, 2024
0403762
Packaging: Prepare src layout migration
winstonsung Oct 7, 2024
1fce2e4
i18n: Add course system messages
winstonsung Oct 7, 2024
f4c5f69
Fix typo: "SCAICT Store" instead of "SCAICT Shop"
winstonsung Oct 7, 2024
cf7fd07
i18n: Add @metadata.authors to course messages
winstonsung Oct 7, 2024
fcada00
Bump black from 24.8.0 to 24.10.0
dependabot[bot] Oct 8, 2024
fd6247e
Bump markupsafe from 2.1.5 to 3.0.0
dependabot[bot] Oct 8, 2024
ebbe9ad
Complete release notes for 0.1.1
winstonsung Oct 8, 2024
9a99211
fix: style, typo (including code strings)
YuevUwU Oct 8, 2024
cd7ee64
fix: avoid case sensibility of environment variable
YuevUwU Oct 8, 2024
189878e
Bump yarl from 1.13.1 to 1.14.0
dependabot[bot] Oct 9, 2024
e5c03eb
Bump markupsafe from 3.0.0 to 3.0.1
dependabot[bot] Oct 9, 2024
d1d5bd2
Update CONTRIBUTING, .env.example
winstonsung Oct 9, 2024
397b979
Fix Merge CI
winstonsung Oct 9, 2024
63074ed
Bump charset-normalizer from 3.3.2 to 3.4.0
dependabot[bot] Oct 10, 2024
374acf5
Bump aiohttp from 3.10.9 to 3.10.10
dependabot[bot] Oct 11, 2024
efe0f48
Bump yarl from 1.14.0 to 1.15.2
dependabot[bot] Oct 14, 2024
c72e441
Bump markupsafe from 3.0.1 to 3.0.2
dependabot[bot] Oct 24, 2024
b45e042
Bump yarl from 1.15.2 to 1.16.0
dependabot[bot] Oct 24, 2024
75b177e
Bump frozenlist from 1.4.1 to 1.5.0
dependabot[bot] Oct 24, 2024
578f734
Bump werkzeug from 3.0.4 to 3.0.6
dependabot[bot] Oct 29, 2024
4252d0f
Bump yarl from 1.16.0 to 1.17.0
dependabot[bot] Oct 29, 2024
e3642ef
Bump mysql-connector-python from 8.4.0 to 9.1.0
dependabot[bot] Nov 2, 2024
8fca4b2
Bump yarl from 1.17.0 to 1.17.1
dependabot[bot] Nov 2, 2024
15cdfc3
Bump werkzeug from 3.0.6 to 3.1.1
dependabot[bot] Nov 2, 2024
c4281ab
Bump packaging from 24.1 to 24.2
dependabot[bot] Nov 20, 2024
42553e2
Bump blinker from 1.8.2 to 1.9.0
dependabot[bot] Nov 20, 2024
5ce1879
Bump werkzeug from 3.1.1 to 3.1.3
dependabot[bot] Nov 20, 2024
ef8c0a8
Bump flask from 3.0.3 to 3.1.0
dependabot[bot] Nov 20, 2024
45801f3
Bump yarl from 1.17.1 to 1.17.2
dependabot[bot] Nov 20, 2024
691d140
Bump aiohttp from 3.10.10 to 3.11.6
dependabot[bot] Nov 20, 2024
4d463b9
fix: Unmatched name of GITHUB_DISCORD_REDIRECT_URI and order
YuevUwU Nov 20, 2024
752f766
Bump yarl from 1.17.2 to 1.18.0
dependabot[bot] Nov 22, 2024
61f2816
Bump aiohttp from 3.11.6 to 3.11.7
dependabot[bot] Nov 22, 2024
e8d3632
Fix Pylint CI duplicated runs
winstonsung Nov 22, 2024
20517c1
Packaging: Prepare src layout migration
winstonsung Nov 27, 2024
b3f016a
Packaging: Prepare src layout migration
winstonsung Dec 1, 2024
684e21f
Packaging: Prepare src layout migration
winstonsung Dec 1, 2024
c0f0a90
Packaging: Prepare src layout migration
winstonsung Dec 2, 2024
e44f966
Format "Packaging: Prepare src layout migration" using Black
github-actions[bot] Dec 2, 2024
7b242fc
Bump pytest from 8.3.3 to 8.3.4
dependabot[bot] Dec 2, 2024
6e0b85b
Bump aiohttp from 3.11.7 to 3.11.9
dependabot[bot] Dec 2, 2024
2cf61ce
Bump pylint from 3.3.1 to 3.3.2
dependabot[bot] Dec 2, 2024
38515ec
Bump aiohappyeyeballs from 2.4.3 to 2.4.4
dependabot[bot] Dec 2, 2024
8a4a15d
Bump yarl from 1.18.0 to 1.18.3
dependabot[bot] Dec 2, 2024
8bdc6fa
Packaging: Prepare src layout migration
winstonsung Dec 2, 2024
72c9063
Introduce unit tests using unittest and pytest
winstonsung Dec 2, 2024
07d7821
Fix YAML formatting
winstonsung Dec 2, 2024
2ece78a
Bump certifi from 2024.8.30 to 2024.12.14
dependabot[bot] Jan 16, 2025
9dc1c35
Bump aiosignal from 1.3.1 to 1.3.2
dependabot[bot] Jan 16, 2025
5c6eed4
Bump attrs from 24.2.0 to 24.3.0
dependabot[bot] Jan 16, 2025
d0c358e
Bump aiohttp from 3.11.9 to 3.11.11
dependabot[bot] Jan 16, 2025
7da7120
Bump urllib3 from 2.2.3 to 2.3.0
dependabot[bot] Jan 16, 2025
accbc56
Bump click from 8.1.7 to 8.1.8
dependabot[bot] Jan 16, 2025
dac673c
Bump jinja2 from 3.1.4 to 3.1.5
dependabot[bot] Jan 16, 2025
48aac31
Bump astroid from 3.3.5 to 3.3.8
dependabot[bot] Jan 16, 2025
ddbbe9f
Bump pylint from 3.3.2 to 3.3.3
dependabot[bot] Jan 16, 2025
463f7bd
Bump charset-normalizer from 3.4.0 to 3.4.1
dependabot[bot] Jan 16, 2025
862cad7
Update .gitignore
winstonsung Jan 16, 2025
a8e9485
Add py-cord dep. propcache 0.2.1 to lock file
winstonsung Jan 16, 2025
9c8f11e
Update release notes
winstonsung Jan 16, 2025
b3e1317
Update release notes
winstonsung Jan 16, 2025
66eacf4
Update release notes
winstonsung Jan 16, 2025
3dcc826
Remove deprecated redundant code in switch-btn.js
winstonsung Jan 16, 2025
a26545a
fix: Hide RPS game alert to public
iach526526 Feb 3, 2025
6c39d61
Bump mysql-connector-python from 9.1.0 to 9.2.0
dependabot[bot] Feb 3, 2025
3657407
Bump attrs from 24.3.0 to 25.1.0
dependabot[bot] Feb 3, 2025
68721f2
Bump pylint from 3.3.3 to 3.3.4
dependabot[bot] Feb 3, 2025
329bd1a
Bump isort from 5.13.2 to 6.0.0
dependabot[bot] Feb 3, 2025
30b7127
Bump black from 24.10.0 to 25.1.0
dependabot[bot] Feb 3, 2025
dd41372
Bump certifi from 2024.12.14 to 2025.1.31
dependabot[bot] Feb 3, 2025
36f2b9d
Packaging: Prepare src layout migration
winstonsung Feb 3, 2025
0c622a7
Version 0.2.0
winstonsung Oct 9, 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
Prev Previous commit
Next Next commit
Format "Merge branch" using Black
  • Loading branch information
github-actions[bot] committed Aug 28, 2024
commit e7d2c87a346227b89ee778c3a4866082ced79997
21 changes: 15 additions & 6 deletions test/api.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
import requests


class Apis:
def __init__(self, api_key:str,guild_id:int):
def __init__(self, api_key: str, guild_id: int):
self.api_key = api_key
self.guild_id = guild_id
self.headers = {"Authorization": f"Bot {self.api_key}","Content-Type": "application/json",}
self.headers = {
"Authorization": f"Bot {self.api_key}",
"Content-Type": "application/json",
}

def get_user(self, uid):
"""
API 回傳的資料格式範例,已經把一些敏感資料隱藏掉
@@ -43,21 +49,24 @@ def get_user(self, uid):
"mute": false,
"deaf": false
}

"""
try:
url = f"https://discord.com/api/v10/guilds/{self.guild_id}/members/{uid}"
response = requests.get(url, headers=self.headers,timeout=5)
response = requests.get(url, headers=self.headers, timeout=5)
response.raise_for_status() # 檢查 HTTP 狀態碼
return response.json()
except requests.exceptions.RequestException as e:
# 如果發生錯誤,返回一個包含錯誤訊息和詳細報錯的字典
return {"error": "get_user error", "details": str(e)}

def create_dm_channel(self, target_user_id: str):
try:
url = "https://discord.com/api/v10/users/@me/channels"
json_data = {"recipient_id": target_user_id}
response = requests.post(url, headers=self.headers, json=json_data, timeout=10)
response = requests.post(
url, headers=self.headers, json=json_data, timeout=10
)
response.raise_for_status() # Raise an HTTPError for bad responses
dm_channel = response.json()
return dm_channel["id"]
@@ -72,4 +81,4 @@ def create_dm_channel(self, target_user_id: str):
"result": "internal server error",
"status": 500,
"error": str(e),
}
}