Skip to content

bot that posts menu from some restaurants to chat

Notifications You must be signed in to change notification settings

ubergrape/menubot

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

77 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Menubot

Local Development

install requirements:

pip3 install -r requirements.txt

configure:

export MENUBOT_WEBHOOOK_URL=...
export MENUBOT_FACEBOOK_APP_ID=...
export MENUBOT_FACEBOOK_APP_SECRET=...

to run crawlers that do OCR (e.g. "Guru1080"), you also need tesseract:

Usage

run all crawlers:

python3 menubot.py

run just one crawler:

python3 menubot.py --crawler gangl.GanglCrawler

just print text, don't send to webhook

python3 menubot.py --dry-run

Deploy to heroku (first time)

  1. create app, configure and push to heroku

    heroku create 
    heroku config:set MENUBOT_WEBHOOOK_URL=....
    heroku config:set MENUBOT_FACEBOOK_APP_ID=...
    heroku config:set MENUBOT_FACEBOOK_APP_SECRET=...
    heroku buildpacks:add https://github.com/heroku/heroku-buildpack-locale

    if you also want OCR:

    heroku buildpacks:add --index 1 https://github.com/heroku/heroku-buildpack-apt
    heroku config:set TESSDATA_PREFIX=/app/.apt/usr/share/tesseract-ocr/4.00/tessdata
    

    push to heroku:

    git push heroku master
    
  2. test:

    heroku run python menubot.py
  3. add scheduler:

    heroku addons:create scheduler:standard
    heroku addons:open scheduler

    configure command python menubot.py to run every day at UTC 10:30

Deploy to heroku (update existing bot)

    git push heroku master

Adding a crawler

  1. crate new python file in "crawlers" directory:

    from . import MenuCrawler
    
    class XxxCrawler(MenuCrawler):
        name = "Xxx"
    
        def run(self):
            # TODO: your code
    
            # put errors in self.error_text
            if something_goes_wrong:
                self.error_text = "The menu is not up to date"
                return
    
            # put the menu in self.menu_text
            self.menu_text = "The menu text you found"

    where Xxx is the Restaurant name

  2. add code in the run method

  3. add all requirements to "requirements.txt"

  4. test with python3 menubot.py --crawler xxx.XxxCrawler --dry-run

  5. Add your crawler to list of crawlers in "menubot.py"

  6. create a PR

Todo

About

bot that posts menu from some restaurants to chat

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages