Skip to content

Instantly share code, notes, and snippets.

@sng2c
Last active December 18, 2015 04:39
Show Gist options
  • Save sng2c/5727160 to your computer and use it in GitHub Desktop.
Save sng2c/5727160 to your computer and use it in GitHub Desktop.
#!/usr/bin/env perl
use strict;
use warnings;
use 5.010;
use Net::MyPeople::Bot;
use Data::Printer;
my $APIKEY = $ENV{MYPEOPLE_APIKEY};
my $bot = Net::MyPeople::Bot->new({apikey=>$APIKEY});
my $from = 0;
my $to = 1500;
my $before=0;
while($to != $from ){
my $half = $from + int(($to - $from) / 2);
last if( $before == $half );
say "$from..$to - send $half";
my $res;
$res = $bot->send('BU_wqPHjxmJKIxKcIrAQu-JiA00', 'X' x $half );
#$res = $bot->groupSend('GID_WZrl1', 'X' x $half );
p $res;
if( $res->{code} eq '200' ){
$from = $half;
}
else{
$to = $half;
}
$before = $half;
}
say "MAX LENGTH : ".$before;
@aanoaa
Copy link

aanoaa commented Jun 7, 2013

<sng2c> 2진 탐색으로 마플 send 최대길이 알아내기
<sng2c> aanoaa: 결과는 1000입니다.

@sng2c
Copy link
Author

sng2c commented Jun 7, 2013

send 테스트 0~1500

0..1500 - send 750
\ {
    code      200,
    message   "Success"
}
750..1500 - send 1125
\ {
    code      400,
    message   "Content length invalid"
}
750..1125 - send 937
\ {
    code      200,
    message   "Success"
}
937..1125 - send 1031
\ {
    code      400,
    message   "Content length invalid"
}
937..1031 - send 984
\ {
    code      200,
    message   "Success"
}
984..1031 - send 1007
\ {
    code      400,
    message   "Content length invalid"
}
984..1007 - send 995
\ {
    code      200,
    message   "Success"
}
995..1007 - send 1001
\ {
    code      400,
    message   "Content length invalid"
}
995..1001 - send 998
\ {
    code      200,
    message   "Success"
}
998..1001 - send 999
\ {
    code      200,
    message   "Success"
}
999..1001 - send 1000
\ {
    code      200,
    message   "Success"
}
MAX LENGTH : 1000

@sng2c
Copy link
Author

sng2c commented Jun 7, 2013

groupSend 테스트 0~5000

0..5000 - send 2500
\ {
    code      400,
    message   "Content length invalid"
}
0..2500 - send 1250
\ {
    code      400,
    message   "Content length invalid"
}
0..1250 - send 625
\ {
    code      200,
    message   "Success"
}
625..1250 - send 937
\ {
    code      200,
    message   "Success"
}
937..1250 - send 1093
\ {
    code      400,
    message   "Content length invalid"
}
937..1093 - send 1015
\ {
    code      400,
    message   "Content length invalid"
}
937..1015 - send 976
\ {
    code      200,
    message   "Success"
}
976..1015 - send 995
\ {
    code      200,
    message   "Success"
}
995..1015 - send 1005
\ {
    code      400,
    message   "Content length invalid"
}
995..1005 - send 1000
\ {
    code      200,
    message   "Success"
}
1000..1005 - send 1002
\ {
    code      400,
    message   "Content length invalid"
}
1000..1002 - send 1001
\ {
    code      400,
    message   "Content length invalid"
}
1000..1001 - send 1000
\ {
    code      200,
    message   "Success"
}
MAX LENGTH : 1000

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment