コード例 #1
0
        protected override async Task OnMemberJoinAsync(MemberJoinEvent ev)
        {
            if (ev.Source.Id == groupId)
            {
                var User_Name = lineMessagingClient.GetGroupMemberProfileAsync(ev.Source.Id, ev.Joined.Members[0].UserId);

                //入会時
                var messages = new ISendMessage[]
                {
                    new FlexMessage("こんにちは", FlexMessageText.Flex_Greeting(), null, sender_admin)
                };

                await lineMessagingClient.ReplyMessageAsync(ev.ReplyToken, messages);

                //CosmosDB
                await database.MemberAdd(new Member
                {
                    id         = ev.Joined.Members[0].UserId,
                    name       = User_Name.Result.DisplayName,
                    newername  = User_Name.Result.DisplayName,
                    joinedDate = DateTime.UtcNow.AddHours(9).ToString("yyyy/MM/dd h:mm"),
                    leavedDate = null
                });
            }
        }
コード例 #2
0
 protected override async Task OnMemberJoinAsync(MemberJoinEvent ev)
 {
     //メンバー参加イベント
     //member joined event
     //リプライ可能 Replyable
     //https://developers.line.biz/ja/reference/messaging-api/#member-joined-event
     //https://developers.line.biz/en/reference/messaging-api/#member-joined-event
 }
コード例 #3
0
        //自訂解析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);
            }
        }
コード例 #4
0
 protected override Task OnMemberJoinAsync(MemberJoinEvent ev)
 {
     Console.WriteLine($"OnMemberJoinAsync( Members: [{string.Join(",",ev.Joined.Members.Select(m=>m.UserId))}]");
     return(base.OnMemberJoinAsync(ev));
 }
コード例 #5
0
 protected virtual Task OnMemberJoinAsync(MemberJoinEvent ev) => Task.CompletedTask;