Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optional ReplyKeyboardMarkup creation depending on specific #8

Open
wants to merge 2 commits into
base: dev
Choose a base branch
from

Conversation

notetell
Copy link
Collaborator

No description provided.

…eplyKeyboardMarkup instead of InlineKeyboardMarkup for Telegram bridge
@notetell notetell requested a review from idchlife April 26, 2023 11:06
nil if keyboard_object.nil? || !keyboard_object.to_a.count.positive?

inline_keyboard = []
if output.specifics.has?(:tg_reply_keyboard) == false || output.specifics.get(:tg_reply_keyboard) == false
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Check for :tg_reply_keyboard == true
in this case - use reply keyboard

Otherwise, use inline keyboard by default

And only one check for get == nil is sufficient

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@@ -66,34 +66,34 @@ def setup
output_convert :keyboard, :tg_reply_markup do |keyboard_object, input, output|
nil if keyboard_object.nil? || !keyboard_object.to_a.count.positive?

if output.specifics.has?(:tg_reply_keyboard) == false || output.specifics.get(:tg_reply_keyboard) == false
inline_keyboard = []
if output.specifics.get :tg_reply_keyboard
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Better check explicitly for true because any object or something passed here will be considered truthy. Only falsy values are false, nil.

Just in case. I doubt there will be the case but just to be sure we won't have any side effects

else
regular_keyboard = []
inline_keyboard = []
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This whole if/else code can be refactored to reduce copypaste

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

In telegram, allow not inline, but keyboard buttons to be sent in keyboard
2 participants