{"id":22256949,"url":"https://github.com/followingthefasciaplane/greptilecord","last_synced_at":"2025-07-28T07:31:32.391Z","repository":{"id":248637232,"uuid":"829268296","full_name":"followingthefasciaplane/greptilecord","owner":"followingthefasciaplane","description":"Discord bot for Greptile AI ","archived":false,"fork":false,"pushed_at":"2024-08-15T11:09:30.000Z","size":161,"stargazers_count":3,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"main","last_synced_at":"2024-08-16T04:28:03.385Z","etag":null,"topics":["acl","ai","artificial-intelligence","bot","claude","discord","discord-bot","discord-py","github","gpt","greptile","intelligence","intelligent","python","sqlite"],"latest_commit_sha":null,"homepage":"https://greptile.com","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"unlicense","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/followingthefasciaplane.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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-07-16T05:20:24.000Z","updated_at":"2024-08-15T11:09:33.000Z","dependencies_parsed_at":"2024-08-15T04:27:58.057Z","dependency_job_id":null,"html_url":"https://github.com/followingthefasciaplane/greptilecord","commit_stats":null,"previous_names":["followingthefasciaplane/greptilecord"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/followingthefasciaplane%2Fgreptilecord","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/followingthefasciaplane%2Fgreptilecord/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/followingthefasciaplane%2Fgreptilecord/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/followingthefasciaplane%2Fgreptilecord/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/followingthefasciaplane","download_url":"https://codeload.github.com/followingthefasciaplane/greptilecord/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":227877895,"owners_count":17833559,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":["acl","ai","artificial-intelligence","bot","claude","discord","discord-bot","discord-py","github","gpt","greptile","intelligence","intelligent","python","sqlite"],"created_at":"2024-12-03T08:09:11.707Z","updated_at":"2024-12-03T08:09:12.413Z","avatar_url":"https://github.com/followingthefasciaplane.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Greptile Discord Bot\n\nThis Discord bot provides information and answers questions about repositories using the [Greptile](https://greptile.com) API. It offers advanced features for repository management, user access control, and intelligent code querying. See [documentation](https://docs.greptile.com/prompt-guide) for more information about Greptile.\n\n## Features\n\n- Repository indexing and management\n- Intelligent code search and querying\n- User access control with whitelist system\n- Configurable settings\n- Error logging and reporting\n- Periodic repository status checks\n- Automatic reindexing of repositories\n- Pagination for long responses\n- SQLite for persistent storage\n\n## Unsupported \n\n- Chat history and session management\n  \nI may implement this in the future, as Greptile's API supports it, however, for now this bot only supports 0 shot queries.\n\n## Installation\n\n1. Set up a virtual environment and install dependencies:\n   - On Linux/macOS:\n     ```\n     ./setup_venv.sh\n     ```\n   - On Windows:\n     ```\n     setup_venv.bat\n     ```\n\n2. Update your \"secrets.yaml\" file:\n   ```yaml\n   DISCORD_BOT_TOKEN: 'your_discord_bot_token' # You will add this in Step 3\n   GREPTILE_API_KEY: 'your_greptile_api_key' # Your Greptile API Key\n   GITHUB_TOKEN: 'your_github_token' # Your GitHub PAT\n   BOT_OWNER_ID: 'your_discord_user_id' # This is not your username\n   ```\n   - To find your Discord ID, you can read [this article](https://support.discord.com/hc/en-us/articles/206346498-Where-can-I-find-my-User-Server-Message-ID).\n\n3. Create a Discord application and bot:\n   - Go to the [Discord Developer Portal](https://discord.com/developers/applications)\n   - Click \"New Application\" and configure your application\n   - Go to the \"Bot\" tab and click \"Add Bot\"\n   - Under the bot's username, click \"Copy\" to copy the bot token\n   - Paste the bot token in your `secrets.yaml` file\n   - Under \"Privileged Gateway Intents\", enable all intents\n   - Go to the \"Installation\" tab and enable \"Guild Install\"\n   - Select the \"bot\" and \"applications.commands\" scopes \n   - For bot permissions, select \"Administrator\"\n   - Save all and copy the generated URL and use it to invite the bot to your server\n\n4. Run the bot:\n   ```\n   python greptilebot.py\n   ```\n\n### Optional security\n- Consider limiting Discord intents and permissions to what is needed. Full permissions are provided for convenience.\n- Consider using environment variables in `secrets.yaml`. Eg: `DISCORD_BOT_TOKEN: '${DISCORD_BOT_TOKEN}'`\n\n## Commands\n\n### General Commands\n\n- `~greptilehelp`: Displays a detailed help message with information about all available commands.\n- `~search \u003csearch_query\u003e`: Searches for relevant code in the indexed repositories.\n- `~query \u003cquestion\u003e`: Asks a question about the codebase and gets a detailed answer.\n- `~smartquery \u003cquestion\u003e`: Asks a more complex question using the 'genius' feature for more detailed analysis.\n- `~listrepos`: Lists all indexed repositories.\n- `~repostatus`: Views the current status of the indexed repositories.\n\n### Admin Commands\n\n- `~addrepo \u003cremote\u003e \u003cowner/name\u003e [branch]`: Adds and indexes a new repository.\n- `~removerepos`: Removes all indexed repositories.\n- `~reindex [repo_id]`: Forces reindexing of a specific repository or all repositories.\n- `~setconfig \u003ckey\u003e \u003cvalue\u003e`: Sets a configuration value.\n- `~viewconfig`: Views the current bot configuration.\n- `~listwhitelist`: Lists all whitelisted users.\n- `~addwhitelist \u003cuser_id\u003e`: Adds a user to the whitelist.\n- `~removewhitelist \u003cuser_id\u003e`: Removes a user from the whitelist.\n- `~setlogchannel \u003cchannel_id\u003e`: Sets the channel for logging bot activities.\n- `~seterrorchannel \u003cchannel_id\u003e`: Sets the channel for error reporting.\n- `~testerror`: Tests the error reporting system.\n\n### Owner Commands\n\n- `~addadmin \u003cuser_id\u003e`: Promotes a user to admin.\n- `~removeadmin \u003cuser_id\u003e`: Demotes an admin to a regular user.\n- `~reload`: Reloads the bot.\n\n## Configuration\n\n- Daily limits for regular and smart queries per user.\n- Smart queries are 3x the price of regular queries in the Greptile API.\n- The bot owner has unlimited usage of all commands.\n\n### Config Keys:\n\n- `MAX_QUERIES_PER_DAY`: Maximum number of regular queries a user can make per day (default: 5)\n- `MAX_SMART_QUERIES_PER_DAY`: Maximum number of smart queries a user can make per day (default: 1)\n- `API_TIMEOUT`: Timeout for API calls in seconds (default: 60)\n- `API_RETRIES`: Maximum retries for failed API calls (default: 3)\n- `BOT_PREFIX`: The prefix used for bot commands (default: \"~\")\n- `DEFAULT_BRANCH`: The default branch to use, if it is omitted from an Administrator command (default: main)\n\nThese can be adjusted with the `~setconfig \u003ckey\u003e \u003cvalue\u003e` command.   \nTo view your current keyvalues, use `~viewconfig`.\n\n## Whitelist System\n\n- Three user roles: `UserRole.USER`, `UserRole.ADMIN`, and `UserRole.OWNER`.\n- Only whitelisted users can use the general commands.\n- Admins can manage the whitelist and bot configuration.\n- The Owner (can only be set in `secrets.yaml`) has full access to all commands, and bypasses daily limits.\n\n### Whitelisting users\n\n- Only the Owner can use `~addadmin` and `~removeadmin`.  \nThese commands will add `UserRole.ADMIN` to a Discord ID, or demote an existing Admin ID to `UserRole.USER`.\n  \n- Admins can use `~addwhitelist` and `~removewhitelist`.  \nThese commands will add or remove `UserRole.USER` to or from a Discord ID.  \n\n- To view the current list of users and the roles they have, you can use `~listwhitelist`.\n\n### Changing permissions for commands\n\nUsing `~seterrorchannel` as an example, you can change this line in `src/greptilebot.py` to one of three roles:  \n```\n@bot.command(name='seterrorchannel')\n@is_whitelisted(UserRole.ADMIN)\n```\n\n\n```\n@bot.command(name='seterrorchannel')  \n@is_whitelisted(UserRole.OWNER)\n```\n\n\n```\n@bot.command(name='seterrorchannel')  \n@is_whitelisted(UserRole.USER)\n```\n\n## Database\n\nThe bot uses SQLite for persistent storage of:  \n- Whitelist information\n- Indexed repositories\n- Bot configuration\n- DB created automatically in `src/bot_data.db`.\n\n## Error Handling and Logging\n\n- Comprehensive error handling for all commands.\n- Detailed logging of bot activities and errors.\n- Automatic error reporting to a designated channel and to the bot owner directly via DM.\n- Debug logfile is automatically generated `src/bot.log`\n\n`~setlogchannel` will stream the debug log to a channel. **Use carefully, this can leak environment information.**  \n`~seterrorchannel` will set a channel to log errors in.  \n`~testerror` will cause a division by 0 error to test the error reporting system.\n\n## Periodic Tasks\n\n- Automatic repository status checks every 30 minutes.\n- Reporting of failed or stuck repository indexing.\n\n## Note\n\nThis bot is not affiliated with Greptile in any way. It is a third-party implementation using the Greptile API. While efforts have been made to ensure stability, it may still contain bugs and requires further testing.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffollowingthefasciaplane%2Fgreptilecord","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffollowingthefasciaplane%2Fgreptilecord","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffollowingthefasciaplane%2Fgreptilecord/lists"}