コード例 #1
0
        /// <summary>
        /// 删除公告
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void hyperLink_Click(object sender, RoutedEventArgs e)
        {
            Hyperlink   link = sender as Hyperlink;
            GroupNotice gn   = waitRemoveNotice = link.DataContext as GroupNotice;
            Border      bder = ((link.Parent as TextBlock).Parent as Grid).Parent as Border;

            if (gn != null)
            {
                if (IMClient.Views.MessageBox.ShowDialogBox("删除后不可恢复,确定删除?"))
                {
                    SDKClient.SDKClient.Instance.DeleteNotice(gn.NoticeId, gn.GroupId, gn.GroupName, gn.NoticeTitle, (result) =>
                    {
                        if (result.Item1)
                        {
                            App.Current.Dispatcher.Invoke(new Action(() =>
                            {
                                BeginAnimation(bder);
                            }));
                        }
                        else
                        {
                            App.Current.Dispatcher.Invoke(new Action(() =>
                            {
                                AppData.MainMV.TipMessage = "删除失败!";
                            }));
                        }
                    }, gn.NoticeType == 0 ? SDKClient.SDKProperty.NoticeType.Common : SDKClient.SDKProperty.NoticeType.Common);
                }
                else
                {
                    return;
                }
            }
        }
コード例 #2
0
        /// <summary>
        /// 校验数据合法性
        /// </summary>
        /// <param name="gn">数据实体</param>
        /// <returns></returns>
        private bool CheckDataLegal(GroupNotice gn)
        {
            if (!string.IsNullOrEmpty(gn.NoticeTitle) && !string.IsNullOrEmpty(gn.NoticeContent))
            {
                int titleLegth   = gn.NoticeTitle.Replace(" ", "").Length;
                int contentLegth = gn.NoticeContent.Replace(" ", "").Length;
                if (titleLegth < 4)
                {
                    this.sp_Error.Visibility = Visibility.Visible;
                    this.txb_ErrorTip.Text   = "标题至少需要4位!";
                    return(false);
                }

                if (contentLegth < 20)
                {
                    this.sp_Error.Visibility = Visibility.Visible;
                    this.txb_ErrorTip.Text   = "正文最少需要20位!";
                    return(false);
                }
                return(true);
            }
            else if (string.IsNullOrEmpty(gn.NoticeTitle))
            {
                this.sp_Error.Visibility = Visibility.Visible;
                this.txb_ErrorTip.Text   = "标题不能为空!";
                return(false);
            }
            else if (string.IsNullOrEmpty(gn.NoticeContent))
            {
                this.sp_Error.Visibility = Visibility.Visible;
                this.txb_ErrorTip.Text   = "内容不能为空!";
                return(false);
            }
            return(false);
        }
コード例 #3
0
        private void RefreshNoticeList(GroupNotice notice)
        {
            GroupNotice    gn  = this.DataContext as GroupNotice;
            GroupViewModel gvm = AppData.MainMV.GroupListVM.Items.ToList().FirstOrDefault(x => (x.Model as GroupModel).ID == gn.GroupId);

            gvm.AllNotice.Add(new GroupNotice()
            {
                GroupId       = notice.GroupId,
                ID            = notice.ID,
                GroupName     = notice.GroupName,
                IsCanOperate  = notice.IsCanOperate,
                NoticeId      = notice.NoticeId,
                IsToTop       = notice.IsToTop,
                NoticeContent = notice.NoticeContent,
                NoticeTitle   = notice.NoticeTitle,
                NoticeType    = notice.NoticeTitle.Equals("入群须知") ? 1 : 0
            });
            if (gvm.AllNotice.Any(x => x.NoticeType == 1))
            {
                App.Current.Dispatcher.Invoke(new Action(() =>
                {
                    gvm.AllNotice.OrderByDescending(x => x.NoticeType == 1).OrderByDescending(x => x.NoticeReleTime);
                    gvm.IsShowEmptyNotice         = false;
                    gvm.IsShowEmptyNoticeOrdinary = false;
                }));
            }
            else
            {
                App.Current.Dispatcher.Invoke(new Action(() =>
                {
                    gvm.AllNotice.OrderByDescending(x => x.NoticeReleTime);
                    gvm.IsShowEmptyNotice = true;
                }));
            }
        }
 GroupNotice IGroupNoticesInterface.this[UUI requestingAgent, UUID groupNoticeID]
 {
     get
     {
         var notice = new GroupNotice();
         if (!Notices.TryGetValue(requestingAgent, groupNoticeID, out notice))
         {
             throw new KeyNotFoundException();
         }
         return(notice);
     }
 }
コード例 #5
0
 void IGroupNoticesInterface.Add(UGUI requestingAgent, GroupNotice notice)
 {
     m_GroupNoticeToGroup.Add(notice.Group.ID, notice.ID);
     try
     {
         m_Groups[notice.Group.ID].Notices.Add(notice.Group.ID, new GroupNotice(notice));
     }
     catch
     {
         m_GroupNoticeToGroup.Remove(notice.Group.ID);
         throw;
     }
 }
コード例 #6
0
        bool IGroupNoticesInterface.TryGetValue(UGUI requestingAgent, UUID groupNoticeID, out GroupNotice groupNotice)
        {
            MemoryGroupInfo info;
            GroupNotice     notice;
            UUID            groupID;

            groupNotice = null;
            if (m_GroupNoticeToGroup.TryGetValue(groupNoticeID, out groupID) &&
                m_Groups.TryGetValue(groupID, out info) &&
                info.Notices.TryGetValue(groupNoticeID, out notice))
            {
                groupNotice = new GroupNotice(notice);
                return(true);
            }
            return(false);
        }
