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

adds quote limit #56

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open

adds quote limit #56

wants to merge 5 commits into from

Conversation

jt3k
Copy link
Owner

@jt3k jt3k commented Nov 28, 2017

#55

@@ -213,6 +215,8 @@ function prepareMessage(msg: Telegram$Message): string {
if (msg.forward_from) {
const name: string = Name.from(msg.forward_from);

text = prepareQuote(text);
Copy link
Collaborator

@eilvelia eilvelia Nov 28, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Forwarded message should be fully displayed, as in the Telegram.

Copy link
Owner Author

@jt3k jt3k Nov 29, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

now i cut it off from here b69eab1

@@ -222,6 +226,17 @@ function prepareMessage(msg: Telegram$Message): string {
return text;
}

function prepareQuote(quote) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This function needs flow type annotations, I guess.

Copy link
Owner Author

@jt3k jt3k Nov 29, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done 8741b5d

@ForNeVeR ForNeVeR self-requested a review November 29, 2017 04:37
Copy link

@ghost ghost left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cosmetic changes

}

const prepared = quote
.split('\n').slice(0, 3).join('\n').slice(0, quoteLength);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this looks like magic, why r u taking first 3 in slice?

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

here I leave no more than three lines and no more than the length of the string specified in the config

How can I improve this code?

const firstThreeLines = quote.split('\n').slice(0, 3).join('\n');
const prepared = firstThreeLines.slice(0, quoteLength);

for example like this?

Copy link
Owner Author

@jt3k jt3k Nov 29, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done look to commit 7c03175

const prepared = quote
.split('\n').slice(0, 3).join('\n').slice(0, quoteLength);
const isMatched = prepared === quote;
return prepared + (isMatched ? '' : '...');
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there is a separate character representing ellipsis … (U+2026) instead of 3 dots

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems to me that showing UTF-symbols to people who are in jabber it can be dangerous.

They are not seldom under linux and some of them under terminal

Copy link
Owner Author

@jt3k jt3k Nov 29, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done 126ae3e

}

// get first three lines
let prepared = quote.split('\n').slice(0, 3).join('\n');
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suggest that we extract that 3 into a config parameter. Probably "quoteLimits": { "characters": 140, "lines": 3 }?

@ForNeVeR ForNeVeR assigned jt3k and unassigned ForNeVeR and eilvelia Jan 20, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants