- edit_message hinzugefügt
- Twitter_send editiert jetzt die Anmeldenachhricht
This commit is contained in:
parent
ee10b75cfc
commit
e2d27a3754
@ -71,9 +71,9 @@ function twitter_send:do_twitter_authorization_flow(hash, is_chat)
|
|||||||
|
|
||||||
local auth_url = client:BuildAuthorizationUrl({ oauth_callback = callback_url, force_login = true })
|
local auth_url = client:BuildAuthorizationUrl({ oauth_callback = callback_url, force_login = true })
|
||||||
if is_chat then
|
if is_chat then
|
||||||
return 'Bitte schließe den Vorgang ab, indem du unten auf den Link klickst und mir die angezeigte PIN per `/tw auth PIN` *im Chat von gerade* übergibst.\n[Bei Twitter anmelden]('..auth_url..')'
|
return 'Bitte schließe den Vorgang ab, indem du unten auf den attraktiven Button klickst und mir die angezeigte PIN per `/tw auth PIN` *in der Gruppe von gerade eben* übergibst.', auth_url
|
||||||
else
|
else
|
||||||
return 'Bitte schließe den Vorgang ab, indem du unten auf den Link klickst und mir die angezeigte PIN per `/tw auth PIN` übergibst.\n[Bei Twitter anmelden]('..auth_url..')'
|
return 'Bitte schließe den Vorgang ab, indem du unten auf den attraktiven Button klickst und mir die angezeigte PIN per `/tw auth PIN` übergibst.', auth_url
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -283,19 +283,20 @@ function twitter_send:action(msg, config, matches)
|
|||||||
utilities.send_reply(self, msg, config.errors.sudo)
|
utilities.send_reply(self, msg, config.errors.sudo)
|
||||||
return
|
return
|
||||||
else
|
else
|
||||||
-- maybe we can edit the older message to update it to "logged in!"?
|
local text, auth_url = twitter_send:do_twitter_authorization_flow(hash, true)
|
||||||
-- this should be interesting: https://core.telegram.org/bots/api#editmessagetext
|
local res = utilities.send_message(self, msg.from.id, text, true, nil, true, '{"inline_keyboard":[[{"text":"Bei Twitter anmelden","url":"'..auth_url..'"}]]}')
|
||||||
local text = twitter_send:do_twitter_authorization_flow(hash, true)
|
|
||||||
local res = utilities.send_message(self, msg.from.id, text, true, nil, true)
|
|
||||||
if not res then
|
if not res then
|
||||||
utilities.send_reply(self, msg, 'Bitte starte mich zuerst [privat](http://telegram.me/' .. self.info.username .. '?start).', true)
|
utilities.send_reply(self, msg, 'Bitte starte mich zuerst [privat](http://telegram.me/' .. self.info.username .. '?start).', true)
|
||||||
elseif msg.chat.type ~= 'private' then
|
elseif msg.chat.type ~= 'private' then
|
||||||
utilities.send_message(self, msg.chat.id, '_Bitte warten, der Administrator meldet sich an..._', true, nil, true)
|
local result = utilities.send_message(self, msg.chat.id, '_Bitte warten, der Administrator meldet sich an..._', true, nil, true)
|
||||||
|
redis:hset(hash, 'login_msg', result.result.message_id)
|
||||||
end
|
end
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
utilities.send_reply(self, msg, twitter_send:do_twitter_authorization_flow(hash), true)
|
local text, auth_url = twitter_send:do_twitter_authorization_flow(hash)
|
||||||
|
local result = utilities.send_reply(self, msg, text, true, '{"inline_keyboard":[[{"text":"Bei Twitter anmelden","url":"'..auth_url..'"}]]}')
|
||||||
|
redis:hset(hash, 'login_msg', result.result.message_id)
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -309,6 +310,9 @@ function twitter_send:action(msg, config, matches)
|
|||||||
end
|
end
|
||||||
if string.len(matches[2]) > 7 then utilities.send_reply(self, msg, 'Invalide PIN!') return end
|
if string.len(matches[2]) > 7 then utilities.send_reply(self, msg, 'Invalide PIN!') return end
|
||||||
utilities.send_reply(self, msg, twitter_send:get_twitter_access_token(hash, matches[2], oauth_token, oauth_token_secret))
|
utilities.send_reply(self, msg, twitter_send:get_twitter_access_token(hash, matches[2], oauth_token, oauth_token_secret))
|
||||||
|
local message_id = redis:hget(hash, 'login_msg')
|
||||||
|
utilities.edit_message(self, msg.chat.id, message_id, '*Anmeldung abgeschlossen!*', true, true)
|
||||||
|
redis:hdel(hash, 'login_msg')
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -27,13 +27,26 @@ function utilities:send_message(chat_id, text, disable_web_page_preview, reply_t
|
|||||||
} )
|
} )
|
||||||
end
|
end
|
||||||
|
|
||||||
function utilities:send_reply(old_msg, text, use_markdown)
|
-- https://core.telegram.org/bots/api#editmessagetext
|
||||||
|
function utilities:edit_message(chat_id, message_id, text, disable_web_page_preview, use_markdown, reply_markup)
|
||||||
|
return bindings.request(self, 'editMessageText', {
|
||||||
|
chat_id = chat_id,
|
||||||
|
message_id = message_id,
|
||||||
|
text = text,
|
||||||
|
disable_web_page_preview = disable_web_page_preview,
|
||||||
|
parse_mode = use_markdown and 'Markdown' or nil,
|
||||||
|
reply_markup = reply_markup
|
||||||
|
} )
|
||||||
|
end
|
||||||
|
|
||||||
|
function utilities:send_reply(old_msg, text, use_markdown, reply_markup)
|
||||||
return bindings.request(self, 'sendMessage', {
|
return bindings.request(self, 'sendMessage', {
|
||||||
chat_id = old_msg.chat.id,
|
chat_id = old_msg.chat.id,
|
||||||
text = text,
|
text = text,
|
||||||
disable_web_page_preview = true,
|
disable_web_page_preview = true,
|
||||||
reply_to_message_id = old_msg.message_id,
|
reply_to_message_id = old_msg.message_id,
|
||||||
parse_mode = use_markdown and 'Markdown' or nil
|
parse_mode = use_markdown and 'Markdown' or nil,
|
||||||
|
reply_markup = reply_markup
|
||||||
} )
|
} )
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user