Skip to content

Commit

Permalink
更新
Browse files Browse the repository at this point in the history
  • Loading branch information
ajdgg committed Jun 14, 2024
1 parent c1ede4e commit e1a6f2a
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 3 deletions.
31 changes: 31 additions & 0 deletions .github/workflows/lint-and-format.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: Lint Code

on:
push:
branches:
- main

jobs:
lint:
name: Lint
runs-on: ubuntu-latest
steps:
- name: Check out repository
uses: actions/checkout@v2

- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: 3.x

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install black flake8
- name: Format with black
run: black .

- name: Lint with flake8
run: flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
continue-on-error: false
2 changes: 2 additions & 0 deletions nonebot_plugin_calc24/file_handle.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
from pathlib import Path
import json


def file_path(file):
return Path(__file__).resolve().parent / file


class file_handle:
def file_reading(self, file: str, key: str):
try:
Expand Down
6 changes: 4 additions & 2 deletions nonebot_plugin_calc24/xj_calc24.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@
file_handle = file_handle()

legal_data_array = file_handle.file_reading("calc24-data.json", "data")
new_continuous_legal_data = {tuple(arr): None for arr in legal_data_array}
if legal_data_array is None:
raise ValueError("文件读取错误")
else:
new_continuous_legal_data = {tuple(arr): None for arr in legal_data_array}


def check_if_in_dict(array):
Expand All @@ -17,7 +20,6 @@ def check_if_in_dict(array):
def random_number_generator():
intdata = [1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 6, 6, 6, 6, 7, 7, 7, 7, 8, 8, 8, 8, 9, 9, 9, 9, 10, 10, 10, 10, 11, 11, 11, 11, 12, 12, 12, 12, 13, 13, 13, 13]
a_data = random.sample(intdata, 4)
# a_data = [1,1,1,1]
if check_if_in_dict(a_data):
return random.sample(intdata, 4)
return a_data
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "nonebot-plugin-calc24"
version = "1.3.12"
version = "1.3.13"

description = "A 24-point game plugin implemented using NoneBot."
authors = ["AwAjie <[email protected]>"]
Expand Down

0 comments on commit e1a6f2a

Please sign in to comment.