コード例 #7
0
 /// <summary>
 /// 添加入群须知
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void hyper_Link_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         if (this.DataContext is ChatViewModel cvm && cvm.TargetVM is GroupViewModel)
         {
             GroupViewModel gvm        = (this.DataContext as ChatViewModel).TargetVM as GroupViewModel;
             GroupViewModel gvm1       = AppData.MainMV.GroupListVM.Items.ToList().FirstOrDefault(x => x.ID == gvm.ID);
             GroupModel     groupModel = gvm1.Model as GroupModel;
             GroupNotice    gnTice     = gvm1.AllNotice.FirstOrDefault(x => x.NoticeTitle == "入群须知");
             if (gnTice != null)
             {
                 AppData.MainMV.TipMessage = "已添加入群须知";
                 return;
             }
             else
             {
                 App.Current.Dispatcher.Invoke(new Action(() =>
                 {
                     GroupModel gm  = (cvm.TargetVM as GroupViewModel).Model as GroupModel;
                     GroupNotice gn = new GroupNotice()
                     {
                         NoticeTitle    = "入群须知",
                         GroupId        = gm.ID,
                         GroupName      = gm.DisplayName,
                         NoticeReleTime = DateTime.Now,
                         IsCanOperate   = true,
                         NoticeType     = 1
                     };
                     if (!gvm.IsCreator)
                     {
                         gn.IsCanOperate = false;
                     }
                     GroupNoticeWindow gnw   = new GroupNoticeWindow(gn, "添加入群须知");
                     gnw.txb_Title.IsEnabled = false;
                     gnw.Owner = App.Current.MainWindow;
                     gnw.ShowDialog();
                 }));
             }
         }
     }
     catch (Exception ex)
     {
         MessageBox.ShowDialogBox(ex.Message);
     }
 }
コード例 #8
0
 /// <summary>
 /// 添加普通群公告
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void bd_AddNotice_PreviewMouseDown(object sender, MouseButtonEventArgs e)
 {
     if (this.DataContext is ChatViewModel cvm && cvm.TargetVM is GroupViewModel)
     {
         GroupModel  gm = (cvm.TargetVM as GroupViewModel).Model as GroupModel;
         GroupNotice gn = new GroupNotice()
         {
             GroupId        = gm.ID,
             GroupName      = gm.DisplayName,
             NoticeReleTime = DateTime.Now,
             IsCanOperate   = true,
             NoticeType     = 0
         };
         GroupNoticeWindow gnw = new GroupNoticeWindow(gn);
         gnw.Owner = App.Current.MainWindow;
         gnw.ShowDialog();
     }
 }
コード例 #9
0
ファイル: Group.cs プロジェクト: shadoskill/SecondBot
        public object GroupnoticeWithAttachment(string group, [FormField] string title, [FormField] string message, string attachment, string token)
        {
            if (tokens.Allow(token, "groups", "GroupnoticeWithAttachment", handleGetClientIP()) == false)
            {
                return(Failure("Token not accepted", "GroupnoticeWithAttachment", new [] { group, title, message, attachment }));
            }
            if (UUID.TryParse(group, out UUID groupuuid) == false)
            {
                return(Failure("Invaild group UUID", "GroupnoticeWithAttachment", new [] { group, title, message, attachment }));
            }
            if (UUID.TryParse(attachment, out UUID inventoryuuid) == false)
            {
                return(Failure("Invaild inventory UUID", "GroupnoticeWithAttachment", new [] { group, title, message, attachment }));
            }
            if (bot.MyGroups.ContainsKey(groupuuid) == false)
            {
                return(Failure("Unknown group", "GroupnoticeWithAttachment", new [] { group, title, message, attachment }));
            }
            if (helpers.notempty(title) == false)
            {
                return(Failure("Title empty", "GroupnoticeWithAttachment", new [] { group, title, message, attachment }));
            }
            if (helpers.notempty(message) == false)
            {
                return(Failure("Message empty", "GroupnoticeWithAttachment", new [] { group, title, message, attachment }));
            }
            Group G = bot.MyGroups[groupuuid];

            if (G.Powers.HasFlag(GroupPowers.SendNotices) == false)
            {
                return(Failure("Missing group notice power", "GroupnoticeWithAttachment", new [] { group, title, message, attachment }));
            }
            GroupNotice NewNotice = new GroupNotice();

            NewNotice.Subject      = title;
            NewNotice.Message      = message;
            NewNotice.OwnerID      = bot.GetClient.Self.AgentID;
            NewNotice.AttachmentID = inventoryuuid;
            bot.GetClient.Groups.SendGroupNotice(groupuuid, NewNotice);
            return(BasicReply("Sending notice with attachment", "GroupnoticeWithAttachment", new [] { group, title, message, attachment }));
        }
コード例 #10
0
        public GroupNoticeWindow(object _pageContext, string title = null) : this()
        {
            GroupNotice gnTice = _pageContext as GroupNotice;

            if (AppData.ordinaryGroupNoticeDic.Count > 0 || AppData.joinGroupNeedKnowDic.Count > 0)
            {
                if (gnTice.NoticeType == 0)
                {
                    if (AppData.ordinaryGroupNoticeDic.ContainsKey(gnTice.GroupId))
                    {
                        this.DataContext = AppData.ordinaryGroupNoticeDic[gnTice.GroupId];
                    }
                    else
                    {
                        this.DataContext = gnTice;
                    }
                }
                else
                {
                    if (AppData.joinGroupNeedKnowDic.ContainsKey(gnTice.GroupId))
                    {
                        this.DataContext = AppData.joinGroupNeedKnowDic[gnTice.GroupId];
                    }
                    else
                    {
                        this.DataContext = gnTice;
                    }
                }
            }
            else
            {
                this.pageContext = _pageContext;
                this.DataContext = pageContext;
            }
            if (!string.IsNullOrEmpty(title))
            {
                this.tbName.Text = title;
            }
            this.MouseLeftButtonDown += GroupNoticeWindow_MouseLeftButtonDown;
            this.Loaded += GroupNoticeWindow_Loaded;
        }
コード例 #11
0
        void IGroupNoticesInterface.Add(UGUI requestingAgent, GroupNotice notice)
        {
            var vals = new Dictionary <string, object>
            {
                ["GroupID"]           = notice.Group.ID,
                ["NoticeID"]          = notice.ID,
                ["Timestamp"]         = notice.Timestamp,
                ["FromName"]          = notice.Timestamp,
                ["Subject"]           = notice.Subject,
                ["Message"]           = notice.Message,
                ["HasAttachment"]     = notice.HasAttachment,
                ["AttachmentType"]    = notice.AttachmentType,
                ["AttachmentName"]    = notice.AttachmentName,
                ["AttachmentItemID"]  = notice.AttachmentItemID,
                ["AttachmentOwnerID"] = notice.AttachmentOwner.ID
            };

            using (var conn = new SqlConnection(m_ConnectionString))
            {
                conn.Open();
                conn.InsertInto("groupnotices", vals);
            }
        }
コード例 #12
0
        List <GroupNotice> IGroupNoticesInterface.GetNotices(UGUI requestingAgent, UGI group)
        {
            var notices = new List <GroupNotice>();

            using (var conn = new SqlConnection(m_ConnectionString))
            {
                conn.Open();
                using (var cmd = new SqlCommand("SELECT * FROM groupnotices WHERE GroupID = @groupid", conn))
                {
                    cmd.Parameters.AddParameter("@groupid", group.ID);
                    using (SqlDataReader reader = cmd.ExecuteReader())
                    {
                        while (reader.Read())
                        {
                            GroupNotice notice = reader.ToGroupNotice();
                            notice.Group = ResolveName(requestingAgent, notice.Group);
                            notices.Add(notice);
                        }
                    }
                }
            }

            return(notices);
        }
コード例 #13
0
        private void HandleGroupNotice(ViewerAgent agent, SceneInterface scene, ImprovedInstantMessage m)
        {
            /* no validation needed with IM, that is already done in circuit */
            var groupsService = scene.GroupsService;

            if (groupsService == null)
            {
                return;
            }

            UGI group;

            try
            {
                group = groupsService.Groups[agent.Owner, m.ToAgentID];
            }
            catch
            {
                return;
            }

            if ((GetGroupPowers(agent.Owner, groupsService, group) & GroupPowers.SendNotices) == 0)
            {
                return;
            }

            InventoryItem item = null;

            if (m.BinaryBucket.Length >= 1 && m.BinaryBucket[0] > 0)
            {
                try
                {
                    var iv = LlsdXml.Deserialize(new MemoryStream(m.BinaryBucket));
                    if (iv is Map)
                    {
                        var binBuck = (Map)iv;
                        var itemID  = binBuck["item_id"].AsUUID;
                        var ownerID = binBuck["owner_id"].AsUUID;
                        item = agent.InventoryService.Item[ownerID, itemID];
                    }
                }
                catch
                {
                    /* do not expose exceptions to caller */
                }
            }

            var gn = new GroupNotice
            {
                ID       = UUID.Random,
                Group    = group,
                FromName = agent.NamedOwner.FullName
            };
            var submsg = m.Message.Split(new char[] { '|' }, 2);

            gn.Subject          = submsg.Length > 1 ? submsg[0] : string.Empty;
            gn.Message          = submsg.Length > 1 ? submsg[1] : submsg[0];
            gn.HasAttachment    = item != null;
            gn.AttachmentType   = item != null ? item.AssetType : Types.Asset.AssetType.Unknown;
            gn.AttachmentName   = item != null ? item.Name : string.Empty;
            gn.AttachmentItemID = item != null ? item.ID : UUID.Zero;
            gn.AttachmentOwner  = item != null ? item.Owner : UGUI.Unknown;

            var gim = new GridInstantMessage
            {
                FromAgent    = agent.NamedOwner,
                Dialog       = GridInstantMessageDialog.GroupNotice,
                IsFromGroup  = true,
                Message      = m.Message,
                IMSessionID  = gn.ID,
                BinaryBucket = m.BinaryBucket
            };

            try
            {
                groupsService.Notices.Add(agent.Owner, gn);
                IMGroupNoticeQueue.Enqueue(new KeyValuePair <SceneInterface, GridInstantMessage>(scene, gim));
            }
            catch
            {
                /* do not expose exceptions to caller */
            }
        }
