{"size": 841, "ext": "js", "max_stars_repo_path": "handlers/service.js", "max_stars_repo_name": "krivahtoo/group-manager", "max_stars_repo_stars_event_min_datetime": "2021-01-06T21:17:38.000Z", "max_stars_repo_stars_event_max_datetime": "2021-12-25T18:19:14.000Z", "max_issues_repo_path": "handlers/service.js", "max_issues_repo_name": "krivahtoo/group-manager", "max_issues_repo_issues_event_min_datetime": "2020-12-03T23:46:12.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-18T02:15:08.000Z", "max_forks_repo_path": "handlers/service.js", "max_forks_repo_name": "krivahtoo/group-manager", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": 3, "max_issues_count": 61, "max_forks_count": null, "avg_line_length": 23.3611111111, "max_line_length": 57, "alphanum_fraction": 0.5422116528}
const Handler = require('./base')
const {
  errorHandler
} = require('../helpers')

const opts = {
  name: 'service',
  type: 'message',
  run: (bot) => [
    [
      // TODO new_chat_members handled by welcome handler
      'new_chat_members',
      'new_chat_photo',
      'new_chat_title',
      'left_chat_member',
      'delete_chat_photo'
    ],
    async (ctx) => {
      ctx.database.Group.findByPk(ctx.chat.id)
        .then((result) => {
          if (result && result.settings) {
            let settings = result.settings
            if (typeof settings !== 'object') {
              settings = JSON.parse(settings)
            }
            if (settings.deleteService) {
              ctx.deleteMessage(ctx.massage.massage_id)
            }
          }
        }).catch(errorHandler)
    }
  ]
}

module.exports = Handler(opts)
