当前位置: 首页>>代码示例>>C#>>正文


C# Connection.SendSysMessage方法代码示例

本文整理汇总了C#中Connection.SendSysMessage方法的典型用法代码示例。如果您正苦于以下问题:C# Connection.SendSysMessage方法的具体用法?C# Connection.SendSysMessage怎么用?C# Connection.SendSysMessage使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Connection的用法示例。


在下文中一共展示了Connection.SendSysMessage方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Handle

        public override void Handle(Connection connection)
        {
            var account = connection.Session.Account;
            var notification = Program.NotificationManager.Get(DeviceToken);

            if (notification == null)
            {
                connection.SendSysMessage("This device is not registered for push notifications.");
                return;
            }

            if (notification.UserId != account.Id)
            {
                connection.SendSysMessage("This device is not registered with your account.");
                return;
            }

            notification.Remove();

            Program.NotificationsDirty = true;

            var notificationSubscription = new NotificationSubscription();
            notificationSubscription.DeviceToken = DeviceToken;
            notificationSubscription.RegexPattern = RegexPattern;
            notificationSubscription.Registered = false;

            connection.Send(notificationSubscription);
        }
开发者ID:Rohansi,项目名称:RohBot,代码行数:28,代码来源:NotificationUnsubscriptionRequest.cs

示例2: Handle

        public override void Handle(Connection connection)
        {
            if (Program.DelayManager.AddAndCheck(connection, DelayManager.Database))
                return;

            if (connection.Session == null)
            {
                connection.SendSysMessage("You need to be logged in to do that.");
                return;
            }

            if (!connection.Session.IsInRoom(Target))
            {
                connection.SendSysMessage("You are not in that room.");
                return;
            }

            var room = Program.RoomManager.Get(Target);
            if (room == null)
            {
                connection.SendSysMessage("Room does not exist.");
                return;
            }

            if (room.IsPrivate && room.IsBanned(connection.Session.Account.Name))
                return;

            List<HistoryLine> lines;
            if (Util.DateTimeFromTimestamp(AfterDate) < (DateTime.UtcNow - Util.MaximumHistoryRequest))
            {
                lines = new List<HistoryLine>();
            }
            else
            {
                var cmd = new SqlCommand("SELECT * FROM rohbot.chathistory WHERE chat=lower(:chat) AND date<:afterdate ORDER BY date DESC LIMIT 100;");
                cmd["chat"] = Target;
                cmd["afterdate"] = AfterDate;

                lines = cmd.Execute().Select(r => (HistoryLine)HistoryLine.Read(r)).ToList();
                lines.Reverse();
            }

            if (lines.Count == 0)
                lines.Add(new ChatLine(0, Target, "Steam", Program.Settings.PersonaName, "0", "", "No additional history is available.", false));

            var history = new ChatHistory
            {
                ShortName = room.RoomInfo.ShortName,
                Requested = true,
                Lines = lines
            };

            connection.Send(history);
        }
开发者ID:Naarkie,项目名称:RohBot,代码行数:54,代码来源:ChatHistoryRequest.cs

示例3: Handle

        public override void Handle(Connection connection)
        {
            var account = connection.Session.Account;
            var notification = new Notification();

            notification.UserId = account.Id;
            notification.Regex = new Regex(RegexPattern);
            notification.DeviceToken = DeviceToken;

            if (Program.NotificationManager.Exists(DeviceToken))
            {
                notification.Save();
            }
            else
            {
                if (Program.NotificationManager.FindWithId(account.Id).Count() < 5)
                {
                    notification.Insert();
                }
                else
                {
                    connection.SendSysMessage("You may only have 5 devices registered for push notifications.");
                    return;
                }
            }

            Program.NotificationsDirty = true;

            var notificationSubscription = new NotificationSubscription();
            notificationSubscription.DeviceToken = DeviceToken;
            notificationSubscription.RegexPattern = RegexPattern;
            notificationSubscription.Registered = true;

            connection.Send(notificationSubscription);
        }
开发者ID:Rohansi,项目名称:RohBot,代码行数:35,代码来源:NotificationSubscriptionRequest.cs

示例4: SendHistory

        public override void SendHistory(Connection connection)
        {
            base.SendHistory(connection);

            if (Chat == null)
                connection.SendSysMessage("Not connected to Steam.");
        }
开发者ID:krixalis,项目名称:RohBot,代码行数:7,代码来源:SteamRoom.cs

示例5: Handle

        public override void Handle(Connection connection)
        {
            if (connection.Session == null)
            {
                connection.SendSysMessage("Guests can not speak.");
                return;
            }

            Content = (Content ?? "").Trim();

            if (Content.Length == 0)
                return;

            // can't send emoticons from web
            Content = Content.Replace('ː', ':');

            // steam discards long messages
            if (Content.Length > 2000)
                Content = Content.Substring(0, 2000) + "...";

            if (Program.DelayManager.AddAndCheck(connection, CalculateMessageCost(Content)))
                return;

            var room = Program.RoomManager.Get(Target);
            var roomName = room != null ? Target : Program.Settings.DefaultRoom;

            var isEscapedCommand = Content.StartsWith("//");
            if (!isEscapedCommand && Command.Handle(new CommandTarget(connection, roomName), Content, "/"))
                return;

            if (isEscapedCommand)
                Content = Content.Substring(1);

            if (room == null)
            {
                connection.SendSysMessage("RohBot is not in this room.");
                return;
            }

            room.SendMessage(connection, Content);
        }
