Pergunta

I have a skypebot with commands. One of the commands I'm trying to implement is "promote_to_master":

# chat is Skype4Py.chat.Chat object, user_string is str
def promote_to_master(self, chat, user_string):
    if self.is_creator_or_master(chat):
        for member in chat.Members:
            if member.Handle == user_string:
                logging.info("Member promoted")
                member.Role = Skype4Py.chatMemberRoleMaster

    return "Member promoted"

The bot is a MASTER, the target a USER. No errors are thrown, but the member's role is not changed in the chat. I do see the log entry. print type(member) shows <class 'Skype4Py.user.User'>, which it seems can't have a Role changed, but I'm not sure.

In the group chat, a commander uses: !promote user After running, using /whois user gives:

member: user
role: USER
subscribed: YES
banned: NO
online locations: [scrubbed]

Any thoughts?

Foi útil?

Solução

It took 2 extra steps to get to where I wanted to be:

  1. I was using chat.Members when I needed chat.MemberObjects
  2. The bot had to be the CREATOR for my little trio of testing accounts. It may have something to do with who adds which user. Previously, my bot was a MASTER and user1 was CREATOR. I don't know how a user's AddedBy property affects a user, but it does something. Now that my bot is CREATOR, I can affect other users' roles.

Outras dicas

I have a Skype bot as well.
You can do something like this:

                        elif msg.startswith('!listener '):
                    debug.action('!listener command executed.')
                    string = msg.replace('!listener ', '', 1)
                    send('/setrole '+string+' listener')

Then do

                        elif msg.startswith('!helper '):
                    debug.action('!helper command executed.')
                    string = msg.replace('!helper ', '', 1)
                    send('/setrole '+string+' helper')

and so on, so that way you can just type a command in chat on Skype to demote/promote people via the bot.

Good luck :)

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top