Skip to content
This repository has been archived by the owner on Jan 19, 2022. It is now read-only.

Commit

Permalink
3.9.3: Message truncation
Browse files Browse the repository at this point in the history
  • Loading branch information
Bjornskjald committed Sep 5, 2018
2 parents 8683f51 + db41b37 commit cffd4ef
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 9 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## [3.9.3] - 2018-09-05
### Added
- Truncating message when exceeds 2000 chars on Discord

## [3.9.2] - 2018-09-05
### Changed
- Fixed quit command
Expand Down
6 changes: 3 additions & 3 deletions config.example.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"messenger": {
"username": "",
"password": "",
"forceLogin": false,
"forceLogin": true,
"filter": {
"whitelist": [],
"blacklist": [],
Expand All @@ -23,10 +23,10 @@
"renameChannels": true,
"showEvents": false,
"showFullNames": false,
"createChannels": true,
"createChannels": false,
"massMentions": true
},
"checkUpdates": true,
"checkUpdates": false,
"logLevel": "info",
"errorChannel": "",
"commandChannel": ""
Expand Down
2 changes: 1 addition & 1 deletion lib/config/getConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const fs = require('fs')

const defaultConfig = {
messenger: {
forceLogin: false,
forceLogin: true,
filter: {
whitelist: [],
blacklist: []
Expand Down
4 changes: 3 additions & 1 deletion lib/discord/createMessage.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
const log = require('npmlog')
const url = require('url')
const handleMentions = require('./handleMentions')

// function creating message from template
module.exports = (thread, sender, message) => {
Expand All @@ -12,7 +13,8 @@ module.exports = (thread, sender, message) => {
log.verbose('createMessage', 'Nickname: %s, author name: %s', nickname, authorName)
log.verbose('createMessage: content', message.body)

var discordMessage = message.body
var discordMessage = handleMentions(message.body)
if (discordMessage.length > 2000) discordMessage = discordMessage.slice(0, 1997) + '...'

// if there are no attachments, send it already
var opts = {
Expand Down
3 changes: 1 addition & 2 deletions lib/messenger/listener.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const log = require('npmlog')
const url = require('url')

const { createMessage, handleMentions } = require('../discord')
const { createMessage } = require('../discord')
const { createMessage: createFBMessage, filter, getChannelName, getSender, getThread } = require('./')
const handleEvent = require('../messenger/handleEvent')
var reconnecting
Expand Down Expand Up @@ -57,7 +57,6 @@ module.exports = async (error, message) => {

// build message from template
var m = createMessage(thread, sender, message, config.discord.showFullNames)
m[0] = handleMentions(m[0])
log.silly('messengerListener: pending message', m)

// get channel
Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "miscord",
"version": "3.9.2",
"version": "3.9.3",
"description": "Facebook Messenger to Discord bridge",
"main": "index.js",
"scripts": {
Expand Down

0 comments on commit cffd4ef

Please sign in to comment.