Skip to content

feat: add initial bot implementation with environment configuration a…#4

Merged
kpj2006 merged 4 commits into
AOSSIE-Org:mainfrom
kpj2006:main
Jun 11, 2026
Merged

feat: add initial bot implementation with environment configuration a…#4
kpj2006 merged 4 commits into
AOSSIE-Org:mainfrom
kpj2006:main

Conversation

@kpj2006

@kpj2006 kpj2006 commented Jun 11, 2026

Copy link
Copy Markdown
Member

…nd skill rules

Addressed Issues:

Fixes #(issue number)

Screenshots/Recordings:

Additional Notes:

Checklist

  • My code follows the project's code style and conventions
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings or errors
  • I have joined the Discord server and I will share a link to this PR with the project maintainers there
  • I have read the Contributing Guidelines

⚠️ AI Notice - Important!

We encourage contributors to use AI tools responsibly when creating Pull Requests. While AI can be a valuable aid, it is essential to ensure that your contributions meet the task requirements, build successfully, include relevant tests, and pass all linters. Submissions that do not meet these standards may be closed without warning to maintain the quality and integrity of the project. Please take the time to understand the changes you are proposing and their impact.

Summary by CodeRabbit

  • New Features

    • Discord bot with local AI model integration for responding to channel messages
    • Automatic processing of message history on startup
    • Configurable AI model and custom context/skill file support
  • Chores

    • Added environment and configuration setup templates
    • Added Python dependencies for Discord, HTTP requests, and environment management
    • Updated repository ignore patterns for Python environments and secrets

@github-actions github-actions Bot added the no-issue-linked PR is not linked to any issue label Jun 11, 2026
@coderabbitai

coderabbitai Bot commented Jun 11, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Warning

Review limit reached

@kpj2006, we couldn't start this review because you've reached your PR review rate limit.

More reviews will be available in 25 minutes and 22 seconds. Learn how PR review limits work.

Your organization has reached its usage spending cap. Adjust your spending cap in the billing tab.

⌛ How to resolve this issue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available.

Please see our Fair Usage Limits Policy for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: 49ebbcba-65b3-42d9-8043-05a7b692c020

📥 Commits

Reviewing files that changed from the base of the PR and between d60ef6a and c223c9b.

📒 Files selected for processing (2)
  • bot.py
  • requirements.txt

Walkthrough

This pull request introduces a complete Discord bot that fetches messages from a configured channel, submits them to a local Ollama model with mentoring context, and replies with generated responses. The project includes configuration rules, environment templates, dependencies, and full bot implementation with startup backlog processing and real-time message handling.

Changes

Discord Ollama Mentor Bot

Layer / File(s) Summary
Project configuration and dependencies
.clinerules, .env.example, .gitignore, requirements.txt
.clinerules defines the mentor bot role and behavior, .env.example templates Discord token, channel ID, and Ollama model configuration, .gitignore excludes venv/ and .env, and requirements.txt pins discord.py 2.3.2, httpx 0.27.0, and python-dotenv 1.0.1.
Bot runtime setup and Ollama utilities
bot.py
Loads environment variables, initializes Discord client with message-content intent, creates an asyncio.Lock for serializing Ollama requests, and implements load_skill_context() to read the skill file and generate_ollama_response() to POST to Ollama with error handling for timeouts and request failures.
Message handling and Discord event flow
bot.py
process_message() filters non-bot messages in the target channel, locks Ollama access, generates responses, truncates to 1900 characters, and replies. The on_message() event handler delegates all messages to process_message().
Bot startup, Ollama readiness, and entry point
bot.py
wait_for_ollama() polls Ollama health, on_ready() waits for Ollama, fetches the channel, locates the last bot message, gathers and processes missed user messages as startup backlog, and __main__ validates configuration and starts the client.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Suggested labels

Python Lang

🐰 A Discord bot hops into view,
With Ollama wisdom bright and new,
It listens, learns, and replies with care,
Mentoring souls with context to share.
Hop on, friends—let the guidance flow!

🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main changes: adding an initial bot implementation with environment configuration and skill rules, which matches the five new files added (.clinerules, .env.example, .gitignore updates, bot.py, and requirements.txt).
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions github-actions Bot added backend Changes to backend code configuration Configuration file changes dependencies Dependency file changes documentation Changes to documentation files python Python code changes size/L Large PR (201-500 lines changed) first-time-contributor First PR of an external contributor needs-review labels Jun 11, 2026
@github-actions

