修改MojoWeixin 只保留用户name 取消群昵称

<pre name="code" class="python">		if($msg->type eq "friend_message"){#接收到好友消息
             $sender = $msg->sender; #获取到该好友对象
			 $friend=$sender->displayname;
        #    print "我的好友:" . $sender->displayname . "给我发了一个消息,消息的内容是:" . $msg->content;
        }
        elsif($msg->type eq "group_message"){#接收到群消息
            my $group = $msg->group;    #获取到消息对应的群组对象
             $sender = $msg->sender;  #获取到发送该消息的群成员对象
             $friend=$sender->displayname;
        #    print $sender->displayname . "在群:", $group->displayname . "中发了一条消息,消息的内容是:" . $msg->content;
        }
        
		
		  $sender 对象内容:
		  
		  
$var is $VAR1 = bless( {
                 'id' => '@89c70523a465a6a42cc32cbaa7f2554563bf67776d021f32541986fb8c197974',
                 'city' => '',
                 'sex' => '',
                 'markname' => '',
                 'name' => '悠悠球',
                 '_group_id' => '@@afb74b7076b5b1dae582ffbb506ab8d354ef172d6ff58b654d9157b04e125235',
                 'province' => '',
                 'account' => '',
                 'signature' => '',
                 'display' => 'yy'
               }, 'Mojo::Weixin::Group::Member' );
			   
			   
查看display 方法:

sub displayname{
    my $self = shift;
    return $self->display || $self->markname || $self->name;
}

我们不需要取群昵称

修改为
sub displayname{
    my $self = shift;
    return  $self->name;
}

name: 微信昵称

display: 群昵称


 

你可能感兴趣的:(修改MojoWeixin 只保留用户name 取消群昵称)