示例#1
0
 protected override async Task OnMemberLeaveAsync(MemberLeaveEvent ev)
 {
     //メンバー退出イベント
     //menber left event
     //https://developers.line.biz/ja/reference/messaging-api/#member-left-event
     //https://developers.line.biz/en/reference/messaging-api/#member-left-event
 }
示例#2
0
        protected override async Task OnMemberLeaveAsync(MemberLeaveEvent ev)
        {
            if (ev.Source.Id == groupId)
            {
                //CosmosDB
                await database.MemberLeave(ev.Left.Members[0].UserId);

                var mes1 = new ISendMessage[]
                {
                    new TextMessage("グループに参加していただきありがとうございました。このBOTはブロック削除をしてください。", null, sender_admin)
                };
                var mes2 = new ISendMessage[]
                {
                    new TextMessage("誰かが退会しました", null, sender_admin)
                };

                await lineMessagingClient.PushMessageAsync(ev.Left.Members[0].UserId, mes1);

                await lineMessagingClient.PushMessageAsync(Environment.GetEnvironmentVariable("ADMIN_GROUP"), mes2);
            }
        }
        //自訂解析JSON傳回物件的邏輯
        public override object ReadJson(JsonReader reader, Type objectType,
                                        object existingValue, JsonSerializer serializer)
        {
            JObject jo = JObject.Load(reader);
            //先取得JobType,由其決定建立物件
            string type = jo["type"].ToString();

            switch (type)
            {
            case Event.MESSAGE_TYPE:
                reader = jo["message"].CreateReader();
                MessageConverter messageConverter = new MessageConverter();
                object           message          = messageConverter.ReadJson(reader, typeof(Message), existingValue, serializer);

                MessageEvent mEv = new MessageEvent();
                serializer.Populate(jo.CreateReader(), mEv);
                mEv.Message = (Message)message;
                return(mEv);

            case Event.UNFOLLOW_TYPE:
            case Event.LEAVE_TYPE:
                Event ufEv = new Event(type);
                serializer.Populate(jo.CreateReader(), ufEv);
                return(ufEv);

            case Event.POST_BACK_TYPE:
                PostbackEvent pbEv = new PostbackEvent();
                serializer.Populate(jo.CreateReader(), pbEv);
                return(pbEv);

            case Event.MEMBER_LEAVE_TYPE:
                MemberLeaveEvent mlEv = new MemberLeaveEvent();
                serializer.Populate(jo.CreateReader(), mlEv);
                return(mlEv);

            case Event.MEMBER_JOIN_TYPE:
                MemberJoinEvent mjEv = new MemberJoinEvent();
                serializer.Populate(jo.CreateReader(), mjEv);
                return(mjEv);

            case Event.JOIN_TYPE:
            case Event.FOLLOW_TYPE:
                FollowJoinEvent fEv = new FollowJoinEvent();
                serializer.Populate(jo.CreateReader(), fEv);
                return(fEv);

            case Event.DEVICE_UN_LINK_TYPE:
                DeviceULinkEvent dulEv = new DeviceULinkEvent();
                serializer.Populate(jo.CreateReader(), dulEv);
                return(dulEv);

            case Event.BEACON_TYPE:
                BeaconEvent bEv = new BeaconEvent();
                serializer.Populate(jo.CreateReader(), bEv);
                return(bEv);

            case Event.ACCOUNT_LINK_TYPE:
                AccountLinkEvent alEv = new AccountLinkEvent();
                serializer.Populate(jo.CreateReader(), alEv);
                return(alEv);

            default:
                throw new ApplicationException("Unsupported type: " + type);
            }
        }
 protected override Task OnMemberLeaveAsync(MemberLeaveEvent ev)
 {
     Console.WriteLine($"OnMemberJoinAsync( Members: [{string.Join(",", ev.Left.Members.Select(m => m.UserId))}]");
     return(base.OnMemberLeaveAsync(ev));
 }
示例#5
0
 protected virtual Task OnMemberLeaveAsync(MemberLeaveEvent ev) => Task.CompletedTask;