0

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?

4

2 回答 2

0

花了两个额外的步骤才能到达我想去的地方:

  1. chat.Members在需要时使用chat.MemberObjects
  2. 该机器人必须是CREATOR我的小三人测试帐户。它可能与谁添加了哪个用户有关。以前,我的机器人是 aMASTER而 user1 是CREATOR. 我不知道用户的 AdditionalBy 属性如何影响用户,但它确实起到了作用。现在我的机器人是CREATOR,我可以影响其他用户的角色。
于 2013-07-04T07:47:21.623 回答
0

我也有一个 Skype 机器人。
你可以这样做:

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

然后做

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

依此类推,这样您就可以在 Skype 上的聊天中键入命令,通过机器人降级/提升人员。

祝你好运 :)

于 2013-12-15T11:23:49.917 回答