Home

Awesome

Insult detection extensions

How it works?

Messages

If insult is detected to visitor is written that his message is insulting. Operator has option to mark this message as not insulting. On third insulting message we terminate the chat.

Images

If we detect nude images we remove file instantly and replace a visitor uploaded file with a simple message telling his uploaded image is inappropriate.

Requirements

This extension requires

Install guide

'extensions' => 
      array (
          'lhcinsult',
          'lhcphpresque',
          // 'nodejshelper' Optional if you have NodeJS extension running.
      ),

How to monitor status automatically?

This required if you are having a lot of messages and DeepPavlov messages check queue jobs queue is not getting close to zero.

This command monitors services health and disables them if required. This command should be run through cronjob every minute.

/usr/bin/php cron.php -s site_admin -e lhcinsult -c cron/check_health

How to monitor service status and restart on failure

Over time I have noticed that time from time docker image just hangs up. And image is not restarted by docker service. Here is a small shell script which monitors status and restarts if required. This script should be run every 5 minutes or so.

#!/bin/bash

fileCron='/data/lhc-chatbot/script/image-dead'
imageTest='/data/lhc-chatbot/script/logo.png'

test=$( base64 -w 0 $imageTest )
data="{\"data\":{\"logo.png\":\"$test\"},\"webhook\":null}"
RESPONSE=$(curl -X POST -d "$data" -H 'Accept: application/json' -H 'Content-Type: application/json' --max-time 180 -s http://localhost:8080/sync)

if [[ $RESPONSE != *"unsafe"* ]]; then
   if [ ! -f $fileCron ];
    then
      echo "Creating lock file"
      touch $fileCron
    else
      /usr/bin/docker restart lhcinsul-image
      echo "Lock found. Restarting API"
    fi
else
  if [ -f $fileCron ]; then
    rm -f $fileCron
  fi
  echo "Live API"
fi

Cronjob command

*/5 * * * * /data/lhc-chatbot/script/monitor-image-insult.sh > /data/lhc-chatbot/script/log_insult.txt /dev/null 2>&1