wilhelmklopp / simple-poll

:bar_chart: Create native and simple polls in Slack.
195 stars 25 forks source link

Configurable emoji #4

Closed mrdavidjcole closed 8 years ago

mrdavidjcole commented 8 years ago

The people have spoken:

image

Any plans to make the emoji configurable? Perhaps it could take the form of...

/poll "question" "choice one" :some_emoji: "choice two" :another_emoji:

P.S. Great tool you've built here :smiley:

wilhelmklopp commented 8 years ago

This is a great idea!

My first thought was that this would add a level of complexity that most users wouldn't like, but I think this can totally be a power user feature :)

The way it will probably work is that this won't be part of the tooltip that explains how the Simple Poll slash command works, but it will be there for everybody to use who knows it exists.

Looking forward to building this!

Thanks for the feedback and advice :+1:

P.S.: Nice emoji you have there ;)

waterfoul commented 8 years ago

+1 I'd love to have this feature, I'd prefer the syntax be /poll "question" :some_emoji: "choice one" :another_emoji: "choice two" to match how it looks in the message but i's more of a stylistic choice

Just cause I was curious I looked at the code and looks like support for this could be added by modifying simple-poll/main/views.py in the following ways (not a recommendation, just a potential solution)

  1. lines 86-93 replace this with a regex matcher using this regex: /(?::([^:]): )?"([^"])"/
  2. Change line 88 to ignore the emoji syntax
  3. Change line 102 to check if an emoji was supplied and use it instead of the number
wilhelmklopp commented 8 years ago

Thanks for this!

I actually wrote the code for this last weekend, and it's currently deployed to my staging environment where I am still testing it.

The regular expression I ended up using was (:[a-z0-9-_+]+:){1,2}

Hope to get this deployed to production over the weekend ;)

wilhelmklopp commented 8 years ago

This is now supported!

Example: /poll "question" "choice one" :robot_face: "choice two"

Output: Custom emoji output