コード例 #14
0
        private void Grid_Click(object sender, RoutedEventArgs e)
        {
            Button btn = e.Source as Button;

            if (btn != null)
            {
                string uid = btn.Uid;
                switch (uid)
                {
                case "Cancel":
                case "Close":
                    GroupNotice groupNotice = this.DataContext as GroupNotice;
                    if (groupNotice != null)
                    {
                        if (groupNotice.NoticeType == 0)
                        {
                            if (!AppData.ordinaryGroupNoticeDic.ContainsKey(groupNotice.GroupId))
                            {
                                AppData.ordinaryGroupNoticeDic.Add(groupNotice.GroupId, groupNotice);
                            }
                        }
                        else
                        {
                            if (!AppData.joinGroupNeedKnowDic.ContainsKey(groupNotice.GroupId))
                            {
                                AppData.joinGroupNeedKnowDic.Add(groupNotice.GroupId, groupNotice);
                            }
                        }
                    }
                    this.Close();
                    break;

                case "Sure":
                    GroupNotice gn = this.DataContext as GroupNotice;
                    if (AppData.CanInternetAction())
                    {
                        if (gn != null)
                        {
                            List <ChatViewModel> list   = AppData.MainMV.ChatListVM.Items.ToList().Where(x => x.IsGroup).Where(x => x.TargetVM != null).ToList();
                            ChatViewModel        chatVM = list.FirstOrDefault(x => ((x.TargetVM as GroupViewModel).Model as GroupModel).ID == gn.GroupId);
                            if (gn.NoticeType == 0)
                            {
                                if (!AppData.ordinaryGroupNoticeDic.ContainsKey(gn.GroupId))
                                {
                                    AppData.ordinaryGroupNoticeDic.Add(gn.GroupId, gn);
                                }
                            }
                            else
                            {
                                if (!AppData.joinGroupNeedKnowDic.ContainsKey(gn.GroupId))
                                {
                                    AppData.joinGroupNeedKnowDic.Add(gn.GroupId, gn);
                                }
                            }
                            GroupViewModel gvm = AppData.MainMV.GroupListVM.Items.ToList().FirstOrDefault(x => (x.Model as GroupModel).ID == gn.GroupId);
                            if (CheckDataLegal(gn))
                            {
                                int index = 0;
                                //bool isFirstBadWordTitle = SDKClient.SDKProperty.stringSearchEx.FindFirst(gn.NoticeTitle, out index);
                                bool isContainsBadWordTitle = SDKClient.SDKProperty.stringSearchEx.ContainsAny(gn.NoticeTitle);
                                //bool isFirstBadWordContent = SDKClient.SDKProperty.stringSearchEx.FindFirst(gn.NoticeContent, out index);
                                bool isContainsBadWordContent = SDKClient.SDKProperty.stringSearchEx.ContainsAny(gn.NoticeContent);
                                if (!isContainsBadWordTitle && !isContainsBadWordContent)
                                {
                                    MessageModel msg = new MessageModel()
                                    {
                                        Sender   = AppData.Current.LoginUser.User,
                                        SendTime = DateTime.Now,
                                        MsgType  = MessageType.addgroupnotice,
                                        IsMine   = true,
                                        Content  = gn.NoticeContent
                                    };
                                    GroupNoticeModel gnModel = new GroupNoticeModel()
                                    {
                                        NoticeTitle        = gn.NoticeTitle,
                                        NoticeId           = gn.NoticeId,
                                        GroupMId           = (gvm.Model as GroupModel).ID,
                                        GroupNoticeContent = gn.NoticeContent
                                    };
                                    msg.NoticeModel = gnModel;
                                    msg.TipMessage  = string.Format("{0}", msg.NoticeModel.NoticeTitle);
                                    if (gn.NoticeTitle.Equals("入群须知"))
                                    {
                                        SDKClient.SDKClient.Instance.AddNotice(gn.NoticeTitle, gn.NoticeContent, gn.GroupId, gn.GroupName, (result) =>
                                        {
                                            if (result.Item1)
                                            {
                                                gn.NoticeId = result.Item2;
                                                App.Current.Dispatcher.Invoke(new Action(() =>
                                                {
                                                    AppData.MainMV.TipMessage = "发布成功!";
                                                    if (AppData.joinGroupNeedKnowDic.ContainsKey(gn.GroupId))
                                                    {
                                                        AppData.joinGroupNeedKnowDic.Remove(gn.GroupId);
                                                    }
                                                    gvm.RefreshNoticeList(gn);
                                                    msg.MsgKey       = result.Item3;
                                                    gnModel.NoticeId = result.Item2;
                                                    msg.NoticeModel  = gnModel;
                                                    chatVM.AddMessage(msg);
                                                }));
                                            }
                                            else
                                            {
                                                App.Current.Dispatcher.Invoke(new Action(() =>
                                                {
                                                    AppData.MainMV.TipMessage = "发布失败!";
                                                    if (!AppData.joinGroupNeedKnowDic.ContainsKey(gn.GroupId))
                                                    {
                                                        AppData.joinGroupNeedKnowDic.Add(gn.GroupId, gn);
                                                    }
                                                }));
                                            }
                                        }, SDKClient.SDKProperty.NoticeType.JoinGroupNotice);
                                    }
                                    else
                                    {
                                        SDKClient.SDKClient.Instance.AddNotice(gn.NoticeTitle, gn.NoticeContent, gn.GroupId, gn.GroupName, (result) =>
                                        {
                                            if (result.Item1)
                                            {
                                                gn.NoticeId = result.Item2;
                                                App.Current.Dispatcher.Invoke(new Action(() =>
                                                {
                                                    AppData.MainMV.TipMessage = "发布成功!";
                                                    if (AppData.ordinaryGroupNoticeDic.ContainsKey(gn.GroupId))
                                                    {
                                                        AppData.ordinaryGroupNoticeDic.Remove(gn.GroupId);
                                                    }
                                                    gvm.RefreshNoticeList(gn);
                                                    msg.MsgKey       = result.Item3;
                                                    gnModel.NoticeId = result.Item2;
                                                    msg.NoticeModel  = gnModel;
                                                    chatVM.AddMessage(msg);
                                                }));
                                            }
                                            else
                                            {
                                                App.Current.Dispatcher.Invoke(new Action(() =>
                                                {
                                                    AppData.MainMV.TipMessage = "发布失败!";
                                                    if (!AppData.ordinaryGroupNoticeDic.ContainsKey(gn.GroupId))
                                                    {
                                                        AppData.ordinaryGroupNoticeDic.Add(gn.GroupId, gn);
                                                    }
                                                }));
                                            }
                                        }, SDKClient.SDKProperty.NoticeType.Common);
                                    }
                                    this.Close();
                                }
                                else
                                {
                                    if (isContainsBadWordTitle)
                                    {
                                        TitleContainsBadWord(gn.NoticeTitle);
                                    }
                                    else
                                    {
                                        if (isContainsBadWordContent)
                                        {
                                            ContentContainsBadWord(gn.NoticeContent);
                                        }
                                    }
                                }
                            }
                            else
                            {
                                App.Current.Dispatcher.Invoke(new Action(() => {
                                    if (gn.NoticeType == 0)
                                    {
                                        if (AppData.ordinaryGroupNoticeDic.ContainsKey(gn.GroupId))
                                        {
                                            this.DataContext = AppData.ordinaryGroupNoticeDic[gn.GroupId];
                                        }
                                    }
                                    else
                                    {
                                        if (AppData.joinGroupNeedKnowDic.ContainsKey(gn.GroupId))
                                        {
                                            this.DataContext = AppData.joinGroupNeedKnowDic[gn.GroupId];
                                        }
                                    }
                                    //AppData.MainMV.TipMessage = "发布失败!";
                                }));
                                return;
                            }
                        }
                        //else
                        //{
                        //    App.Current.Dispatcher.Invoke(new Action(() =>
                        //    {
                        //        AppData.MainMV.TipMessage = "请检查数据合法性!";
                        //    }));
                        //}
                    }
                    else
                    {
                        App.Current.Dispatcher.Invoke(new Action(() =>
                        {
                            if (gn.NoticeType == 0)
                            {
                                if (!AppData.ordinaryGroupNoticeDic.ContainsKey(gn.GroupId))
                                {
                                    AppData.ordinaryGroupNoticeDic.Add(gn.GroupId, gn);
                                }
                            }
                            else
                            {
                                if (!AppData.joinGroupNeedKnowDic.ContainsKey(gn.GroupId))
                                {
                                    AppData.joinGroupNeedKnowDic.Add(gn.GroupId, gn);
                                }
                            }
                            AppData.MainMV.TipMessage = "网络异常,请检查网络设置!";
                        }));
                    }
                    break;
                }
            }
        }
