How to use loadKeyboard method in pyatom

Best Python code snippet using pyatom_python

create_buttons.py

Source:create_buttons.py Github

copy

Full Screen

...29 async def CreateButtonURL(self, message: types.Message, state: FSMContext):30 if message.text not in self.button_url:31 self.button_url.append(message.text)32 await AdminCreatePost.continues.set()33 keyboard = self.keyboard.loadKeyboard('create_buttons_admin')[0]34 await message.answer(getText('create_button_next'), reply_markup=self.keyboard.inline(keyboard))35 else:36 await message.delete()37 await message.answer('Такая ссылка уже используется! Укажите другую ссылку!')38 async def CreateButtonsContinues(self, CallbackQuery: types.CallbackQuery, state: FSMContext):39 if CallbackQuery.data == 'createButtonYes':40 await AdminCreatePost.title.set()41 await CallbackQuery.message.edit_text(getText('title_button'))42 elif CallbackQuery.data == 'createButtonNo':43 async with state.proxy() as data:44 data['buttons'] = self.keyboard.InlineMenu(self.button_names, self.button_url)45 self.button_names, self.button_url = list(), list()46 await AdminCreatePost.time.set()47 admin_exit = self.keyboard.loadKeyboard('cancellation')[0]48 await CallbackQuery.message.edit_text(getText('time'), reply_markup=self.keyboard.inline(admin_exit))49 await CallbackQuery.answer()50 def registerHandlers(self, dp: Dispatcher):51 dp.register_message_handler(self.createButtonsTitle, content_types='text',52 state=AdminCreatePost.title, is_admin=True, chat_private=True)53 dp.register_message_handler(self.CreateButtonURL, content_types='text',54 state=AdminCreatePost.url, is_admin=True, chat_private=True, is_url=True)55 dp.register_callback_query_handler(self.CreateButtonsContinues,56 Text(equals=self.keyboard.loadKeyboard('create_buttons_admin')[1],57 ignore_case=True),...

Full Screen

Full Screen

help.py

Source:help.py Github

copy

Full Screen

1from main import api, plugins, telepot, json, keyboard2def plugi(plg='plugin_all', arg=None):3 desc = '📝 Commands List: \n{}'4 jump = '\n'5 if plg == "plugin_all": 6 desc = desc + "\nsend <code>/help name|number</code> to see how the command works."7 plugin = plugins.plugins_all8 else:9 if plg == "plugin_entertainment": plugin = plugins.plugin_entertainment10 elif plg == "plugin_utility": plugin = plugins.plugin_utility11 elif plg == "plugin_admin": plugin = plugins.plugin_admin12 lista = [aPlug for aPlug in plugin if (not aPlug["usage"] == False) and (not aPlug["usage"] is None)]13 for num,plug in enumerate(lista):14 if arg != None:15 desc = None16 if arg.lower() == plug['name'].lower() or str(arg) ==str(num): 17 jump = '📝 This is the description for the command: {}\n{}'.format(arg, plug['usage'])18 else:19 if plg != "plugin_all": jump = jump + "{}\n".format(plug['usage'])20 else: jump = jump + "{} - {}\n".format(num,lista[num]['name'])21 if desc is not None: jump = desc.format(jump)22 elif len(jump) < 2: jump = 'You typed something invalid.'23 return jump24def Function(msg, cmd):25 if 'cb' in msg:26 try: api.editMessageText((msg['chat']['id'], msg['message_id']), plugi(cmd[0]),27 parse_mode='HTML',reply_markup=keyboard.loadkeyboard(cmd[0]))28 except: return False29 elif (len(cmd) <= 1):30 if (cmd[0] == "start"):31 if msg['chat']['type'] != 'private': return False32 else:33 start="Hello, I'm a simple bot I'm still learning.\nWhat can I do for you right now?\n\nSend /help right now to know!"34 api.sendMessage(msg['chat']['id'],"{}".format(start), "HTML", reply_markup=keyboard.loadkeyboard('start'))35 return False36 else:37 return plugi()38 else:39 try:40 return plugi(arg=cmd[1])41 except: return 'You typed something invalid.'42plugin = {43 'patterns': [44 "^[/!]((?:help)|(?:start))$",45 "^[/!](help) ((\d+)|(\w+))$",46 "^###cb: ((?:plugin_all)|(?:plugin_admin)|(?:plugin_utility)|(?:plugin_entertainment))$",47 ],48 'function': Function,49 'name': "Help",50 'admin': False,51 'sudo': False, 52 'usage': '<code>/help</code>: Show list of plugins\n<code>/help name or number</code>: Commands for that plugin',...

Full Screen

Full Screen

keyboard.py

Source:keyboard.py Github

copy

Full Screen

1import settings2__all__ = ['loadkeyboard', 'start', 'plugin_all', 'plugin_admin', 'plugin_utility', 'plugin_entertainment']3def loadkeyboard(key):4 import json5 global keyboardLIST6 if key in __all__:7 keyboard = json.dumps(keyboardLIST[key])8 return keyboard9 else: return False10keyboardLIST = dict()11keyboardLIST['start'] = { "inline_keyboard": [12 [{"url": 'https://t.me/{}?startgroup=start'.format(settings.BOT_USERNAME), "text": '👥 Add in group'},13 {"url": 'https://t.me/{}'.format(settings.CHANNEL), "text": '👁‍🗨 Official Channel'}],14 [{"callback_data": "plugin_all","text": '⚙ Command'}]]15}16keyboardLIST['plugin_all'] = { "inline_keyboard": [17 [{"callback_data": "plugin_admin", "text": "👤 admin"}],18 [{"callback_data": "plugin_utility", "text": "🛠 utility"}],19 [{"callback_data": "plugin_entertainment","text": "💈 entertainment"}]]20}21keyboardLIST['plugin_admin'] = { "inline_keyboard": [22 [{"callback_data": "plugin_utility", "text": "🛠 utility"}],23 [{"callback_data": "plugin_entertainment","text": "💈 entertainment"}],24 [{"callback_data": "plugin_all","text": "🔙 All Commands"}]]25}26keyboardLIST['plugin_utility'] = { "inline_keyboard": [27 [{"callback_data": "plugin_admin", "text": "👤 admin"}],28 [{"callback_data": "plugin_entertainment","text": "💈 entertainment"}],29 [{"callback_data": "plugin_all","text": "🔙 All Commands"}]]30}31keyboardLIST['plugin_entertainment'] = { "inline_keyboard": [32 [{"callback_data": "plugin_admin", "text": "👤 admin"}],33 [{"callback_data": "plugin_utility", "text": "🛠 utility"}],34 [{"callback_data": "plugin_all","text": "🔙 All Commands"}]]...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run pyatom automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful