Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Complete QoL Improvements #139

Merged
merged 1 commit into from Apr 21, 2019
Merged
Changes from all commits
Commits
File filter...
Filter file types
Jump to…
Jump to file or symbol
Failed to load files and symbols.

Always

Just for now

@@ -34,17 +34,18 @@ class TgDocumentHandler {
let username = '\x02' + TgHelpers.ResolveUserName(from) + '\x02';
let url = await this._tgbot.getFileLink(document.file_id);

let message = this._GetDocumentMessage(caption, username, url);
let message = this._GetDocumentMessage(caption, username, document, url);
this._action(message);
}

/**
* Generates the message to send out
* @param {string} caption - The caption of the document
* @param {string} from - User who sent the photo
* @param {string} document - Telegram document object
* @param {string} fileUrl - URL to the document
*/
_GetDocumentMessage(caption, from, fileUrl) {
_GetDocumentMessage(caption, from, document, fileUrl) {
var message;

if (Helpers.IsNullOrUndefined(caption)) {
@@ -53,12 +54,14 @@ class TgDocumentHandler {

if (!this.Enabled) {
message = from +
" shared a file on Telegram with caption: " +
" shared a file (" +
document.mime_type +
") on Telegram with caption: " +
"'" + caption + "'";
} else {
message = "'" + caption + "'" +
" uploaded by " +
from + ": " +
message = "'" + caption + "'" +
" uploaded by " +
from + ": " +
fileUrl;
}
return message;
@@ -11,6 +11,7 @@ module.exports.ResolveUserName = function(from) {
}

// Add ZWP to remove IRC highlighting when Telegram + IRC nicks are the same
// See https://github.com/42wim/matterbridge/issues/175 for inspiration
return from.username.substr(0,1) + "\u200B" + from.username.substr(1);
};

@@ -25,5 +26,8 @@ module.exports.GetFullUserName = function(from) {
return from.first_name;
}

return from.first_name + " (@" + from.username + ")";
// Add ZWP so users with same username across bridge don't ping themselves

This comment has been minimized.

Copy link
@jwflory

jwflory Apr 21, 2019

Member

Thanks for the useful comment, this is the kind of thing we would forget why we did it in two years.

username = from.username.substr(0,1) + "\u200B" + from.username.substr(1);

return from.first_name + " (@" + username + ")";
};
@@ -4,6 +4,7 @@
"description": "A simple Telegram <=> IRC bot",
"main": "teleirc.js",
"scripts": {
"start": "node teleirc.js",

This comment has been minimized.

Copy link
@jwflory

jwflory Apr 21, 2019

Member

On a side note, it could be an interesting side-project for us to package an RPM for TeleIRC. A future sprint idea.

"test": "nodeunit ./tests"
},
"repository": {
@@ -37,7 +37,9 @@ exports.TgDocumentHandler_DisabledNoCaptionTest = async function(assert) {
await uut.RelayDocumentMessage(fromWithUsername, document, null);

var expectedMessage = '\x02' + fromWithUsername.username + '\x02' +
" shared a file on Telegram with caption: 'Untitled Document'";
" shared a file (" +
document.mime_type +
") on Telegram with caption: 'Untitled Document'";

assert.strictEqual(expectedMessage, message);
assert.done();
@@ -59,7 +61,9 @@ exports.TgDocumentHandler_DisabledCaptionTest = async function(assert) {
let caption = "My caption";

let expectedMessage = '\x02' + fromWithUsername.username + '\x02' +
" shared a file on Telegram with caption: " +
" shared a file (" +
document.mime_type +
") on Telegram with caption: " +
"'" + caption + "'";

await uut.RelayDocumentMessage(fromWithUsername, document, caption);
@@ -55,8 +55,9 @@ exports.TgJoinHandler_EnabledNoUsername = function(assert) {
*/
exports.TgJoinHandler_EnabledWithUsername = function(assert) {
var message = undefined;
var username = "u" + "\u200B" + "sername";

let expectedMessage = fromWithUserName.first_name + " (@" + fromWithUserName.username + ") has joined the Telegram Group!";
let expectedMessage = fromWithUserName.first_name + " (@" + username + ") has joined the Telegram Group!";

let uut = new TgJoinHandler(
true,
@@ -52,8 +52,9 @@ exports.TgPartHandler_EnabledNoUsername = function(assert) {
*/
exports.TgPartHandler_EnabledWithUsername = function(assert) {
var message = undefined;
var username = "u" + "\u200B" + "sername";

let expectedMessage = fromWithUserName.first_name + " (@" + fromWithUserName.username + ") has left the Telegram Group.";
let expectedMessage = fromWithUserName.first_name + " (@" + username + ") has left the Telegram Group.";

let uut = new TgPartHandler(
true,
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.