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

Support multiple commands in a single telegram message. #135

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

qip
Copy link

@qip qip commented Jul 29, 2020

Support multiple commands in a single telegram message, one command per line.

Backstory: getting tried of organizing bookmarks with spamming /bm (and the mixed chat layout for future reference).

const { message_id, text } = message || {}
if (message_id) sm({ chat_id, message_id, text, parse_mode: 'HTML' }, 'editMessageText')
for (let line of data.split('\n')) {
const [action, fid, target] = data.split(' ').filter(v => v)
Copy link
Owner

Choose a reason for hiding this comment

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

should be const [action, fid, target] = line.split(' ').filter(v => v)

Copy link
Author

Choose a reason for hiding this comment

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

Ah, good catch! Didn't tested /copy command there...
Thanks for the check!

@iwestlin
Copy link
Owner

😄Nice tought, however this might cause some problem...

For example:

if (text.startsWith('/help')) return send_help(chat_id)

Should change to

if (text.startsWith('/help')) {
  send_help(chat_id)
  continue
}

And so do other lines with return ...

Sometimes user might forward multiple lines message from other tg channels, god know what's gonna happen...It's unpredictable.

In my option, multiple line commands seems cool, but it's against the rule of keep things simple(aka do one thing at a time...)

If you want edit multiple bookmark record at one time, you could use bookmark.js, run ./bookmark.js -h for help.

Be notice, it will not overwrite alias, see #120 (comment) for more info.

@qip
Copy link
Author

qip commented Aug 2, 2020

True, I wasn't aware of the return messages, which can be tricky...
And yeah, user inputs are always unpredictable, and we have no control, especially with the folder-id parsing feature, which doesn't have the / format.
Multi-line execution is appealing to me because I can maintain bookmarks in a single message, and every time any bookmark gets updated, I can modify that message and forward it to this bot, without the need to copy those line by line. Other than that, I haven't realized a useful scenario (maybe copying a list of shared folders, but it's much better with a shell script), to be honest.
bookmark.js is one nice solution (other than alias feature), but access to telegram is much easier than SSH, especially on mobile.
With all that been said, thank you for this awesome project! It's already making people's life much easier:)

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.

2 participants