本文整理汇总了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);
}
示例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);
}
示例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);
}
示例4: SendHistory
public override void SendHistory(Connection connection)
{
base.SendHistory(connection);
if (Chat == null)
connection.SendSysMessage("Not connected to Steam.");
}
示例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);
}
示例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);
}
示例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;
}
}
示例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);
}
示例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);
}
示例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);
}