Skip to main content

nonebot

nonebot-plugin-course

✨基于Nonebot2的课表查询插件✨

💡写在前面

特别感谢hamo的nonebot_plugin_PicMenu提供的图片生成工具img_tool和很多思路

算是菜鸡写的第一个完整的工程项目,代码似乎十分屎山,但作为总计写python不到两个月的人来说,我还是较为有成就感的。之后有空再重构,所以有什么改进建议或者在使用时遇到bug,欢迎狠狠地提Issue

🌟功能

  • 📖完整课表

  • 📙本周课表

  • 🧾下周课表

  • 🔍查询指定周数课表

  • 🕑查询当前在上什么课,今天还有没有课

  • 📆支持设定周数

  • 📌添加课表过程简单,与主流课表app流程无太大区别

    🎯TODO

    ☑︎ 支持不同账号设定不同的上下课时间,而非一个bot共用一套上下课时间(8.28已更新,现在可在json文件里自动生成的"exact_time"下更改)

    ⬜︎ 如果今天没课了,跨天或跨周查询离现在最近的一节课还有多久(课少的时候看着很赏心悦目

    ⬜︎ 相同课的表格合并

    ⬜︎ 自定义课表表格的行数与列数

    ⬜︎ 这个老师经常点名?在Ta上课前半小时自动提醒我

    ❎暂时不会考虑添加的功能

    • 用对话添加课表:因为一周内的课十分的多,多的时候会添加5×13次,而这都需要一次一次地在聊天框输入后发送,若遇传参问题会增加复杂度,反而本末倒置了。若是在群组里添加也会十分地刷屏。

💿如何使用

  • 首先部署nonebot,具体可参照这里

下载

方法一

nb plugin install nonebot-plugin-course

方法二

  • Step1
    pip install nonebot_plugin_course
    
  • Step2 在pyproject.toml里的plugins = []添加"nonebot_plugin_course"

方法三

在src文件夹下的plugin文件夹里使用git clone

初次使用

  1. 上一步完成以后启动一次bot,会自动在根目录的/data文件夹(即bot.py所在文件夹)下生成一个名为course_config的文件夹

  2. 打开里面的config.json文件,将"default"字段的值改为任意字体的路径,字体格式为PIL.ImageFont.truetype所支持的字体,比如将第一行改为"default": "simhei.ttf"

  3. 保存json文件后就可以快乐地添加课表了

  4. 在任意一个群内发送“完整课表”,即可自动初始化当前帐号的课表结构

  1. 根据自己的课表情况在框内填写即可

示例

"qq号": {
        "week": 1,
        "exact_time": {//自定义用户每节课的上下课时间
            "1": {
                "start": "08:20",
                "end": "09:05"
            },
            "2": {
                "start": "09:10",
                "end": "09:55"
            },
            ...
        },
        "1": { // 周一
            "1": [ // 第一节课
                {
                    "name": "",
                    "teacher": "",
                    "classroom": "",
                    "week": []
                }
            ],
            "2": [ // 第二节课
                {
                    "name": "",
                    "teacher": "",
                    "classroom": "",
                    "week": []
                }
            ],
            "3": [ //注意如果某天的某个位置在不同周有多节课,在列表位置以相同格式复制字典后再填写即可
                {
                    "name": "数字图像处理基础",
                    "teacher": "虞旦",
                    "classroom": "物流113",
                    "week": [
                        8
                    ]
                },
                {
                    "name": "数字图像处理基础",
                    "teacher": "王晓兰",
                    "classroom": "物流113",
                    "week": [ // 周数需一个一个填,暂不支持如"3-13"的形式填写
                        9,
                        10,
                        11,
                        12,
                        13,
                        15,
                        16
                    ]
                }
            ],
            ...
        },
        "2":{ // 周二
            ...
        },
        ...
}

❗注意事项

  1. 不同学校的上课时间有所不同,默认设定的时间仅代表作者的学校。因此,请务必确认utils.py里默认初始化的上下课时间是否与使用者的一致

    self.data_manager.course_data[user_id] = {'week': 1,
                                                  'exact_time': {
                                                      "1": {"start": "08:20", "end": "09:05"},
                                                      "2": {"start": "09:10", "end": "09:55"},
                                                      "3": {"start": "10:15", "end": "11:00"},
                                                      "4": {"start": "11:05", "end": "11:50"},
                                                      "5": {"start": "11:55", "end": "12:25"},
                                                      "6": {"start": "12:30", "end": "13:00"},
                                                      "7": {"start": "13:10", "end": "13:55"},
                                                      "8": {"start": "14:00", "end": "14:45"},
                                                      "9": {"start": "15:05", "end": "15:50"},
                                                      "10": {"start": "15:55", "end": "16:40"},
                                                      "11": {"start": "18:00", "end": "18:45"},
                                                      "12": {"start": "18:50", "end": "19:35"},
                                                      "13": {"start": "19:40", "end": "20:25"},
                                                  },
                                                  }
    
  2. 如果某一节课在不同周有不同的教室,建议在填写classroom的时候就以原始形式填写

    "classroom": "2-3:3B403,4-6:2A401"
    

    因为除了“完整课表”以外的查询命令,都会返回查询者的当前周数。(若在填写时以字典形式存每周对应的教室反而会增加填写难度和出错率。)

📈功能展示

指令

  • 本周课表:查看这周的课表
  • 完整课表:查看完整的课表
  • 下周课表:查看下周的课表
  • 查看课表 + 周数:查询指定周的课表
  • 设置周数 + 周数:设定当前是第几周
  • 上课:查询当前是否有课,及今天的下一节课是什么,还有多久上

感谢你看到这里,如果觉得还不错的话给个star吧

Metadata

Release files for nonebot-plugin-course 0.1.9

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for nonebot-plugin-course 0.1.9
File Size Uploaded
nonebot_plugin_course-0.1.9.tar.gz 15.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for nonebot-plugin-course 0.1.9
File Interpreter ABI Platform
nonebot_plugin_course-0.1.9-py3-none-any.whl Python 3 none any Details

Total release size: 30.1 kB

Release files / nonebot_plugin_course-0.1.9.tar.gz

Download URL nonebot_plugin_course-0.1.9.tar.gz
Size 15.9 kB
Tags Source
SHA-256 checksum
How to use checksums
dda7cb87f0632b8e3922d70175b63df018fc9798ea8629a0f8ee1b0f60401602
BLAKE2b-256 checksum
How to use checksums
05a0b78730e0c21b5d7e0818bce09ad65010bb6e93a01a1befe821acd6f5fca5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.8.10

Release files / nonebot_plugin_course-0.1.9-py3-none-any.whl

Download URL nonebot_plugin_course-0.1.9-py3-none-any.whl
Size 14.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
17bde2885e5da196b63b9b2596959458bf1d2c6bf851aeda6a970a37a33db070
BLAKE2b-256 checksum
How to use checksums
d4da50ec4c5ecbb71ff1cc334cea8869d52f0e88179f12e4fe8b86db6458feaf
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.8.10

Release history Release notifications | RSS feed

This release

0.1.9 This release

2 release files

0.1.8

2 release files

0.1.7

2 release files

0.1.6

2 release files

0.1.5

2 release files

0.1.4

2 release files

0.1.3

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1.0

2 release files

0.0.9

2 release files

0.0.8

2 release files

0.0.7

2 release files

0.0.6

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page