Last active
May 21, 2021 12:36
-
-
Save sampaiodiego/db4b60717e7ac0051024dde23c6a902e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
EXAMPLE MESSAGE | |
/poll "question?" "option 1" "option 2" | |
*/ | |
/** Global Helpers | |
* | |
* console - A normal console instance | |
* _ - An underscore instance | |
* s - An underscore string instance | |
* HTTP - The Meteor HTTP object to do sync http calls | |
*/ | |
class Script { | |
/** | |
* @params {object} request | |
*/ | |
prepare_outgoing_request({ request }) { | |
// request.params {object} | |
// request.method {string} | |
// request.url {string} | |
// request.auth {string} | |
// request.headers {object} | |
// request.data.token {string} | |
// request.data.channel_id {string} | |
// request.data.channel_name {string} | |
// request.data.timestamp {date} | |
// request.data.user_id {string} | |
// request.data.user_name {string} | |
// request.data.text {string} | |
// request.data.trigger_word {string} | |
const emojis = [ | |
':zero:', | |
':one:', | |
':two:', | |
':three:', | |
':four:', | |
':five:', | |
':six:', | |
':seven:', | |
':eight:', | |
':nine:', | |
':ten:' | |
]; | |
let match; | |
// Change the URL and method of the request | |
match = request.data.text.match(/((["'])(?:(?=(\\?))\3.)*?\2)/g); | |
let title = ''; | |
let options = []; | |
match.forEach((item, i) => { | |
item = item.replace(/(^['"]|['"]$)/g, ''); | |
if (i === 0) { | |
title = item; | |
} else { | |
options.push(emojis[(options.length + 1)] + ' ' + item); | |
} | |
}); | |
return { | |
message: { | |
text: '_Please vote using reactions_', | |
attachments: [ | |
{ | |
color: '#0000DD', | |
title: title, | |
text: options.join('\n') | |
} | |
] | |
} | |
}; | |
} | |
/** | |
* @params {object} request, response | |
*/ | |
process_outgoing_response({ request, response }) { | |
} | |
} |
Made a post there.
…On Thu, Oct 15, 2020 at 9:31 PM Diego Sampaio ***@***.***> wrote:
***@***.**** commented on this gist.
------------------------------
@wajeeh-devsinc <https://github.com/wajeeh-devsinc> please post any
issues on the app repository
https://github.com/sampaiodiego/rocket.chat.app-poll
the issue you're describing looks like something with permissions.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<https://gist.github.com/db4b60717e7ac0051024dde23c6a902e#gistcomment-3490746>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AMCZKAWCJ53UGT4ENIUKV73SK4PWVANCNFSM4IORHEHQ>
.
Hello need help for full commadline creation of poll
am calling poll creation using
/api/v1/commands.run
with following params
{
"command": "poll",
"roomId":"zDSutedKQTqxY42D2",
"params": "'Question?' 'op1' 'op2'",
"triggerId":"NPgkh84FbQ6wsry2L"
}
it return success but in chat no polls are being created.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@wajeeh-devsinc please post any issues on the app repository https://github.com/sampaiodiego/rocket.chat.app-poll
the issue you're describing looks like something with permissions.