public event EventHandler <TasSayEventArgs> Said = delegate { }; // this is fired when any kind of say message is recieved /// <summary> /// Say something through chat system /// </summary> /// <param Name="place">Pick user (private message) channel or battle</param> /// <param Name="channel">Channel or User Name</param> /// <param Name="inputtext">chat text</param> /// <param Name="isEmote">is message emote? (channel or battle only)</param> /// <param Name="linePrefix">text to be inserted in front of each line (example: "!pm xyz")</param> public async Task Say(SayPlace place, string channel, string inputtext, bool isEmote, bool isRing = false) { if (string.IsNullOrEmpty(inputtext)) { return; } var lines = inputtext.Split(new[] { '\n' }, StringSplitOptions.RemoveEmptyEntries); foreach (var text in lines) { if (string.IsNullOrEmpty(text)) { continue; } var args = new SayingEventArgs(place, channel, text, isEmote); Saying(this, args); if (args.Cancel) { continue; } if ((args.SayPlace == SayPlace.Channel) && !JoinedChannels.ContainsKey(args.Channel)) { await JoinChannel(args.Channel); } var say = new Say() { Target = args.Channel, Place = args.SayPlace, Text = args.Text, IsEmote = args.IsEmote, Ring = isRing }; await SendCommand(say); } }
public async Task LeaveChannel(string channelName) { if (JoinedChannels.ContainsKey(channelName)) { await SendCommand(new LeaveChannel() { ChannelName = channelName }); } }
public Channel GetJoinedChannel(string channelName) { if (JoinedChannels.ContainsKey(channelName)) { return(JoinedChannels[channelName]); } else { return(null); } }
void OnJoin(string[] args) { if (!JoinedChannels.ContainsKey(args[0])) { JoinedChannels.Add(args[0], Channel.Create(args[0])); var cancelEventArgs = new CancelEventArgs <TasEventArgs>(new TasEventArgs(args)); PreviewChannelJoined(this, cancelEventArgs); if (!cancelEventArgs.Cancel) { ChannelJoined(this, new TasEventArgs(args)); } } }
/// <summary> /// Say something through chat system /// </summary> /// <param Name="place">Pick user (private message) channel or battle</param> /// <param Name="channel">Channel or User Name</param> /// <param Name="inputtext">chat text</param> /// <param Name="isEmote">is message emote? (channel or battle only)</param> /// <param Name="linePrefix">text to be inserted in front of each line (example: "!pm xyz")</param> public async Task Say(SayPlace place, string channel, string inputtext, bool isEmote, string linePrefix = "") { if (String.IsNullOrEmpty(inputtext)) { return; } var lines = inputtext.Split(new[] { '\n' }, StringSplitOptions.RemoveEmptyEntries); foreach (var text in lines) { if (String.IsNullOrEmpty(text)) { continue; } var sentText = linePrefix + text; var args = new SayingEventArgs(place, channel, sentText, isEmote); Saying(this, args); if (args.Cancel) { continue; } switch (place) { case SayPlace.Channel: if (!JoinedChannels.ContainsKey(args.Channel)) { JoinChannel(args.Channel); } if (args.IsEmote) { await con.SendCommand("SAYEX", args.Channel, args.Text); } else { await con.SendCommand("SAY", args.Channel, args.Text); } break; case SayPlace.User: await con.SendCommand("SAYPRIVATE", args.Channel, args.Text); break; case SayPlace.Battle: if (args.IsEmote) { await con.SendCommand("SAYBATTLEEX", args.Text); } else { await con.SendCommand("SAYBATTLE", args.Text); } break; case SayPlace.BattlePrivate: if (args.IsEmote) { await con.SendCommand("SAYBATTLEPRIVATEEX", channel, args.Text); } else { await con.SendCommand("SAYBATTLEPRIVATE", channel, args.Text); } break; } } }
public bool IsJoinedChannel(string channelName) => JoinedChannels.ContainsKey(channelName);