コード例 #15
0
 /* TODO: revise this API */
 bool IGroupNoticesInterface.TryGetValue(UGUI requestingAgent, UUID groupNoticeID, out GroupNotice groupNotice)
 {
     groupNotice = null;
     return(false);
 }
コード例 #16
0
        /// <summary>
        /// Handler event for this plugin.
        /// </summary>
        /// <param name="b">A currently active RestBot</param>
        /// <param name="Parameters">A dictionary containing the message </param>
        /// <returns></returns>
        public override string Process(RestBot b, Dictionary <string, string> Parameters)
        {
            string      message;
            string      subject;
            UUID        groupUUID      = UUID.Zero;
            UUID        attachmentUUID = UUID.Zero;
            GroupNotice notice;

            try
            {
                if (Parameters.ContainsKey("subject"))
                {
                    subject = Parameters["subject"].ToString().Replace("%20", " ").Replace("+", " ");
                }
                else
                {
                    return("<error>No notice subject</error>");
                }

                if (Parameters.ContainsKey("message"))
                {
                    message = Parameters["message"].ToString().Replace("%20", " ").Replace("+", " ");
                }
                else
                {
                    return("<error>No notice message</error>");
                }

                if (Parameters.ContainsKey("group"))
                {
                    if (!UUID.TryParse(Parameters["group"].ToString().Replace("_", " "), out groupUUID))
                    {
                        return("<error>parsekey group</error>");
                    }
                }
                else
                {
                    return("<error>arguments: no group key</error>");
                }

                if (Parameters.ContainsKey("attachment"))
                {
                    if (!UUID.TryParse(Parameters["attachment"].ToString().Replace("_", " "), out attachmentUUID))
                    {
                        return("<error>parsekey attachment</error>");
                    }
                }
                else
                {
                    // just a warning, attachment can be empty
                    DebugUtilities.WriteWarning(session + " " + MethodName + " Notice has no attachment (no problem)");
                }

                DebugUtilities.WriteDebug(session + " " + MethodName + " Attempting to create a notice");

                /* This doesn't work as it should!
                 * if (!b.Client.Inventory.Store.Contains(attachmentUUID))
                 * {
                 *      DebugUtilities.WriteWarning(session + " " + MethodName + " Item UUID " + attachmentUUID.ToString() + " not found on inventory (are you using an Asset UUID by mistake?)");
                 *      attachmentUUID = UUID.Zero;
                 * }
                 */

                notice = new GroupNotice();

                notice.Subject      = subject;
                notice.Message      = message;
                notice.AttachmentID = attachmentUUID;                 // this is the inventory UUID, not the asset UUID
                notice.OwnerID      = b.Client.Self.AgentID;

                b.Client.Groups.SendGroupNotice(groupUUID, notice);

                DebugUtilities.WriteDebug($"{session} {MethodName} Sent Notice from avatar {notice.OwnerID.ToString()} to group: {groupUUID.ToString()} subject: '{notice.Subject.ToString()}' message: '{notice.Message.ToString()}' Optional attachment: {notice.AttachmentID.ToString()} Serialisation: {Utils.BytesToString(notice.SerializeAttachment())}");

                return("<notice>sent</notice>");
            }
            catch (Exception e)
            {
                DebugUtilities.WriteError(e.Message);
                return("<error>loads of errors</error>");
            }
        }
コード例 #17
0
        bool IGroupNoticesInterface.TryGetValue(UGUI requestingAgent, UUID groupNoticeID, out GroupNotice groupNotice)
        {
            GroupNotice gnot;

            if (m_InnerService.Notices.TryGetValue(requestingAgent, groupNoticeID, out gnot))
            {
                VerifyAgentPowers(gnot.Group, requestingAgent, GroupPowers.ReceiveNotices);
                groupNotice = gnot;
                return(true);
            }
            groupNotice = null;
            return(false);
        }
コード例 #18
0
 void IGroupNoticesInterface.Add(UGUI requestingAgent, GroupNotice notice)
 {
     VerifyAgentPowers(notice.Group, requestingAgent, GroupPowers.SendNotices);
     m_InnerService.Notices.Add(requestingAgent, notice);
 }
コード例 #19
0
        public static void PerformCheck(DateTime LastScheduleCheck)
        {
            if (DateTime.Now > LastScheduleCheck)
            {
                LastScheduleCheck = DateTime.Now + TimeSpan.FromMinutes(5);
                OCBotMemory bm = OCBotMemory.Memory;
                Dictionary <string, OCBotMemory.Notices> NoticeLists     = bm.NoticeLists;
                Dictionary <int, OCBotMemory.Notices>    NoticeEditQueue = new Dictionary <int, OCBotMemory.Notices>();

                foreach (KeyValuePair <string, OCBotMemory.Notices> entry in NoticeLists)
                {
                    // check notice information
                    OCBotMemory.Notices Notice = bm.NoticeLists[entry.Key];
                    if (entry.Value.Repeats)
                    {
                        if (entry.Value.LastSent == null)
                        {
                            Notice.LastSent = DateTime.Now - TimeSpan.FromMinutes(90);
                        }
                        // Check datetime
                        if (Notice.LastSent < DateTime.Now)
                        {
                            MH(Destinations.DEST_LOCAL, UUID.Zero, "Dispatching scheduled notice");
                            // Send notice and update information
                            GroupNotice NewNotice = new GroupNotice();
                            if (Notice.HasAttachment)
                            {
                                NewNotice.AttachmentID = Notice.NoticeAttachment;
                            }
                            else
                            {
                                NewNotice.AttachmentID = UUID.Zero;
                            }
                            NewNotice.Message = Notice.NoticeDescription;
                            NewNotice.OwnerID = BotSession.Instance.grid.Self.AgentID;
                            NewNotice.Subject = Notice.NoticeSummary;


                            BotSession.Instance.grid.Groups.SendGroupNotice(Notice.GroupKey, NewNotice);


                            Notice.LastSent = DateTime.Now + TimeSpan.FromDays(14);
                            NoticeEditQueue.Add(1, Notice); // This will edit the entry
                            break;
                        }
                    }
                    else
                    {
                        GroupNotice NewNotice = new GroupNotice();
                        if (Notice.HasAttachment)
                        {
                            NewNotice.AttachmentID = Notice.NoticeAttachment;
                        }
                        else
                        {
                            NewNotice.AttachmentID = UUID.Zero;
                        }
                        NewNotice.Message = Notice.NoticeDescription;
                        NewNotice.OwnerID = BotSession.Instance.grid.Self.AgentID;
                        NewNotice.Subject = Notice.NoticeSummary;

                        BotSession.Instance.grid.Groups.SendGroupNotice(Notice.GroupKey, NewNotice);

                        NoticeEditQueue.Add(2, Notice); // Will delete the notice
                        MH(Destinations.DEST_LOCAL, UUID.Zero, "Dispatching single-use notice");
                        break;
                    }
                }

                foreach (KeyValuePair <int, OCBotMemory.Notices> entry in NoticeEditQueue)
                {
                    if (entry.Key == 1)
                    {
                        bm.NoticeLists[entry.Value.InternalName] = entry.Value;
                    }
                    else if (entry.Key == 2)
                    {
                        bm.NoticeLists.Remove(entry.Value.InternalName);
                    }
                }

                bm.Save();
            }
        }
