CLIxIndia-Dev / MiTiRobot

A chatbot for Telegram
MIT License
0 stars 1 forks source link

Duplicated code for getting Keyboard Buttons #3

Open coleshaw opened 7 years ago

coleshaw commented 7 years ago

I see this action repeated quite a bit throughout the code:

        for x in children:
           if x.name is not None:
               button_list.append(x.name)
               buttons.append([KeyboardButton(text=x.name)])

It seems like you could make it a method on the Element class or just a standalone method (whichever makes more sense), to DRY up the code, and return both the button_list and buttons. I would also then suggest a set of tests against that method, to test for things like: