src/main.rsdrives the Telegram bot;src/bin/web.rsexposes the Actix-Web API used by the Next.js frontend.- Shared logic lives in
src/lib.rswith supporting modules such assrc/db.rs,src/msg.rs, andsrc/sec.rs; keep additions scoped by topic. assets/holds bundled static data,script/contains Python crawlers and data helpers, andweb/tracks the safc-web submodule for UI work.- Documentation lives in
doc/; database snapshots likedb.sqliteshould be copied locally before experiments rather than edited in place.
cargo run --bin safc_botstarts the bot (requiresTELOXIDE_TOKEN,TELOXIDE_PROXY,SAFC_DB_PATH).cargo run --bin safc_webexposes the HTTP API used by the static site; pair withnpm run devinsideweb/afternpm install.cargo build --releaseproduces optimized binaries for deployment; keep release artifacts out of version control.cargo fmt,cargo +nightly fmt --all -- --check, andcargo clippy --all-targets --all-featuresmirror CI expectations.
- Use Rust’s default 4-space indentation; stick to
snake_casefor modules/functions andCamelCasefor types and enums. - Centralize reusable logic in
lib.rsor dedicated submodules; avoid sprawlingmain.rs. - Prefer structured logging via
log::info!/warn!instead ofprintln!; keep messages concise and actionable.
- Add unit tests with
#[cfg(test)]blocks beside new code or create integration suites undertests/. - Run
cargo test --allbefore every PR; extend coverage when touching database or security-critical paths. - Include lightweight fixtures or doc tests to lock down schema assumptions when altering
src/db.rs.
- Follow the repository’s short, imperative commit style (
ci update,db update); squash noisy WIP commits before review. - Target PRs at
master, provide a clear summary, link related issues or TODO items, and note which surfaces (bot,web,scripts) are affected. - Attach screenshots or terminal transcripts when showcasing bot flows or API output changes.
- Store secrets in untracked
.envfiles; never commit real tokens, proxies, or production SQLite dumps. - When sharing repro steps, reference sanitized sample env (
TELOXIDE_TOKEN=123...XYZ) and local database paths (SAFC_DB_PATH=./tmp/safc.db).
- 面向与你的用户的对话时,优先使用中文与用户沟通。