Skip to content

1M50RRY/pychatbotlib

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 

Repository files navigation

PyChatbotLib


Exclusive library for creating chatbots.
It uses a very simple algorithm which helps to recognize possible answers to messages.
You just need to train it in chats with 2 types of messages: reply and original.

Installation

pip install pychatbotlib

Example of usage

import telebot # pip3 install PyTelegramBotAPI==2.2.3
from time import sleep
from pychatbotlib.pychatbotlib import Chatbot
bot = telebot.TeleBot('APIKEY')
chatbot = Chatbot("chatbot_data")

@bot.message_handler(content_types=["text"])
def handle_message(message):
    try:
        chatbot.add_data(message.text, message.reply_to_message.text)
        answer = chatbot.get_reply(message.text)
        if answer is not None:
            bot.reply_to(message, answer)
    except Exception as e:
        answer = chatbot.get_reply(message.text)
        if answer is not None:
            bot.reply_to(message, answer)
        print("Not a reply")

while True:
    try:
        bot.polling(none_stop=True)
    except Exception as e:
        bot.polling(none_stop=True)
  

Releases

No releases published

Packages

No packages published

Languages