def main(): res = None try: res = shelve.open('medias.dbm') bot = Client(config.bot_token) logging.info('starting bot...') admin_commands.bot_start_report(bot, res=res) start_bot(bot, res) except Exception as e: logging.exception('Bad things happend!') try: for admin in config.bot_admins: bot.send_text(admin, str(e)) except Exception: pass finally: if res: res.close()
from soroush_python_sdk import Client bot_token = 'your bot token' bot = Client(bot_token) try: to = 'user chat_id' [error, success] = bot.send_text(to, 'Your text') if success: print('Message sent successfully') else: print('Sending message failed: {}'.format(error)) except Exception as e: print(e.args[0])
# 2 rows. each row is a list of button dictionaries, each button is a dictionary os {'text':'your text'} keyboard7 = bot.make_keyboard([[{ 'text': 'Row1Button1' }, { 'text': 'Row1Button2' }], [{ 'text': 'Row2Button1' }]]) # 2 rows. each row is a list of button dictionaries, each button is a dictionary os {'text': 'your text', 'command: 'your command'} keyboard8 = bot.make_keyboard([[{ 'text': 'Row1Button1', 'command': 'help' }, { 'text': 'Row1Button2', 'command': 'back' }], [{ 'text': 'Row2Button1', 'command': 'options' }]]) [error, success] = bot.send_text(to, 'Your text', keyboard=keyboard6) if success: print('Message sent successfully') else: print('Sending message failed: {}'.format(error)) except Exception as e: print(e.args[0])