本文整理汇总了C#中Session.SendSysMessage方法的典型用法代码示例。如果您正苦于以下问题:C# Session.SendSysMessage方法的具体用法?C# Session.SendSysMessage怎么用?C# Session.SendSysMessage使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Session
的用法示例。
在下文中一共展示了Session.SendSysMessage方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SendHistory
public override void SendHistory(Session session)
{
base.SendHistory(session);
if (Chat == null)
session.SendSysMessage("Not connected to Steam.");
}
示例2: Handle
public override void Handle(Session session)
{
if (session.Account == null)
{
session.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) + "...";
Room room = Program.RoomManager.Get(session.Room);
if (room == null)
{
if (Command.Handle(new CommandTarget(session), Content, "/"))
return;
if (Command.Handle(new CommandTarget(session), Content, "~"))
return;
session.SendSysMessage("RohBot is not in this room.");
return;
}
if (Program.DelayManager.AddAndCheck(session, 1))
return;
room.SendMessage(session, Content);
}
示例3: Handle
public override void Handle(Session session)
{
if (Program.DelayManager.AddAndCheck(session, 2.5))
return;
var room = Program.RoomManager.Get(session.Room);
if (room == null)
{
session.SendSysMessage("Room does not exist.");
return;
}
if (room.IsPrivate)
{
if (session.Account == null || room.IsBanned(session.Account.Name))
return;
}
List<HistoryLine> lines;
if (Util.DateTimeFromUnixTimestamp(AfterDate) > DateTime.UtcNow.AddDays(-7))
{
var cmd = new SqlCommand("SELECT * FROM rohbot.chathistory WHERE chat=lower(:chat) AND date<:afterdate ORDER BY date DESC LIMIT 100;");
cmd["chat"] = session.Room;
cmd["afterdate"] = AfterDate;
lines = cmd.Execute().Select(r => (HistoryLine)HistoryLine.Read(r)).Reverse().ToList();
}
else
{
lines = new List<HistoryLine>();
}
var history = new ChatHistory
{
Name = room.RoomInfo.Name,
ShortName = room.RoomInfo.ShortName,
Requested = true,
Lines = lines
};
session.Send(history);
}
示例4: SendMessage
/// <summary>
/// Called when somebody sends a message.
/// </summary>
public void SendMessage(Session session, string message)
{
if (!message.StartsWith("//") && Command.Handle(new CommandTarget(session), message, "/"))
return;
if (!message.StartsWith("~~") && Command.Handle(new CommandTarget(session), message, "~"))
return;
if (message.StartsWith("//") || message.StartsWith("~~"))
message = message.Substring(1);
if (IsBanned(session.Account.Name))
{
session.SendSysMessage("You are banned from this room.");
return;
}
var roomName = RoomInfo.ShortName;
var userName = session.Account.Name;
var userId = session.Account.Id.ToString();
var userStyle = session.Account.EnabledStyle;
var line = new ChatLine(Util.GetCurrentUnixTimestamp(), roomName, "RohBot", userName, userId, userStyle, message, false);
SendLine(line);
}
示例5: SendHistory
/// <summary>
/// Called when somebody joins the room. Should call base.
/// </summary>
public virtual void SendHistory(Session session)
{
if (IsPrivate)
{
if (session.Account == null)
{
ClearScrollbackFor(session);
session.SendSysMessage("You must login to view this room.");
return;
}
if (IsBanned(session.Account.Name))
{
ClearScrollbackFor(session);
session.SendSysMessage("You are banned from this room. To view it you must be unbanned (or whitelisted).");
return;
}
}
lock (_history)
{
var chatHistory = new ChatHistory { Name = RoomInfo.Name, ShortName = RoomInfo.ShortName, Requested = false, Lines = _history.ToList() };
session.Send(chatHistory);
}
}