GithubHelp home page GithubHelp logo

Add option to group messages about tedicross HOT 5 OPEN

tedicross avatar tedicross commented on June 15, 2024 1
Add option to group messages

from tedicross.

Comments (5)

rraallvv avatar rraallvv commented on June 15, 2024 1

@trgwii Yes, sure 👍

from tedicross.

Suppen avatar Suppen commented on June 15, 2024

Discord messages might break the grouping only at the change of hour. https://www.reddit.com/r/discordapp/comments/5dr2a4/when_does_discord_separate_messages/

More testing to determine when grouping breaks must be done

from tedicross.

Suppen avatar Suppen commented on June 15, 2024

This has been slightly improved in commit 42d4812
It now says

username:
message
username
message

from tedicross.

rraallvv avatar rraallvv commented on June 15, 2024

I solved this keeping track of the user ID in the last message. Is not an elegant solution though, I added a setter to the class Bridge to check whether the user is different from the previous and to set a flag I use then to know whether to show the user or not in the next message.

class Bridge {
	set lastUserId(id) {
		if (this._lastUserId !== id) {
			this._lastUserId = id;
			this._showUsername = true;
		}
	}

	get showUsername() {
			return this._showUsername;
	}
}

The in discord to telegram

let textToSend;
if (bridge.discord.sendUsernames && bridge.showUsername) {
	textToSend = `<b>${senderName}</b>\n${processedMessage}`;
} else {
	textToSend = processedMessage;
}

// Disable showing the user name for the same user in the next message
bridge.showUsername = false;

And telegram to discord

let messageText;
if (!bridge.telegram.sendUsernames || messageObj.reply !== null || !bridge.showUsername) {
	messageText = messageObj.text;
} else {
	messageText = `**${messageObj.from}**\n${messageObj.text}`;
}

// Disable showing the user name for the same user in the next message
bridge.showUsername = false;

from tedicross.

trgwii avatar trgwii commented on June 15, 2024

Can you do a PR?

from tedicross.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.