コード例 #20
0
ファイル: ActionCommandsIn.cs プロジェクト: rcoscali/METAbolt
        public string ProcessCommand(string command, string name, UUID fromid)
        {
            string icmd = command.Replace(this.instance.Config.CurrentConfig.CommandInID, string.Empty);

            if (instance.Config.CurrentConfig.DisplayLSLcommands)
            {
                tconsole.DisplayChatScreen("Recevided LSL (action) command: " + icmd + " >>> from " + name + " (" + fromid + ")");
            }

            char[]   deli = "|".ToCharArray();
            string[] sGrp = command.Split(deli);

            // Check password first and exit if not valid
            string pwd    = sGrp[1].Trim();
            string md5pwd = GetMD5();

            if (pwd != md5pwd)
            {
                return("LSL Command: Command ignored due to incorrect METAbolt password");
            }

            string cmdtype = sGrp[2].Trim();
            string msg     = string.Empty;

            switch (cmdtype)
            {
            case "WEAR":
                // Format: cmd identifier|password|command type|folder UUID
                UUID folder = (UUID)sGrp[3].Trim();

                if (folder == UUID.Zero)
                {
                    return("IM WEAR COMMAND: Folder UUID can't be empty or null. Failed.");
                }

                try
                {
                    List <InventoryBase> contents = client.Inventory.FolderContents(folder, client.Self.AgentID, true, true, InventorySortOrder.ByName, 20 * 1000);
                    List <InventoryItem> items    = new List <InventoryItem>();

                    if (contents == null)
                    {
                        Logger.Log("IM WEAR COMMAND: Failed to get contents of '" + folder.ToString() + "'", Helpers.LogLevel.Warning);
                        return("IM WEAR COMMAND: Could not get folder contents. Failed");
                    }

                    foreach (InventoryBase iitem in contents)
                    {
                        if (iitem is InventoryItem)
                        {
                            items.Add((InventoryItem)iitem);
                        }
                    }

                    client.Appearance.ReplaceOutfit(items);
                }
                catch (Exception ex)
                {
                    Logger.Log("IM WEAR COMMAND: " + ex.Message, Helpers.LogLevel.Error);
                    return("IM WEAR COMMAND: " + ex.Message + ". Failed");
                }

                //msg = "Wearing folder: " + folder.ToString();
                //client.Self.Chat(msg, 0, ChatType.Whisper);

                break;

            case "AWAY":
                instance.State.SetAway(true);
                break;

            case "NOTAWAY":
                instance.State.SetAway(false);
                break;

            case "BUSY":
                instance.State.SetBusy(true);
                break;

            case "NOTBUSY":
                instance.State.SetBusy(false);
                break;

            case "TP":
                // Format: cmd identifier|password|command type|SIM|coord x|coord y|coord z
                string sim = sGrp[3].Trim();
                float  x   = float.Parse(sGrp[4].Trim());
                float  y   = float.Parse(sGrp[5].Trim());
                float  z   = float.Parse(sGrp[6].Trim());

                client.Self.AutoPilotCancel();

                if (!string.IsNullOrEmpty(sim))
                {
                    netcom.Teleport(sim, new Vector3(x, y, z));
                }
                else
                {
                    Logger.Log("TP COMMAND: SIM name can't be empty. Command has been ignored", Helpers.LogLevel.Info);
                    return("IM TP COMMAND: SIM name can't be empty. Command has been ignored");
                }
                break;

            case "SAY":
                // Format: cmd identifier|password|command type|channel|message|message type
                int      channel  = Convert.ToInt32(sGrp[3].Trim());
                string   msgtosay = sGrp[4].Trim();
                string   ctypein  = sGrp[5].Trim().ToLower();
                ChatType ctype    = ChatType.Normal;

                switch (ctypein)
                {
                case "normal":
                    ctype = ChatType.Normal;
                    break;

                case "ownersay":
                    ctype = ChatType.OwnerSay;
                    break;

                case "regionsay":
                    ctype = ChatType.RegionSay;
                    break;

                case "shout":
                    ctype = ChatType.Shout;
                    break;

                case "whisper":
                    ctype = ChatType.Whisper;
                    break;

                default:
                    ctype = ChatType.Normal;
                    break;
                }

                netcom.ChatOut(msgtosay, ctype, channel);
                break;

            case "GIVE":
                // Format: cmd identifier|password|command type|item UUID|avatar UUID
                UUID imitem = (UUID)sGrp[3].Trim();
                UUID avatar = (UUID)sGrp[4].Trim();

                if (imitem == UUID.Zero || avatar == UUID.Zero)
                {
                    return(string.Empty);
                }

                // Find the item in inventory
                InventoryItem item = client.Inventory.FetchItem(imitem, client.Self.AgentID, 15000);

                if (item == null)
                {
                    Logger.Log("IM GIVE COMMAND: Item " + imitem.ToString() + " not found in inventory", Helpers.LogLevel.Error);
                    return("IM GIVE COMMAND: Item " + imitem.ToString() + " not found in inventory");
                }

                try
                {
                    if ((item.Permissions.OwnerMask & PermissionMask.Transfer) == PermissionMask.Transfer)
                    {
                        if ((item.Permissions.OwnerMask & PermissionMask.Copy) != PermissionMask.Copy)
                        {
                            client.Inventory.GiveItem(item.UUID, item.Name, item.AssetType, avatar, false);
                            client.Inventory.Store.RemoveNodeFor(item);
                        }
                        else
                        {
                            client.Inventory.GiveItem(item.UUID, item.Name, item.AssetType, avatar, false);
                            instance.TabConsole.DisplayChatScreen("Gave inventory item  " + item.Name + " (" + imitem + ") to " + avatar + " via ActionCommand received");
                        }
                    }
                }
                catch (Exception ex)
                {
                    Logger.Log("IM GIVE COMMAND: " + ex.Message, Helpers.LogLevel.Error);
                    return("IM GIVE COMMAND: " + ex.Message);
                }

                break;

            case "GIVEFOLDER":
                // Format: cmd identifier|password|command type|folder UUID|folder name|avatar UUID
                UUID   imfolder = (UUID)sGrp[3].Trim();
                string fname    = sGrp[4].Trim();
                UUID   imavatar = (UUID)sGrp[5].Trim();

                if (imfolder == UUID.Zero || imavatar == UUID.Zero)
                {
                    return(string.Empty);
                }

                try
                {
                    client.Inventory.GiveFolder(imfolder, fname, AssetType.Folder, imavatar, true);
                    instance.TabConsole.DisplayChatScreen("Gave inventory folder " + fname + " (" + imfolder + ") to " + imavatar + " via ActionCommand received");
                }
                catch (Exception ex)
                {
                    Logger.Log("ERROR IM GIVEFOLDER COMMAND: " + ex.Message, Helpers.LogLevel.Error);
                    return("ERROR IM GIVEFOLDER COMMAND: " + ex.Message);
                }

                break;

            case "EJECTFROMGROUP":
                UUID groupid  = (UUID)sGrp[3].Trim();
                UUID avatarid = (UUID)sGrp[4].Trim();

                if (groupid == UUID.Zero || avatarid == UUID.Zero)
                {
                    return(string.Empty);
                }

                client.Groups.EjectUser(groupid, avatarid);
                break;

            case "TOUCH":
                UUID itemid = (UUID)sGrp[3].Trim();

                if (itemid == UUID.Zero)
                {
                    return(string.Empty);
                }

                Primitive fav = client.Network.Simulators[0].ObjectsPrimitives.Find((Primitive av) => { return(av.ID == itemid); });

                if (fav == null)
                {
                    return(string.Empty);
                }

                client.Self.Touch(fav.LocalID);
                break;

            case "SIT":
                UUID oid = (UUID)sGrp[3].Trim();

                if (oid == UUID.Zero)
                {
                    return(string.Empty);
                }

                client.Self.AutoPilotCancel();
                instance.State.SetSitting(true, oid);
                break;

            case "STAND":
                UUID sid = (UUID)sGrp[3].Trim();

                client.Self.AutoPilotCancel();

                if (sid == UUID.Zero)
                {
                    return(string.Empty);
                }

                instance.State.SetSitting(false, sid);
                break;

            case "MOVETO":
                string typ = sGrp[3].Trim().ToLower();
                float  xx  = Convert.ToSingle(sGrp[4].Trim());
                float  yy  = Convert.ToSingle(sGrp[5].Trim());
                float  zz  = Convert.ToSingle(sGrp[6].Trim());

                client.Self.AutoPilotCancel();

                client.Self.Movement.SendManualUpdate(AgentManager.ControlFlags.AGENT_CONTROL_AT_POS, client.Self.Movement.Camera.Position,
                                                      client.Self.Movement.Camera.AtAxis, client.Self.Movement.Camera.LeftAxis, client.Self.Movement.Camera.UpAxis,
                                                      client.Self.Movement.BodyRotation, client.Self.Movement.HeadRotation, client.Self.Movement.Camera.Far, AgentFlags.None,
                                                      AgentState.None, true);

                if (typ == "walk")
                {
                    client.Self.Movement.Fly = false;
                    client.Self.Fly(false);
                    client.Self.Movement.AlwaysRun = false;
                }

                if (typ == "run")
                {
                    client.Self.Movement.Fly = false;
                    client.Self.Fly(false);
                    client.Self.Movement.AlwaysRun = true;
                }

                if (typ == "fly")
                {
                    client.Self.Movement.Fly = true;
                    client.Self.Fly(true);
                    client.Self.Movement.AlwaysRun = false;
                }

                ulong regionHandle = client.Network.CurrentSim.Handle;

                ulong followRegionX = regionHandle >> 32;
                ulong followRegionY = regionHandle & (ulong)0xFFFFFFFF;
                ulong ux            = (ulong)(xx + followRegionX);
                ulong uy            = (ulong)(yy + followRegionY);
                float uz            = zz - 2f;

                client.Self.AutoPilot(ux, uy, uz);
                break;

            case "STOP":
                client.Self.AutoPilotCancel();
                client.Self.Movement.Stop = true;
                break;

            case "FOLLOW":
                string flname = sGrp[3].Trim();

                //if (instance.State.FollowName != flname)
                //{
                //    instance.State.Follow(name);
                //}
                //else
                //{
                //    instance.State.Follow(string.Empty);
                //}

                if (string.IsNullOrEmpty(flname))
                {
                    instance.State.Follow(string.Empty);
                }
                else
                {
                    if (instance.State.FollowName != flname)
                    {
                        instance.State.Follow(flname);
                    }
                    else
                    {
                        instance.State.Follow(string.Empty);
                    }
                }
                break;

            case "SENDNOTICE":
                string subject = sGrp[3].Trim();
                string mssg    = sGrp[4].Trim();
                UUID   athmnt  = (UUID)sGrp[5].Trim();
                UUID   ngrp    = (UUID)sGrp[6].Trim();

                GroupNotice sgnotice = new GroupNotice();

                if (ngrp == UUID.Zero)
                {
                    return("Send Notice LSL Command: Group UUID cannot be emptry or zero. Notice has been ignored.");
                }

                try
                {
                    sgnotice.Subject = subject;
                    sgnotice.Message = mssg;

                    if (athmnt != UUID.Zero)
                    {
                        sgnotice.AttachmentID = athmnt;
                        sgnotice.OwnerID      = client.Self.AgentID;
                        sgnotice.SerializeAttachment();
                    }

                    client.Groups.SendGroupNotice(ngrp, sgnotice);
                }
                catch (Exception ex)
                {
                    return("Send Notice LSL Command Error: " + ex.Message);
                }

                break;
            }

            return(msg);
        }
