<commit_before>import Vott from 'vott'
import express from 'express'
import bodyParser from 'body-parser'
import request from 'request-promise-native'

export class MessengerBot extends Vott {
  constructor (config) {
    super(config)
    this.platform = 'Messenger'
    this.config.endpoint = '/facebook/receive'
    this.config.port = 8080
    this.config = Object.assign(this.config, config)
  }

  send (event) {
    const payload = {
      recipient: { id: event.user.id }
    }

    if (event.messaging_type) {
      payload.messaging_type = event.messaging_type
    } else {
      payload.messaging_type = !event.tag ? 'RESPONSE' : 'MESSAGE_TAG'
    }

    if (event.tag) {
      payload.tag = event.tag
    }

    if (event.sender_action) {
      payload.sender_action = event.sender_action
    } else {
      payload.message = event.message
    }

    if (event.notification_type) {
      payload.notification_type = event.notification_type
    }

    if (!event.user.id && event.user.phone_number) {
      payload.recipient.phone_number = event.user.phone_number
    }

    this.getAccessToken(event.user.page_id, (token) => {
      if (token) {
        payload.access_token = token

        this.outbound(payload, (bot, message) => {
          const options = {
            method: 'POST',
            uri: 'https://graph.facebook.com/v2.6/me/messages',
            body: message,
            json: true
          }

          request(options).then((response) => {
            this.emit('message_sent', { response, message })
          }).catch((error) => {
            this.emit('error', error)
          })
        })
      } else {
        this.emit('error', { message: 'Token not found.' })<commit_msg>Add ability to use custom API url<commit_after>import Vott from 'vott'
import express from 'express'
import bodyParser from 'body-parser'
import request from 'request-promise-native'

export class MessengerBot extends Vott {
  constructor (config) {
    super(config)
    this.platform = 'Messenger'
    this.config.endpoint = '/facebook/receive'
    this.config.port = 8080
    this.config = Object.assign(this.config, config)
  }

  send (event) {
    const payload = {
      recipient: { id: event.user.id }
    }

    if (event.messaging_type) {
      payload.messaging_type = event.messaging_type
    } else {
      payload.messaging_type = !event.tag ? 'RESPONSE' : 'MESSAGE_TAG'
    }

    if (event.tag) {
      payload.tag = event.tag
    }

    if (event.sender_action) {
      payload.sender_action = event.sender_action
    } else {
      payload.message = event.message
    }

    if (event.notification_type) {
      payload.notification_type = event.notification_type
    }

    if (!event.user.id && event.user.phone_number) {
      payload.recipient.phone_number = event.user.phone_number
    }

    this.getAccessToken(event.user.page_id, (token) => {
      if (token) {
        payload.access_token = token

        this.outbound(payload, (bot, message) => {
          const options = {
            method: 'POST',
            uri: this.config.api_url || 'https://graph.facebook.com/v2.6/me/messages',
            body: message,
            json: true
          }

          request(options).then((response) => {
            this.emit('message_sent', { response, message })
          }).catch((error) => {
            this.emit('error', error)
          })
        })
      } else {
        this.emit('error', { message: 'Token not found.' })
{'fraction_non_alphanumeric': 0.1258982466225927, 'fraction_numerical': 0.0034492670307559644, 'mean_word_length': 2.273753527751646, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 11, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4459124', 'n_tokens_mistral': 1085, 'n_tokens_neox': 1046, 'n_words': 209}