@@ -1064,6 +1064,57 @@ def rich_menu_request_b
10641064
10651065 reply_text ( event , "[STATS]\n #{ stats } " )
10661066
1067+ when 'narrowcast'
1068+ request = Line ::Bot ::V2 ::MessagingApi ::NarrowcastRequest . new (
1069+ messages : [
1070+ Line ::Bot ::V2 ::MessagingApi ::TextMessage . new ( text : 'Hello, this is a narrowcast message' )
1071+ ] ,
1072+ filter : Line ::Bot ::V2 ::MessagingApi ::Filter . new (
1073+ demographic : Line ::Bot ::V2 ::MessagingApi ::OperatorDemographicFilter . new (
1074+ _or : [
1075+ Line ::Bot ::V2 ::MessagingApi ::OperatorDemographicFilter . new (
1076+ _and : [
1077+ Line ::Bot ::V2 ::MessagingApi ::AgeDemographicFilter . new (
1078+ gte : 'age_20' ,
1079+ lte : 'age_60'
1080+ ) ,
1081+ Line ::Bot ::V2 ::MessagingApi ::AppTypeDemographicFilter . new (
1082+ one_of : [ 'ios' ]
1083+ )
1084+ ]
1085+ ) ,
1086+ Line ::Bot ::V2 ::MessagingApi ::OperatorDemographicFilter . new (
1087+ _and : [
1088+ Line ::Bot ::V2 ::MessagingApi ::GenderDemographicFilter . new (
1089+ one_of : [ 'female' ]
1090+ ) ,
1091+ Line ::Bot ::V2 ::MessagingApi ::AreaDemographicFilter . new (
1092+ one_of : %w( jp_08 jp_09 jp_10 jp_11 jp_12 jp_13 jp_14 )
1093+ ) ,
1094+ ]
1095+ )
1096+ ]
1097+ )
1098+ )
1099+ )
1100+ _body , _status_code , headers = client . narrowcast_with_http_info ( narrowcast_request : request )
1101+ request_id = headers [ 'x-line-request-id' ]
1102+
1103+ reply_text ( event , "Narrowcast requested, requestId: #{ request_id } " )
1104+
1105+ client . show_loading_animation ( show_loading_animation_request : Line ::Bot ::V2 ::MessagingApi ::ShowLoadingAnimationRequest . new (
1106+ chat_id : event . source . user_id
1107+ ) )
1108+ sleep 5
1109+
1110+ response = client . get_narrowcast_progress ( request_id : request_id )
1111+ client . push_message ( push_message_request : Line ::Bot ::V2 ::MessagingApi ::PushMessageRequest . new (
1112+ to : event . source . user_id ,
1113+ messages : [
1114+ Line ::Bot ::V2 ::MessagingApi ::TextMessage . new ( text : "Narrowcast status: #{ response } " )
1115+ ]
1116+ ) )
1117+
10671118 else
10681119 if ( event . message . quoted_message_id != nil )
10691120 reply_text ( event , "[ECHO]\n #{ event . message . text } Thanks you for quoting my message!" )
0 commit comments