github-actions Bot commented Jun 11, 2026

Copy link
Copy Markdown
Contributor
Messages
📖

⚠️ PR Template Check

These are non-blocking, but please fix:

  • Please replace the placeholder Fixes #(issue number) with the actual issue number (e.g. Fixes #42).

  • Some required checklist items are not completed:

  • My PR addresses a single issue

  • My code follows the project's code style

  • My changes generate no new warnings or errors

Generated by 🚫 dangerJS against c223c9b

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 4

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@bot.py`:
- Line 110: The code calls int(DISCORD_CHANNEL_ID) inline (e.g., in channel =
await client.fetch_channel(int(DISCORD_CHANNEL_ID))) which can raise on bad env
values and currently is only logged; instead parse and validate
DISCORD_CHANNEL_ID once during startup in __main__, convert it to an integer
(e.g., DISCORD_CHANNEL_ID_INT) and exit the process with a non-zero status if
parsing fails, then replace all inline int(...) uses (including the
fetch_channel call and the uses around lines 145-147) to use the validated
integer variable so the app fails fast on invalid IDs.
- Around line 109-133: The backlog replay currently scans only the last 50
messages for the bot cursor and falls back to 5 messages, which can drop older
messages and cause duplicate replies when on_message is active; change to use a
durable persisted checkpoint named last_processed_message_id (persist to
disk/DB) instead of searching for last_bot_msg, fetch history using
channel.history(after=last_processed_message_id, oldest_first=True) (or from
beginning if no checkpoint) without artificial small limits, and update/persist
last_processed_message_id after each successful process_message call;
additionally add message-id deduping inside process_message (skip if message.id
already processed) or temporarily disable on_message handling while replay runs
to prevent double-processing.
- Around line 85-99: The wait_for_ollama() loop can hang forever; add a
fail-fast by introducing a max_retries (or max_wait_seconds) counter and stop
retrying after it is exceeded. In wait_for_ollama(), track attempts (or elapsed
time) around the httpx.AsyncClient GET call and, when the limit is reached, log
a clear degraded-state decision via logger (e.g., "Ollama unreachable after N
attempts; proceeding in degraded mode" or "exiting due to Ollama unavailable"),
and either return a boolean/failure value or raise a specific exception so the
caller can decide to exit or continue without backlog. Make the new behavior
configurable (optional parameter or constant) and ensure calls to asyncio.sleep
and httpx.RequestError handling remain, updating callers to handle the new
return/exception from wait_for_ollama().

In `@requirements.txt`:
- Around line 1-3: requirements.txt currently pins python-dotenv==1.0.1 which is
vulnerable; update requirements.txt to pin python-dotenv==1.2.2 and add
idna==3.15 to address the transitive idna vuln, then update project/CI Python
minimum (e.g., to 3.10+) to match python-dotenv 1.2.2's dropped 3.9 support;
alternatively, if you must keep Python 3.9, select the newest python-dotenv
version that still supports 3.9 instead of 1.2.2. Verify the runtime usage in
bot.py (load_dotenv) still works and run tests/CI to ensure no breakage after
the dependency and CI Python-version changes.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: a5b65ff8-fc90-4639-ae8d-9ef3c8e74a01

📥 Commits

Reviewing files that changed from the base of the PR and between bb3294f and d60ef6a.

📒 Files selected for processing (5)
  • .clinerules
  • .env.example
  • .gitignore
  • bot.py
  • requirements.txt

Comment thread bot.py
Comment thread bot.py
Comment thread bot.py Outdated
Comment thread requirements.txt Outdated
kpj2006 and others added 2 commits June 11, 2026 10:54
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
@kpj2006 kpj2006 merged commit ba49d03 into AOSSIE-Org:main Jun 11, 2026
9 of 11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backend Changes to backend code configuration Configuration file changes dependencies Dependency file changes documentation Changes to documentation files first-time-contributor First PR of an external contributor needs-review no-issue-linked PR is not linked to any issue python Python code changes size/L Large PR (201-500 lines changed)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant