1

当我创建一个组并添加一个新成员时(新添加的成员的号码是用于登录 yowsup 的号码),我想向所有成员发送通知说“你好!”。这个回复应该是自动的。我该怎么做呢?

我在文件 demos/cli/layer.py 中添加了一个函数

def createGroupMessage(self, groupID,messageBody):
    groupID = groupID + "@g.us" 
    outgoingMessageProtocolEntity = TextMessageProtocolEntity(
    messageBody,
    to = groupID
    )
    print outgoingMessageProtocolEntity
    self.toLower(outgoingMessageProtocolEntity)

在进行必要的导入后,我试图在文件 layers/protocol_groups/protocolentities/notification_groups_create.py 中调用它:

def init(self, id, from, timestamp, notify, participant, offline,
    createType, groupId, creationTimestamp, creatorJid,
    subject, subjectTime, subjectOwnerJid,
    participants):
    super(CreateGroupsNotificationProtocolEntity, self).__init(_id, _from, timestamp, notify, participant, offline)
    self.setGroupProps(createType, groupId, creationTimestamp, creatorJid, subject, subjectTime, subjectOwnerJid, participants)
    self.foo1 = YowsupCliLayer()
    self.foo1.createGroupMessage(groupId,"Hello !\n")

虽然代码没有给出错误,但当我添加 yowsup 号码时,我没有收到任何消息。

我得到的输出是:

Message:
ID: 1442859669-5
To: 919xxxxxx515-1442843444@g.us
Type:  text
Timestamp: 1442859669
Body: Hello !!


Printing notification..
w:gp2

Notification: Notification
From: 919xxxxxx515-1442843444@g.us
Type: w:gp2
Participant: 919xxxxxx515@s.whatsapp.net
Creator: 919xxxxxx515@s.whatsapp.net
Create type: None
Creation timestamp: 1442843444
Subject: FBI
Subject owner: 919xxxxxx515@s.whatsapp.net
Subject timestamp: 1442843444
Participants: {'919xxxxxx515@s.whatsapp.net': 'admin', '91886xxxxx5@s.whatsapp.net': None}

请让我知道我哪里出错了或者我该如何解决这个问题?谢谢!

4

0 回答 0