コード例 #21
0
        private async void LoadDatas()
        {
            if (this.DataContext is ChatViewModel cvm && cvm.TargetVM is GroupViewModel)
            {
                GroupViewModel gvm = AppData.MainMV.GroupListVM.Items.ToList().FirstOrDefault(x => x.ID == (cvm.TargetVM as GroupViewModel).ID);
                if (gvm.AllNotice.Count > 0)
                {
                    gvm.AllNotice.Clear();
                }
                GroupModel gm = gvm.Model as GroupModel;
                App.Current.Dispatcher.Invoke(() => {
                    this.aniLoading?.Begin();
                });
                await SDKClient.SDKClient.Instance.GetNoticeList_DESC(gm.ID, 0, 0, null, HandleCompleteCallBack : (r) =>
                {
                    if (r.success)
                    {
                        App.Current.Dispatcher.Invoke(() =>
                        {
                            this.aniLoading.Stop();
                            this.sv.Visibility            = Visibility.Visible;
                            this.grid_LoadFail.Visibility = Visibility.Collapsed;
                        });
                        var pacageDatas = r.datas;
                        List <SDKClient.DTO.NoticeEntity> dataList = new List <SDKClient.DTO.NoticeEntity>();
                        if (pacageDatas.Any(x => x.type == 1))
                        {
                            dataList = pacageDatas.Where(x => x.type != 1).ToList();
                        }
                        else
                        {
                            dataList = pacageDatas.ToList();
                        }

                        if (dataList.Count > 0)
                        {
                            App.Current.Dispatcher.Invoke(new Action(() =>
                            {
                                this.aniLoading.Stop();
                                foreach (SDKClient.DTO.NoticeEntity item in dataList)
                                {
                                    GroupNotice gn    = new GroupNotice();
                                    gn.GroupId        = item.groupId;
                                    gn.NoticeTitle    = item.title;
                                    gn.NoticeContent  = item.content;
                                    gn.NoticeReleTime = item.publishTime ?? DateTime.Now;
                                    gn.NoticeType     = item.type;
                                    gn.NoticeId       = item.noticeId;
                                    gvm.AllNotice.Add(gn);
                                }
                            }));
                        }
                        if (pacageDatas.Any(x => x.type == 1))
                        {
                            App.Current.Dispatcher.Invoke(new Action(() =>
                            {
                                this.aniLoading.Stop();
                                var item          = pacageDatas.FirstOrDefault(x => x.type == 1);
                                GroupNotice gn    = new GroupNotice();
                                gn.GroupId        = item.groupId;
                                gn.NoticeTitle    = item.title;
                                gn.NoticeContent  = item.content;
                                gn.NoticeReleTime = item.publishTime ?? DateTime.Now;
                                gn.NoticeType     = item.type;
                                gn.NoticeId       = item.noticeId;
                                gvm.AllNotice.Insert(0, gn);
                            }));
                            gvm.IsShowEmptyNotice         = false;
                            gvm.IsShowEmptyNoticeOrdinary = false;
                        }
                        else
                        {
                            App.Current.Dispatcher.Invoke(() =>
                            {
                                this.aniLoading.Stop();
                            });
                            int count = pacageDatas.Count;
                            if (gvm.IsCreator)
                            {
                                if (count != 0)//没有入群须知,只有普通群公告
                                {
                                    gvm.IsShowEmptyNotice         = true;
                                    gvm.IsShowEmptyNoticeOrdinary = false;
                                }
                                else//没有入群须知,也没有普通群公告
                                {
                                    gvm.IsShowEmptyNotice         = true;
                                    gvm.IsShowEmptyNoticeOrdinary = false;
                                }
                            }
                            else
                            {
                                if (count != 0)//没有入群须知,只有普通群公告
                                {
                                    gvm.IsShowEmptyNoticeOrdinary = false;
                                    gvm.IsShowEmptyNotice         = false;
                                }
                                else//没有入群须知,也没有普通群公告
                                {
                                    gvm.IsShowEmptyNoticeOrdinary = true;
                                    gvm.IsShowEmptyNotice         = false;
                                }
                            }
                        }
                    }
                    else
                    {
                        //提示请求失败
                        App.Current.Dispatcher.Invoke(() => {
                            this.aniLoading.Stop();
                            this.sv.Visibility            = Visibility.Collapsed;
                            this.grid_LoadFail.Visibility = Visibility.Visible;
                        });
                        if (gvm.IsCreator)
                        {
                            gvm.IsShowEmptyNotice         = true;
                            gvm.IsShowEmptyNoticeOrdinary = false;
                        }
                        else
                        {
                            gvm.IsShowEmptyNotice         = false;
                            gvm.IsShowEmptyNoticeOrdinary = true;
                        }
                    }
                }).ConfigureAwait(false);
            }
        }
コード例 #22
0
 void IGroupNoticesInterface.Add(UGUI requestingAgent, GroupNotice notice) =>
 GetGroupsService(notice.Group).Notices.Add(requestingAgent, notice);
コード例 #23
0
        bool IGroupNoticesInterface.TryGetValue(UGUI requestingAgent, UUID groupNoticeID, out GroupNotice groupNotice)
        {
            GroupNotice notice;

            using (var conn = new SqlConnection(m_ConnectionString))
            {
                conn.Open();
                using (var cmd = new SqlCommand("SELECT TOP(1) * FROM groupnotices WHERE NoticeID = @noticeid", conn))
                {
                    cmd.Parameters.AddParameter("@noticeid", groupNoticeID);
                    using (SqlDataReader reader = cmd.ExecuteReader())
                    {
                        if (!reader.Read())
                        {
                            groupNotice = null;
                            return(false);
                        }
                        notice       = reader.ToGroupNotice();
                        notice.Group = ResolveName(requestingAgent, notice.Group);
                    }
                }
            }

            groupNotice = notice;
            return(true);
        }