Skip to content

Reddit bot that posts info about Japanese words and kanji

License

Notifications You must be signed in to change notification settings

Remedan/kanjibot

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

27 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Kanjibot

A simple Reddit bot that will reply with information when called.

Usage

To summon the bot, simply mention its name along with some Japanese on the same line. Multiple items should be separated by , or 、 or spaces.

For example:

/u/kanji-bot 日、ありがとう

The bot will look at each item as either a kanji character or a word. By default, it chooses automatically. You can force to it to pick either by putting !kanji or !word befor some items.

For example:

/u/kanji-bot ① !kanji ② !word ③

① will be interpreted automatically, ② as kanji and ③ as words or phrases. You can put multiple items in place of ①, ② and ③!

Running the Code

Kanjibot needs a MySQL database to store its data. Before starting it you need to edit praw.ini and kanjibot.ini and fill in Reddit, Imgur and db info. If you want the bot to post stroke order images, you need to obtain them as described below and place them in jp-data/strokes.

To fill the database with the data the bot needs, run:

python -m kanjibot --init-db

(Note: There are a few obscure characters that will fail to import into even utf8mb4 encoded table. I'm currently not sure what to do about this but it's not really a big issue.)

To start the bot, run:

python -m kanjibot

The bot will continuously read its inbox and post replies. I recommend creating a simple systemd (or equivalent) service to daemonize it.

Dictionary Data

This bot uses the JMdict, KANJIDIC and KRADFILE dictionary files. These files are the property of the Electronic Dictionary Research and Development Group, and are used in conformance with the Group's licence.

Stroke Order Images

The bot posts stroke order images when available. The source images come from the KanjiVG project. The images were colorized using KanjiColorizer. Finally, Inkscape was used to convert them from svg to png.

The images should be placed in jp-data/strokes. I didn't include them in the repo to save space.

About

Reddit bot that posts info about Japanese words and kanji

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages