File Coverage

blib/lib/Mojo/Weixin/Model/Remote/_webwxupdatechatroom.pm
Criterion Covered Total %
statement 0 38 0.0
branch 0 30 0.0
condition n/a
subroutine 0 1 0.0
pod n/a
total 0 69 0.0


line stmt bran cond sub pod time code
1             sub Mojo::Weixin::_webwxupdatechatroom {
2 0     0     my $self = shift;
3 0           my $fun = shift;
4 0           my $api = 'https://' .$self->domain . '/cgi-bin/mmwebwx-bin/webwxupdatechatroom';
5 0 0         if($fun eq "mod"){
    0          
    0          
6 0           my $group = shift;
7 0           my $displayname = shift;
8 0 0         if(not defined $displayname){
9 0           $self->error("_webwxupdatechatroom invaild displayname");
10 0           return;
11             }
12 0           my @query_string = (
13             fun => 'modtopic',
14             );
15 0 0         push @query_string,(pass_ticket => $self->url_escape($self->pass_ticket)) if $self->pass_ticket;
16 0           my $post = {
17             BaseRequest => {
18             Uin => $self->wxuin,
19             Sid => $self->wxsid,
20             Skey => $self->skey,
21             DeviceID => $self->deviceid,
22             },
23             ChatRoomName => $group->id,
24             NewTopic => $displayname,
25             };
26              
27 0           my $json = $self->http_post($self->gen_url($api,@query_string),{json=>1,Referer=>'https://' . $self->domain . '/'},json=>$post);
28 0 0         return if not defined $json;
29 0 0         return if $json->{BaseResponse}{Ret}!=0;
30 0           return 1;
31             }
32             elsif($fun eq "add"){
33 0           my $group = shift;
34 0           my @member = @_;
35 0 0         my $mode = ($group->members + @member)>=40?'invitemember':'addmember';
36 0           my @query_string = (
37             fun => $mode,
38             );
39 0 0         push @query_string,(pass_ticket => $self->url_escape($self->pass_ticket)) if $self->pass_ticket;
40 0           my $post = {
41             BaseRequest => {
42             Uin => $self->wxuin,
43             Sid => $self->wxsid,
44             Skey => $self->skey,
45             DeviceID => $self->deviceid,
46             },
47             ChatRoomName => $group->id,
48             };
49 0 0         $post->{($mode eq 'invitemember'?'InviteMemberList':'AddMemberList')} = join(",",map{ $_->id } @member);
  0            
50 0           my $json = $self->http_post($self->gen_url($api,@query_string),{json=>1,Referer=>'https://' . $self->domain . '/'},json=>$post);
51 0 0         return if not defined $json;
52 0 0         return if $json->{BaseResponse}{Ret}!=0;
53 0           return 1;
54             }
55             elsif($fun eq "del"){
56 0           my $group = shift;
57 0           my @member = @_;
58 0           my @query_string = (
59             fun => 'delmember',
60             );
61 0 0         push @query_string,(pass_ticket => $self->url_escape($self->pass_ticket)) if $self->pass_ticket;
62             my $post = {
63             BaseRequest => {
64             Uin => $self->wxuin,
65             Sid => $self->wxsid,
66             Skey => $self->skey,
67             DeviceID => $self->deviceid,
68             },
69             ChatRoomName => $group->id,
70 0           DelMemberList => join(",",map{ $_->id } @member),
  0            
71             };
72 0           my $json = $self->http_post($self->gen_url($api,@query_string),{json=>1,Referer=>'https://' . $self->domain . '/'},json=>$post);
73 0 0         return if not defined $json;
74 0 0         return if $json->{BaseResponse}{Ret}!=0;
75 0           return 1;
76            
77             }
78             }
79             1;
80