-
Notifications
You must be signed in to change notification settings - Fork 9
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
base: master
Are you sure you want to change the base?
adds quote limit #56
Conversation
src/bots/telegram/client.js
Outdated
@@ -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); |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
src/bots/telegram/client.js
Outdated
@@ -222,6 +226,17 @@ function prepareMessage(msg: Telegram$Message): string { | |||
return text; | |||
} | |||
|
|||
function prepareQuote(quote) { |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done 8741b5d
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cosmetic changes
src/bots/telegram/client.js
Outdated
} | ||
|
||
const prepared = quote | ||
.split('\n').slice(0, 3).join('\n').slice(0, quoteLength); |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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
src/bots/telegram/client.js
Outdated
const prepared = quote | ||
.split('\n').slice(0, 3).join('\n').slice(0, quoteLength); | ||
const isMatched = prepared === quote; | ||
return prepared + (isMatched ? '' : '...'); |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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'); |
There was a problem hiding this comment.
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 }
?
#55