(self, group_or_users, msg_type, msg,
is_to_all=False, preview=False,
send_ignore_reprint=0, client_msg_id=None)
| 310 | ) |
| 311 | |
| 312 | def _send_mass_message(self, group_or_users, msg_type, msg, |
| 313 | is_to_all=False, preview=False, |
| 314 | send_ignore_reprint=0, client_msg_id=None): |
| 315 | data = { |
| 316 | 'msgtype': msg_type, |
| 317 | 'send_ignore_reprint': send_ignore_reprint, |
| 318 | } |
| 319 | if client_msg_id is not None: |
| 320 | data['clientmsgid'] = client_msg_id |
| 321 | if not preview: |
| 322 | if isinstance(group_or_users, (tuple, list)): |
| 323 | # send by user ids |
| 324 | data['touser'] = group_or_users |
| 325 | endpoint = 'message/mass/send' |
| 326 | else: |
| 327 | # send by group id |
| 328 | data['filter'] = { |
| 329 | 'group_id': group_or_users, |
| 330 | 'is_to_all': is_to_all, |
| 331 | } |
| 332 | endpoint = 'message/mass/sendall' |
| 333 | else: |
| 334 | if not isinstance(group_or_users, six.string_types): |
| 335 | raise ValueError('group_or_users should be string types') |
| 336 | # 预览接口 |
| 337 | if self.OPENID_RE.match(group_or_users): |
| 338 | # 按照 openid 预览群发 |
| 339 | data['touser'] = group_or_users |
| 340 | else: |
| 341 | # 按照微信号预览群发 |
| 342 | data['towxname'] = group_or_users |
| 343 | endpoint = 'message/mass/preview' |
| 344 | |
| 345 | data.update(msg) |
| 346 | return self._post( |
| 347 | endpoint, |
| 348 | data=data |
| 349 | ) |
| 350 | |
| 351 | def send_mass_text(self, group_or_users, content, |
| 352 | is_to_all=False, preview=False, |
no test coverage detected