1
0
mirror of https://github.com/danog/Telegram.git synced 2024-12-03 09:57:46 +01:00
Telegram/Watch/Bridge/TGBridgeBotReplyMarkup+TGBotReplyMarkup.m
2015-10-01 19:19:52 +03:00

41 lines
1.5 KiB
Objective-C

#import "TGBridgeBotReplyMarkup+TGBotReplyMarkup.h"
#import "TGMessage.h"
#import "TGBridgeMessage+TGMessage.h"
#import "TGBotReplyMarkup.h"
#import "TGBotReplyMarkupRow.h"
#import "TGBotReplyMarkupButton.h"
@implementation TGBridgeBotReplyMarkup (TGBotReplyMarkup)
+ (TGBridgeBotReplyMarkup *)botReplyMarkupWithTGBotReplyMarkup:(TGBotReplyMarkup *)botReplyMarkup message:(TGMessage *)message
{
if (botReplyMarkup == nil)
return nil;
TGBridgeBotReplyMarkup *bridgeReplyMarkup = [[TGBridgeBotReplyMarkup alloc] init];
bridgeReplyMarkup->_userId = botReplyMarkup.userId;
bridgeReplyMarkup->_messageId = botReplyMarkup.messageId;
bridgeReplyMarkup->_alreadyActivated = botReplyMarkup.alreadyActivated;
bridgeReplyMarkup->_hideKeyboardOnActivation = botReplyMarkup.hideKeyboardOnActivation;
NSMutableArray *rows = [[NSMutableArray alloc] init];
for (TGBotReplyMarkupRow *row in botReplyMarkup.rows)
{
NSMutableArray *buttons = [[NSMutableArray alloc] init];
for (TGBridgeBotReplyMarkupButton *button in row.buttons)
[buttons addObject:[[TGBridgeBotReplyMarkupButton alloc] initWithText:button.text]];
[rows addObject:[[TGBridgeBotReplyMarkupRow alloc] initWithButtons:buttons]];
}
bridgeReplyMarkup->_rows = rows;
if (message != nil && message.forceReply)
bridgeReplyMarkup->_message = [TGBridgeMessage messageWithTGMessage:message];
return bridgeReplyMarkup;
}
@end