Page Menu
Home
Phabricator (Chris)
Search
Configure Global Search
Log In
Files
F117755
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Authored By
Unknown
Size
2 KB
Referenced Files
None
Subscribers
None
View Options
diff --git a/src/plugins/utility/poll.lua b/src/plugins/utility/poll.lua
index d4176ee..1f0a55e 100644
--- a/src/plugins/utility/poll.lua
+++ b/src/plugins/utility/poll.lua
@@ -1,60 +1,60 @@
--[[
mattata v2.1 - Poll Plugin
Create polls and quizzes via Telegram's native poll API.
]]
local plugin = {}
plugin.name = 'poll'
plugin.category = 'utility'
plugin.description = 'Create polls and quizzes'
plugin.commands = { 'poll', 'quiz' }
plugin.help = '/poll Question? | Option 1 | Option 2 | ... - Create a poll.\n/quiz Question? | Correct Answer | Wrong 1 | Wrong 2 - Create a quiz (first option is correct).'
local json = require('dkjson')
function plugin.on_message(api, message, ctx)
if not message.args or message.args == '' then
if message.command == 'quiz' then
return api.send_message(message.chat.id, 'Usage: /quiz Question? | Correct Answer | Wrong 1 | Wrong 2\n\nThe first option is the correct answer.')
end
return api.send_message(message.chat.id, 'Usage: /poll Question? | Option 1 | Option 2 | ...\n\nSeparate options with |. Minimum 2 options, maximum 10.')
end
-- Parse question and options
local parts = {}
for part in message.args:gmatch('[^|]+') do
part = part:match('^%s*(.-)%s*$')
if part ~= '' then
table.insert(parts, part)
end
end
if #parts < 3 then
return api.send_message(message.chat.id, 'You need at least a question and 2 options. Separate them with |.')
end
if #parts > 11 then
return api.send_message(message.chat.id, 'Maximum 10 options allowed.')
end
local question = parts[1]
local options = {}
for i = 2, #parts do
table.insert(options, parts[i])
end
local is_quiz = message.command == 'quiz'
local opts = {
is_anonymous = false
}
if is_quiz then
- opts.type = 'quiz'
- opts.correct_option_id = 0 -- First option is correct
+ opts.poll_type = 'quiz'
+ opts.correct_option_id = 0
end
return api.send_poll(message.chat.id, question, json.encode(options), opts)
end
return plugin
File Metadata
Details
Attached
Mime Type
text/x-diff
Expires
Thu, May 14, 9:30 PM (1 d, 7 h ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
62700
Default Alt Text
(2 KB)
Attached To
Mode
R69 mattata
Attached
Detach File
Event Timeline