开发者ID:Rohansi,项目名称:RohBot,代码行数:41,代码来源:SendMessage.cs

示例6: Handle

        public override void Handle(Connection connection)
        {
            if (Program.DelayManager.AddAndCheck(connection, 2.5))
                return;

            if (connection.Session == null)
            {
                connection.SendSysMessage("Guests can not speak.");
                return;
            }

            Content = (Content ?? "").Trim();

            if (Content.Length == 0)
                return;

            // can't send emoticons from web
            Content = Content.Replace('ː', ':');

            // steam discards long messages
            if (Content.Length > 1000)
                Content = Content.Substring(0, 1000) + "...";

            var room = Program.RoomManager.Get(Target);
            if (room == null)
            {
                if (Command.Handle(new CommandTarget(connection, Program.Settings.DefaultRoom), Content, "/"))
                    return;

                if (Command.Handle(new CommandTarget(connection, Program.Settings.DefaultRoom), Content, "~"))
                    return;

                connection.SendSysMessage("RohBot is not in this room.");
                return;
            }

            room.SendMessage(connection, Content);
        }
开发者ID:krixalis,项目名称:RohBot,代码行数:38,代码来源:SendMessage.cs

示例7: AddAndCheck

        public bool AddAndCheck(Connection connection, double cost)
        {
            lock (_delays)
            {
                double delay;
                if (!_delays.TryGetValue(connection.Address, out delay))
                {
                    if (cost > 0)
                        _delays.Add(connection.Address, cost);
                }
                else
                {
                    _delays[connection.Address] += cost;
                }

                var shouldDelay = (delay + cost) >= DelayThreshold;

                if (shouldDelay)
                    connection.SendSysMessage("Too many requests are coming from your location and your request has been canceled. Please wait and try again in a few minutes.");

                return shouldDelay;
            }
        }
开发者ID:krixalis,项目名称:RohBot,代码行数:23,代码来源:DelayManager.cs

示例8: SendMessage

        /// <summary>
        /// Called when somebody sends a message.
        /// </summary>
        public void SendMessage(Connection connection, string message)
        {
            if (connection.Session == null) // should never happen
                return;

            var roomName = RoomInfo.ShortName;
            var account = connection.Session.Account;

            if (!message.StartsWith("//") && Command.Handle(new CommandTarget(connection, roomName), message, "/"))
                return;

            if (!message.StartsWith("~~") && Command.Handle(new CommandTarget(connection, roomName), message, "~"))
                return;

            if (message.StartsWith("//") || message.StartsWith("~~"))
                message = message.Substring(1);

            if (IsBanned(account.Name))
            {
                connection.SendSysMessage("You are banned from this room.");
                return;
            }

            var userName = account.Name;
            var userId = account.Id.ToString("D");
            var userStyle = account.EnabledStyle;
            var line = new ChatLine(Util.GetCurrentTimestamp(), roomName, "RohBot", userName, userId, userStyle, message, false);
            SendLine(line);
        }
开发者ID:Naarkie,项目名称:RohBot,代码行数:32,代码来源:Room.cs

示例9: SendHistory

        /// <summary>
        /// Called when somebody joins the room. Should call base.
        /// </summary>
        public virtual void SendHistory(Connection connection)
        {
            if (IsPrivate)
            {
                if (connection.Session == null)
                {
                    ClearScrollbackFor(connection);
                    connection.SendSysMessage("You must login to view this room.");
                    return;
                }

                if (IsBanned(connection.Session.Account.Name))
                {
                    ClearScrollbackFor(connection);
                    connection.SendSysMessage("You are banned from this room.");
                    return;
                }
            }

            var lines = GetHistoryLines(connection);
            var chatHistory = new ChatHistory { ShortName = RoomInfo.ShortName, Requested = false, Lines = lines };
            connection.Send(chatHistory);
        }
开发者ID:Naarkie,项目名称:RohBot,代码行数:26,代码来源:Room.cs

示例10: SendMessage

        /// <summary>
        /// Called when somebody sends a message.
        /// </summary>
        public virtual void SendMessage(Connection connection, string message)
        {
            if (connection.Session == null) // should never happen
                return;

            var roomName = RoomInfo.ShortName;
            var account = connection.Session.Account;

            if (IsBanned(account.Name))
            {
                connection.SendSysMessage("You are banned from this room.");
                return;
            }

            var userName = account.Name;
            var userId = account.Id.ToString("D");
            var userStyle = account.EnabledStyle;
            var line = new ChatLine(Util.GetCurrentTimestamp(), roomName, "RohBot", userName, userId, userStyle, message, false);
            SendLine(line);
        }
开发者ID:Rohansi,项目名称:RohBot,代码行数:23,代码来源:Room.cs


注:本文中的Connection.SendSysMessage方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。