{"id":15031287,"url":"https://github.com/nubilfi/botagent","last_synced_at":"2026-03-07T22:01:22.764Z","repository":{"id":254951785,"uuid":"845426683","full_name":"nubilfi/botagent","owner":"nubilfi","description":"Detect bot user agents using regular expressions.","archived":false,"fork":false,"pushed_at":"2024-08-28T03:11:30.000Z","size":42,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-12-27T02:29:29.073Z","etag":null,"topics":["backend","regex","rustlang","user-agent"],"latest_commit_sha":null,"homepage":"https://crates.io/crates/botagent","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/nubilfi.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-08-21T08:22:37.000Z","updated_at":"2024-08-28T04:50:21.000Z","dependencies_parsed_at":null,"dependency_job_id":"ad382913-2e43-4eb0-b311-cc43acad6d0b","html_url":"https://github.com/nubilfi/botagent","commit_stats":null,"previous_names":["nubilfi/botagent"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/nubilfi/botagent","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nubilfi%2Fbotagent","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nubilfi%2Fbotagent/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nubilfi%2Fbotagent/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nubilfi%2Fbotagent/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nubilfi","download_url":"https://codeload.github.com/nubilfi/botagent/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nubilfi%2Fbotagent/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30233429,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-07T19:01:10.287Z","status":"ssl_error","status_checked_at":"2026-03-07T18:59:58.103Z","response_time":53,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["backend","regex","rustlang","user-agent"],"created_at":"2024-09-24T20:15:22.094Z","updated_at":"2026-03-07T22:01:22.722Z","avatar_url":"https://github.com/nubilfi.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# botagent\n\n[![version](https://img.shields.io/crates/v/botagent?color=blue\u0026logo=rust\u0026style=flat-square)](https://crates.io/crates/botagent)\n[![Build Status](https://github.com/nubilfi/botagent/actions/workflows/rust.yml/badge.svg)](https://github.com/nubilfi/botagent/actions?branch=main)\n[![Documentation](https://docs.rs/botagent/badge.svg)](https://docs.rs/botagent/latest/botagent/)\n\n[![codecov](https://codecov.io/gh/nubilfi/botagent/graph/badge.svg?token=SRGOFSB31Q)](https://codecov.io/gh/nubilfi/botagent)\n\n**botagent** is a Rust library for detecting bot user agents using regular expressions. It reads patterns from a JSON file, compiles them into a regex, and checks user agents against these patterns.\n\n## Features\n\n- **Bot Detection**: Identify whether a given user agent string matches known bot patterns.\n- **Customizable**: Use your own bot patterns by providing a JSON file.\n- **Efficient**: Uses the `pcre2` crate for high-performance regex matching.\n- **Error Handling**: Robust error handling with detailed messages.\n\n## Installation\n\nTo use this library in your project, add the following to your `Cargo.toml`:\n\n```toml\n[dependencies]\nbotagent = \"0.1\"\n```\n\nOr by run `cargo add botagent` command.\n\n## Usage\n### Check if User Agent is a Bot\n\nTo check if a given user agent string matches any known bot patterns:\n\n```rust\nuse botagent::is_bot;\n\nfn main() {\n    let is_bot = is_bot(\"Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)\", \"patterns.json\").unwrap();\n    println!(\"Is bot: {}\", is_bot);\n}\n```\n\n### Find the Matching Bot Pattern\n\nIf you want to know which bot pattern matched the user agent:\n\n```rust\nuse botagent::is_bot_match;\n\nfn main() {\n    let matched_pattern = is_bot_match(\"Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)\", \"patterns.json\").unwrap();\n    if let Some(pattern) = matched_pattern {\n        println!(\"Matched bot pattern: {}\", pattern);\n    } else {\n        println!(\"No bot pattern matched.\");\n    }\n}\n```\n\n## Patterns File Format\n\nThe bot patterns are stored in a JSON file, with each pattern being a regular expression string. Here is an example `patterns.json`:\n\n```json\n[\n  \"(?\u003c! (?:channel/|google/))google(?!(app|/google| pixel))\",\n  \"(?\u003c! cu)bots?(?:\\\\b|_)\"\n]\n```\n\nEach string in the array is a pattern that will be compiled into a single regular expression to match against user agent strings.\n\n## Running Tests\n\nTo run the tests, you can use the following command:\n\n```bash\ncargo test\n```\n\nThis will also run the documentation tests to ensure that all code examples in the documentation are correct.\n\n## Accuracy\n\nThis library follows the original logic and pattern list from [isbot](https://github.com/omrilotan/isbot) and it uses a regular expression that matches bots and only bots. I'll try to ensure it aligns closely with the original logic, but tailored to work seamlessly in a Rust environment, feel free to reach out with any feedback or suggestions!\n\n## Credits\n\nThis library was inspired by and largely based on the work from [isbot](https://github.com/omrilotan/isbot). The original TypeScript code was rewritten in Rust.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnubilfi%2Fbotagent","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnubilfi%2Fbotagent","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnubilfi%2Fbotagent/lists"}