Skip to content

liveupx/factcheckbot

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

FactCheckBot

An open-source, AI-powered fact-checking bot for Reddit. When a user replies to a claim with !FactCheck, the bot analyses the claim and responds with a clear verdict: True, False, Misleading, Unverified, or Opinion — along with a confidence score and explanation.

Built by Liveupx.com | Powered by GROQ (Llama 3.3 70B)


How it works

A user sees a suspicious claim on Reddit and replies:

!FactCheck The Great Wall of China is visible from space

The bot replies within seconds:

## [FALSE] Verdict: FALSE
**Confidence:** 96%

**Claim analyzed:**
> The Great Wall of China is visible from space with the naked eye

**Analysis:**
This is a widely debunked myth. Multiple astronauts, including Chris Hadfield,
have confirmed the Wall is not visible from low Earth orbit without aid. At ~6
metres wide, it is far too narrow to resolve with the naked eye from orbital
altitude (~400 km). NASA has also published official statements confirming this.

---
I am a bot developed by Liveupx.com | Powered by GROQ AI

Architecture

User comment with "!FactCheck"
         |
         v
  ┌─────────────┐
  │  bot.py      │  Reddit comment stream (PRAW)
  │  main loop   │  Detects trigger, extracts context
  └──────┬───────┘
         │
         v
  ┌─────────────┐     ┌──────────────┐
  │  checker.py  │────>│  search.py   │  Optional: Serper.dev web search
  │  pipeline    │     └──────────────┘
  └──────┬───────┘
         │
         v
  ┌─────────────┐
  │ groq_client  │  GROQ API (Llama 3.3 70B)
  │  with model  │  Extracts claim + analyses in one call
  │  fallback    │  Falls back through 4 models automatically
  └──────┬───────┘
         │
         v
  ┌─────────────┐
  │  database.py │  SQLite: deduplication + audit trail
  └──────┬───────┘
         │
         v
  Reply posted to Reddit

Features

  • Single-trigger activation — Only responds when a user explicitly tags !FactCheck. Never posts unsolicited comments.
  • Decisive verdicts — Uses the LLM's training knowledge as the primary source. Does not default to "Unverified" on well-known claims.
  • Model fallback chain — Automatically tries 4 GROQ models (llama-3.3-70b-versatilellama3-70b-8192llama-3.1-70b-versatilemixtral-8x7b-32768) if one is unavailable.
  • Rate limiting — Configurable max replies per hour and minimum interval between replies.
  • Deduplication — SQLite database prevents duplicate replies to the same comment.
  • Auto-reconnect — Recovers from Reddit API stream disconnections automatically.
  • Bot disclosure — Every reply includes a footer identifying the account as a bot with a link to this source code.
  • Optional web search — Serper.dev integration adds web sources to verdicts (not required — works perfectly without it).

Quick start

Prerequisites

Installation

git clone https://github.com/liveupx/factcheckbot.git
cd factcheckbot
pip install -r requirements.txt
cp .env.example .env

Configuration

Edit .env with your credentials:

REDDIT_CLIENT_ID=your_client_id
REDDIT_CLIENT_SECRET=your_secret
REDDIT_USERNAME=YourBotUsername
REDDIT_PASSWORD=your_password
GROQ_API_KEY=gsk_your_groq_key

All configuration options are documented in .env.example.

Test the fact-checker

Before running the full bot, verify the fact-checking engine works:

python -m tests.test_checker

Expected output — all five test claims should return correct, confident verdicts:

Claim   : The Great Wall of China is visible from space
Expected: FALSE
Verdict : FALSE (96%) [PASS]

Claim   : Water boils at 100 degrees Celsius at sea level
Expected: TRUE
Verdict : TRUE (97%) [PASS]

Results: 5 passed, 0 failures out of 5

Run the bot

python bot.py

For production deployment (keeps running after SSH disconnect):

screen -S factcheckbot
python bot.py
# Press Ctrl+A then D to detach
# Reconnect later: screen -r factcheckbot

Project structure

factcheckbot/
├── bot.py                 # Entry point — Reddit stream + reply logic
├── src/
│   ├── config.py          # All settings (loaded from .env)
│   ├── checker.py         # Fact-checking pipeline
│   ├── groq_client.py     # GROQ API client with model fallback
│   ├── search.py          # Optional Serper.dev web search
│   └── database.py        # SQLite tracking + deduplication
├── tests/
│   └── test_checker.py    # Smoke tests for the pipeline
├── data/                   # Created at runtime (db + logs)
├── .env.example           # Template for environment variables
├── requirements.txt
├── LICENSE                # MIT
└── README.md

Configuration reference

Variable Required Default Description
REDDIT_CLIENT_ID Yes Reddit app client ID
REDDIT_CLIENT_SECRET Yes Reddit app client secret
REDDIT_USERNAME Yes Bot Reddit username
REDDIT_PASSWORD Yes Bot Reddit password
GROQ_API_KEY Yes GROQ API key
GROQ_MODEL No llama-3.3-70b-versatile Primary GROQ model
SERPER_API_KEY No Serper.dev key for web search
TRIGGER No !FactCheck Comment trigger phrase
SUBREDDITS No all Subreddits to monitor (comma-separated or all)
MAX_REPLIES_PER_HOUR No 30 Rate limit
MIN_REPLY_INTERVAL No 30 Seconds between replies
LOG_LEVEL No INFO Python log level

Reddit policy compliance

This bot is designed to comply with Reddit's Bottiquette and API Terms:

  • Bot disclosure: Every reply includes a footer identifying the account as automated.
  • Opt-in only: The bot never comments unless explicitly triggered by a user.
  • Rate limiting: Configurable limits prevent excessive posting.
  • No data collection: Only stores comment IDs (for deduplication). No user data is collected, stored, or shared.
  • No vote manipulation: The bot does not vote on any content.
  • No advertising: Replies contain no ads or affiliate links.
  • Moderator cooperation: The bot is designed to operate only in subreddits where moderators have granted explicit approval.
  • Appropriate user agent: Identifies itself with a descriptive user agent string per API guidelines.

Deployment options

Platform Cost Notes
DigitalOcean Droplet $4/mo Recommended. 1 vCPU, 512MB is sufficient.
Oracle Cloud Free Always-free tier (1 vCPU, 1GB RAM).
Railway Free tier Easy deploy, may sleep on free tier.
Your own machine $0 Works if it stays on 24/7.

Troubleshooting

Bot returns UNVERIFIED on everything: Your GROQ API key is invalid or expired. Run python -m tests.test_checker to verify.

"RATELIMIT" errors from Reddit: Your bot account is too new or has insufficient karma. Build karma manually first.

Bot doesn't detect triggers: Ensure SUBREDDITS is set correctly in .env. Using all monitors all public subreddits.

Stream disconnections: Expected behaviour — Reddit's streaming API occasionally drops. The bot auto-reconnects after 30 seconds.

Contributing

Contributions are welcome. Please open an issue first to discuss what you'd like to change.

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/your-feature)
  3. Commit your changes
  4. Push to the branch
  5. Open a pull request

License

MIT — Liveupx.com

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages