Skip to main content

12306车票查询机器人,助你漫漫回家路

Project description

nonebot-plugin-12306-ticket

✨12306车票查询机器人,助你漫漫回家路✨

GitHub Repo stars GitHub License GitHub last commit Static Badge PyPI - Version

📖 介绍

这是一个查询12306列车余票及其票价的机器人插件,持续更新中

它可以在你跟群友唠嗑的时候,顺便把火车票给查了。如果暂时没票,可以设定一个定时任务,它会持续帮你查询

有些功能因为特殊原因,没有进行全面的测试,如果出现Bug,请您及时进行反馈

💿 安装

Required

  • Python >= 3.11

  • Nonebot 2 >= 2.4.4

使用 nb-cli 安装 在nonebot2项目插件目录下,打开命令行,输入以下安装命令
pnb plugin install nonebot-plugin-12306-ticket
使用pip安装 在nonebot2项目插件目录下,打开命令行,输入以下安装命令
pip install nonebot-plugin-12306-ticket
使用git clone安装 可以将本项目克隆到你已经建立好的Nonebot机器人的目录内,并在project.toml中配置好本插件的安装目录
git clone https://github.com/leaf2006/nonebot-plugin-12306-ticket.git

🎉 使用

指令表

指令 权限 需要@ 范围 说明
/车票 【出发站】 【到达站】 【日期(选填)】 群员 群聊、私聊 查询从出发站至到达站间的列车票价及余票数量
/定时查询 【出发站】 【到达站】 【日期(选填)】 【列车出发时间范围 H-H(可选)】 【持续查询时间(分钟/小时)】 群员 群聊、私聊 定时查询车票情况
/取消查询 群员 群聊、私聊 取消定时查询任务

选填的【日期】可以填以下几种格式,如不填日期或所填日期小于今天,一律默认为今天

  • 今天明天
  • 2026-03-12
  • 2026年3月12日

【列车出发时间范围】示例:14-18,即时间范围为14时到18时

【持续查询时间】示例:30分钟/1小时

效果

1.普通查询

🤵:/车票 上海 杭州 明天
🤖:正在加载,请耐心等待...

🤖:
@user_name 信息如下:
------------------------------
【1】G547(北京南——上海虹桥)
北京南 06:18 —— 12:11 上海虹桥,历时05:53分
二等座:¥553  有
一等座:¥930  有
商务座:¥1873  11张
无座:¥553  有
------------------------------
【2】G1(北京南——上海虹桥)
北京南 06:30 —— 11:24 上海虹桥,历时04:54分
二等座:¥662  有
一等座:¥1060  无
商务座:¥2318  无
无座:¥662  18张
------------------------------
【3】G3(北京南——上海)
北京南 06:52 —— 11:33 上海,历时04:41分
二等座:¥669  有
一等座:¥1070  无
商务座:¥2341  5张
无座:¥669  有
------------------------------
【4】G565(北京南——上海虹桥)
北京南 07:07 —— 13:12 上海虹桥,历时06:05分
二等座:¥576  有
一等座:¥969  有
商务座:¥1998  有
无座:¥576  有
------------------------------
【5】G549(北京南——上海虹桥)
北京南 07:13 —— 13:03 上海虹桥,历时05:50分
二等座:¥598  有
一等座:¥969  有
商务座:¥1998  18张
无座:¥598  有
------------------------------
【6】G5(北京——上海)
北京 07:42 —— 12:32 上海,历时04:50分
二等座:¥673  有
一等座:¥1076  无
商务座:¥2354  12张
无座:¥673  有
------------------------------
【7】G597(北京南——上海虹桥)
北京南 07:42 —— 13:49 上海虹桥,历时06:07分
二等座:¥576  有
一等座:¥969  有
商务座:¥1998  17张
无座:¥576  有
------------------------------
【8】G37(北京南——杭州东)
北京南 07:52 —— 12:35 上海虹桥,历时04:43分
二等座:¥626  有
一等座:¥1035  有
商务座:¥2318  15张
无座:¥626  有
------------------------------
【9】G5(北京——上海)
北京南 07:59 —— 12:32 上海,历时04:33分
二等座:¥669  有
一等座:¥1070  无
商务座:¥2341  12张
无座:¥669  有
------------------------------
【10】G599(北京南——上海虹桥)
北京南 08:15 —— 14:14 上海虹桥,历时05:59分
二等座:¥576  有
一等座:¥969  有
商务座:¥1998  12张
无座:¥576  有
------------------------------
---【当前第1页,共6页】---
数据来源:12306.cn

🤖:如需继续查看,请输入 /下一页,五分钟内有效

如用户想继续查看,可以输入命令/下一页next

2.定时查询

🤵:/定时查询 南京南 湖州 2026年4月6日 18-19 1小时
🤖:@user_name ❌抱歉,您查询的南京南到湖州,18时到19时暂时无票
     1小时后将再次查询
🤖:@user_name ❌抱歉,您查询的南京南到湖州,18时到19时暂时无票
     还将进行9次查询
     ...

如果有票,会输出有票的车次,如果有票的车次较多、票源充足,则仅输出前10条数据

🤵:/定时查询 南京南 湖州 2026年4月6日 9-15 1小时
🤖:@user_name ⭐您查询的南京南到湖州,9时到15时车票十分充足!以下仅显示部分车次:
【1】G3029(商丘——丽水)
南京南 09:33 —— 10:32 湖州,历时59分
二等座:¥94  1张
一等座:¥153  无
商务座:¥295  无
无座:¥94  无
------------------------------
【2】G7691(合肥南——江山)
南京南 09:44 —— 10:37 湖州,历时53分
二等座:¥94  有
一等座:¥153  18张
商务座:¥295  7张
无座:¥94  有
------------------------------
【3】G7605(徐州东——杭州东)
南京南 09:54 —— 10:54 湖州,历时1小时整
二等座:¥94  有
一等座:¥153  有
商务座:¥295  5张
无座:¥94  有
------------------------------
【4】G645(济南东——南昌西)
南京南 10:00 —— 11:01 湖州,历时1小时1分
二等座:¥94  有
一等座:¥153  10张
商务座:¥295  2张
无座:¥94  有
------------------------------
【5】G7619(徐州东——瑞安)
南京南 10:10 —— 11:09 湖州,历时59分
二等座:¥102  有
一等座:¥163  有
商务座:¥324  6张
无座:¥102  无
------------------------------
【6】G7695(淮北——江山)
南京南 10:15 —— 11:42 湖州,历时1小时27分
二等座:¥102  有
一等座:¥163  有
商务座:¥324  6张
无座:¥102  无
------------------------------
【7】G7755(亳州南——杭州东)
南京南 10:27 —— 11:37 湖州,历时1小时10分
二等座:¥102  有
一等座:¥163  10张
商务座:¥324  3张
无座:¥102  无
------------------------------
【8】G1097(济南——温州南)
南京南 10:32 —— 11:27 湖州,历时55分
二等座:¥102  3张
一等座:¥163  无
商务座:¥324  无
无座:¥102  无
------------------------------
【9】G1731(济南东——苍南)
南京南 10:42 —— 11:48 湖州,历时1小时6分
二等座:¥94  3张
一等座:¥143  9张
商务座:¥268  无
无座:¥94  无
------------------------------
【10】D2293(南京南——深圳北)
南京南 10:57 —— 12:17 湖州,历时1小时20分
二等座:¥68  有
一等座:¥109  10张
无座:¥68  有
------------------------------

⚠️ 已知问题

  • Bot回复速度较慢,还需等待后续修复

🔜 TODO

  • 加入对显示该列车是否支持候补的支持
  • 加入显示某些特殊坐席的支持,如T7785(杭州——兰溪)的二等软座、一等软座,还会显示为二等座、一等座
  • 加入学生票查询

Copyright © Leaf developer 2023-2026,遵循MIT开源协议

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

nonebot_plugin_12306_ticket-0.1.1.tar.gz (18.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

nonebot_plugin_12306_ticket-0.1.1-py3-none-any.whl (18.3 kB view details)

Uploaded Python 3

File details

Details for the file nonebot_plugin_12306_ticket-0.1.1.tar.gz.

File metadata

File hashes

Hashes for nonebot_plugin_12306_ticket-0.1.1.tar.gz
Algorithm Hash digest
SHA256 52bc7e7cff6b73a8b95029a1a30b8efcffafebd471604a23cc4aaad7ce4d8932
MD5 90487453ee6c2a22cef0d0f0f7e5ba59
BLAKE2b-256 0c3b5ab3eb086205424b8d9fd97ce723882b5d0eac19bfa5bba6abd000d8a5a5

See more details on using hashes here.

File details

Details for the file nonebot_plugin_12306_ticket-0.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for nonebot_plugin_12306_ticket-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 2d885baed98e7e97b7a38419cc1820a867e48448e1bf37400363d9d97fc127e8
MD5 d9cb1c91faa5a96d2d14eb94caa822aa
BLAKE2b-256 0252c9f01fc19431d5937b168cbbe642b7e63a17b014604d1d6c72c51eb6645e

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page