| 1 | package Webqq::Client::Plugin::SendMsgFromMsg; | ||
| 2 | use Webqq::Client::Util qw(console); | ||
| 3 | my %GROUP_MARKNAME = qw( | ||
| 4 | test IT狂人 | ||
| 5 | a PERL学习交流 | ||
| 6 | b perl技术 | ||
| 7 | c PERL | ||
| 8 | ); | ||
| 9 | |||
| 10 | sub call{ | ||
| 11 | my $client = shift; | ||
| 12 | my $msg = shift; | ||
| 13 | if($msg->{content} =~/^(?::m)(?:\n|[\t ]+)(.*?)(?:\n^|[\t ]+)(?::e)$/ms){ | ||
| 14 | my $command = $1; | ||
| 15 | open my $fh,"<",\$command or return; | ||
| 16 | while(<$fh>){ | ||
| 17 | chomp; | ||
| 18 | my $line = $_; | ||
| 19 | console "从消息接收到发送消息指令: " . $line . "\n"; | ||
| 20 | my($group,$content) = split(/\s+/,$line,2); | ||
| 21 | $group = $GROUP_MARKNAME{$group} if exists $GROUP_MARKNAME{$group}; | ||
| 22 | my $gid = undef; | ||
| 23 | for(@{$client->{qq_database}{group_list}}){ | ||
| 24 | if($_->{name} eq $group or $_->{markname} eq $group){ | ||
| 25 | $gid = $_->{gid} ; | ||
| 26 | last; | ||
| 27 | } | ||
| 28 | } | ||
| 29 | if(defined $gid){ | ||
| 30 | $client->send_group_message( | ||
| 31 | $client->create_group_msg( to_uin=>$gid,content=>$content) | ||
| 32 | ); | ||
| 33 | } | ||
| 34 | } | ||
| 35 | |||
| 36 | close $fh; | ||
| 37 | } | ||
| 38 | |||
| 39 | return 1; | ||
| 40 | } | ||
| 41 | |||
| 42 | 1; |