W
W
why22021-07-24 00:44:51
Python
why2, 2021-07-24 00:44:51

How to exit the default function?

You need to exit the function when the /stop command comes to the bot in order to connect another profile (hub), and then exit the hub function to connect default.

@bot.message_handler(commands=['default])
def default (message):	
    loop = asyncio.new_event_loop()
    asyncio.set_event_loop(loop)
    RPC = Presence(rpc)


    bts = [
      {
        'label': 'Twitch',
        'url': 'https://www.twitch.tv'
      },
      {
        'label': 'Steam', 
        'url': 'https://steamcommunity.com'
      }
    ]
    bot.send_message(message.chat.id, 'Подключаюсь')
    RPC.connect()
    bot.send_message(message.chat.id, 'Подключился')
    RPC.update(
      state = ' ...... ',
      details = '...',
      start = time(),
      buttons = bts, 
      large_image = '_-',
      small_image = 'b.l',
      large_text = '......',
      small_text = '...'
    )
    bot.send_message(message.chat.id, ', всё гуд')
@bot.message_handler(commands=['stop'])
def stop ():
    return default 
@bot.message_handler(commands=['hub'])
def hub (message):
  loop = asyncio.new_event_loop()
  asyncio.set_event_loop(loop)
  
  RPC=Presence('rpc2')

  bts=[
    {
      'label': '',
      'url': 'https://www.donationalerts.com'
    }
  ]
  bot.send_message(message.chat.id, 'Подключаюсь')
  RPC.connect()
  bot.send_message(message.chat.id, 'Подключился')
  RPC.update(
    state='*********',
    details='*******',
    start=time(),
    buttons=bts,
    large_image='p',
    small_image='pp',
    large_text='******',
    small_text='*****'
  )
  bot.send_message(message.chat.id, 'Сделал гряззьь')
bot.polling()

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question