/Kotori-telegram_bot

A telegram chat bot written in python

Primary LanguagePythonMIT LicenseMIT

Kotori Telegram_bot

A telegram chat bot written in python. It's a chinese chat bot, english translation are in the comment.

Installation

This bot is written in python(version 3.5). install python

Requirements

List of required libraries to run the app

  • python-telegram-bot $ pip install python-telegram-bot
  • requests $ pip install requests
  • Flask $ pip install Flask
  • chatterbot $ pip install chatterbot
  • lxml $ pip install lxml

Environment variable

List of environment variable.

  • DATABASE_URL -> your database url.
  • HENTAI_COOKIE -> your cookie to access exhentai.
  • MUGI_APIKEY -> your APIKEY of dojinshi.org.
  • TELEGRAM_TOKEN -> the token of your telegram bot.

These variable must be set on the service which the app deployed. You can use service such as heroku to deploy this app. Heroku official website

Features

Search about Dojinshi

dojinshi.org is a database of dojinshi. It provides an api for people to easily query it and get XML response.

Commands :

/author
/circle
  • Use /author to start searching dojinshi author.
  • Use /circle to start searching dojinshi circle.

After typeing these command , the bot will ask you for the keyword you want to search. Then get the best matched result and return useful links such as HomePage,Pixiv,Twitter.

The program first call the dojinshi api to get the id of the result. Then scrape the webpage to get links.

demo :

Search for books

Commands :

/book

After typeing these command , the bot will ask you for the keyword you want to search.

The bot will scrape the three biggest online bookstore in Taiwan(books,kingstone,taaze), get (up to) 5 results for each bookstore. The result contains title, price, and the book's link.

demo :

Get random manga from exhentai

Commands :

/huolu
/myfav

Use /huolu to get a manga from exhentai (A adult manga site). The program will scrape a random page in exhentai, call e-hentai api to get gallery tags and filter the result using some rule. Finally return the first gallery that pass the rule. /myfav will get a random manga from your e-hentai favorites.

demo :

Machine learning

This bot use ChatterBot to chat with users. ChatterBot is a machine-learning based conversational dialog engine build in Python. Without typing any command. The bot will learn all the input text, and return the best response message.

The bot will save the learned response in database. You can also train the bot with corpus packages. example :

chatbot.train("chatterbot.corpus.english")

learn more : ChatterBot Documentation

Other commands

Commands :

/start
/help
  • While first open the bot on telegram. You will be asked to type /start.
  • Use /help to get command list.

demo :

ToDo List

  • more searching features
  • inline bot

License

Kotori bot is available under the MIT license.