|
@@ -0,0 +1,31 @@
|
|
|
+from rollbot import as_command, Attachment
|
|
|
+from rollbot.injection import Args, ArgList, SenderName, Origin
|
|
|
+
|
|
|
+# RWKGYBbPO
|
|
|
+EMOJIS = "🟥🟩🟨🟦🟫🟪🟧❤️💚💛💙🤎💜🧡"
|
|
|
+
|
|
|
+@as_command
|
|
|
+def poll(origin: Origin, name: SenderName, args: Args, arg_list: ArgList):
|
|
|
+ if origin != "DISCORD":
|
|
|
+ return "Polls only supported in Discord!"
|
|
|
+
|
|
|
+ for delim in ("|", ";", ","):
|
|
|
+ if delim in args:
|
|
|
+ opts = args.split(delim)
|
|
|
+ break
|
|
|
+ else:
|
|
|
+ opts = arg_list
|
|
|
+
|
|
|
+ if len(opts) > len(EMOJIS):
|
|
|
+ return f"Polls are limited to {len(EMOJIS)} options! Hardware limitation :\\("
|
|
|
+
|
|
|
+ if len(opts) == 0:
|
|
|
+ return "Can't make an empty poll!"
|
|
|
+
|
|
|
+ msg = f"Poll started by {name}\n\n"
|
|
|
+ atts = []
|
|
|
+ for e, o in zip(EMOJIS, opts):
|
|
|
+ msg += f"> {e} - **{o.strip()}**\n"
|
|
|
+ atts.append(Attachment(name="react", body=e))
|
|
|
+ msg += "\nPlease participate in democracy by picking the emojis corresponding to your choices!"
|
|
|
+ return msg, *atts
|