A lightweight Python chatbot that responds to messages using exact or close matches with
difflib
.
DecoderBot is a simple Python class that lets you build a chatbot that replies to input messages based on:
- Exact matches (like
"hello"
) - Closest matches (like
"helo"
→"hello"
), ifdifflib
is available
No extra libraries. No nonsense. Just logic.
- 🧠 Exact and fuzzy response matching
- 🛠️ Add or update responses easily
- 📦 Zero external dependencies
- 🔥 Lightweight and fast
from DecoderBot import ChatBot
bot = ChatBot("Your Bot Name")
# Add a custom response
bot.train_for("yo", "What's up?")
# Get exact match response
print(bot.get_response("yo")) # Output: What's up?
# Get a close match response (e.g. "helo" → "hello")
try:
print(bot.get_closest_response("helo"))
except Exception as e:
print(e)