public TSIrcPlayer(string name, Group group, IIrcMessageTarget target) : base(name) { Group = group; Target = target; UserAccountName = name; }
/// <summary> /// </summary> /// <param name="localUser"> /// </param> /// <param name="target"> /// </param> private void SendGreeting(IrcLocalUser localUser, IIrcMessageTarget target) { localUser.SendNotice(target, "This is the {0}, welcome.", ProgramInfo.AssemblyTitle); localUser.SendNotice(target, "Message me with '.help' for instructions on how to use me."); localUser.SendNotice(target, "Remember to log in via a private message and not via the channel."); }
public IRCCommandEventArgs(string text, IrcUser sender, IIrcMessageTarget target) { parameters = IRCCommands.ParseParameters(text); RawText = text; Sender = sender; Target = target; }
public TSIrcPlayer(string name, Group group, IIrcMessageTarget target) : base(name) { Group = group; Target = target; User = TShock.Users.GetUserByName(name); //Not sure if this is the correct way }
public TSIrcPlayer(string name, Group group, IIrcMessageTarget target) : base(name) { Group = group; Target = target; if (User != null) User.Name = name; }
/// <summary> /// </summary> /// <param name="localUser"> /// </param> /// <param name="target"> /// </param> /// <param name="format"> /// </param> /// <param name="args"> /// </param> public static void SendNotice( this IrcLocalUser localUser, IIrcMessageTarget target, string format, params object[] args) { SendNotice(localUser, new[] { target }, format, args); }
/// <summary> /// </summary> /// <param name="localUser"> /// </param> /// <param name="target"> /// </param> /// <param name="format"> /// </param> /// <param name="args"> /// </param> public static void SendMessage( this IrcLocalUser localUser, IIrcMessageTarget target, string format, params object[] args) { SendMessage(localUser, new[] { target }, format, args); }
public IrcMessageCommand( IrcBot bot, IrcBotUser user, IrcClient client, string[] parameters, IIrcMessageTarget target, IIrcMessageSource source ) : base(bot, user, client, parameters, target, source) { }
/// <inheritdoc cref="SendNotice(IEnumerable{IIrcMessageTarget}, string)"/> /// <param name="target">The <see cref="IIrcMessageTarget"/> to which to send the notice.</param> public void SendNotice(IIrcMessageTarget target, string text) { if (target == null) { throw new ArgumentNullException("target"); } if (text == null) { throw new ArgumentNullException("text"); } SendNotice(new[] { target }, text); }
/// <inheritdoc cref="SendNotice(IEnumerable{IIrcMessageTarget}, string)"/> /// <param name="target">The <see cref="IIrcMessageTarget"/> to which to send the notice.</param> public void SendNotice(IIrcMessageTarget target, string text) { if (target == null) { return; } if (text == null) { return; } SendNotice(new[] { target }, text); }
public bool AddUser(string username, Channels ChannelWatch, IIrcMessageTarget target, IIrcMessageSource source, IrcClient ircConnection) { ModifyingConfig = true; bool returnvalue = false; IrcChannel findChannel = null; foreach (IrcChannel ircChannel in ircConnection.Channels) { if(ircChannel.Name == target.Name) { findChannel = ircChannel; } } if (Utilities.CheckOp(source.Name, findChannel)) { try { Channels Watch = new Channels(); foreach (Channels c in TwitchChannels) { if (findChannel.Name == c.ChannelName) { Watch = c; }//if (findChannel.Name == c.ChannelName) }//foreach (Channels c in TwitchChannels) // config writing XElement newStreamer = new XElement("streamer"); newStreamer.SetAttributeValue("value", username); XElement xElem = ConfigDocument.Descendants("servers").FirstOrDefault().Descendants("server").FirstOrDefault().Elements("channel").First(x => x.Attribute("id").Value == Watch.ChannelName); xElem.Descendants("streamers").FirstOrDefault().Add(newStreamer); TwitchStuff twitchInfo = new TwitchStuff(); twitchInfo.UpdateInfo(username,this); Watch.Streamers.Add(username); Watch.StreamInfo.Add(twitchInfo); returnvalue = true; ConfigDocument.Save(FileName); }//try catch (Exception ex) { Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine("ERROR: " + ex.Message); Console.ForegroundColor = ConsoleColor.Gray; returnvalue = false; } } ModifyingConfig = false; return returnvalue; }
public IrcCommand( IrcBot bot, IrcBotUser user, IrcClient client, string[] parameters, IIrcMessageTarget target, IIrcMessageSource source ) { this.Bot = bot; this.User = user; this.Client = client; this.Target = target; this.Source = source; ParseParameters(parameters); }
public static void SendMessage(IIrcMessageTarget target, string msg) { msg = msg.Replace("\0", ""); msg = msg.Replace("\r", ""); msg = msg.Replace("\n", ""); var sb = new StringBuilder(); foreach (string word in msg.Split(' ')) { if (sb.Length + word.Length + 1 > 400) { IrcClient.LocalUser.SendMessage(target, sb.ToString()); sb.Clear(); } else sb.Append(word).Append(" "); } IrcClient.LocalUser.SendMessage(target, sb.ToString()); }
public static void SendMessage(this IIrcMessageTarget target, string msg) { msg = msg.Replace("\0", ""); msg = msg.Replace("\r", ""); msg = msg.Replace("\n", ""); StringBuilder sb = new StringBuilder(); foreach (string word in msg.Split(' ')) { if (sb.Length + word.Length + 1 > maxCharsPerLine) { ircClient.LocalUser.SendMessage(target, sb.ToString()); sb.Clear(); } else { sb.Append(word).Append(" "); } } ircClient.LocalUser.SendMessage(target, sb.ToString()); }
public bool AddWhiteList(string game, Channels ChannelWatch, IIrcMessageTarget target, IIrcMessageSource source, IrcClient ircConnection) { ModifyingConfig = true; bool returnvalue = false; XElement xElem = ConfigDocument.Descendants("servers").FirstOrDefault().Descendants("server").FirstOrDefault().Elements("channel").First(x => x.Attribute("id").Value == ChannelWatch.ChannelName); XElement whiteList = new XElement("whitelist"); if(xElem.Descendants("whitelist").Count() > 0) { whiteList = xElem.Descendants("whitelist").FirstOrDefault(); } else { xElem.Add(whiteList); } XElement newGame = new XElement("game"); XAttribute newGameAttr = new XAttribute("name", game); newGame.Add(newGameAttr); whiteList.Add(newGame); ChannelWatch.WhiteList.Add(game); returnvalue = true; ConfigDocument.Save(FileName); ModifyingConfig = false; return returnvalue; }
/// <inheritdoc cref="Ping(IList{IIrcMessageTarget})"/> /// <summary> /// Pings the specified user. /// </summary> /// <param name="user">The user to which to send the request.</param> public void Ping(IIrcMessageTarget user) { Ping(new[] { user }); }
public bool SetWhiteList(bool value, Channels ChannelWatch, IIrcMessageTarget target, IIrcMessageSource source, IrcClient ircConnection) { ModifyingConfig = true; bool returnvalue = false; XElement xElem = ConfigDocument.Descendants("servers").FirstOrDefault().Descendants("server").FirstOrDefault().Elements("channel").First(x => x.Attribute("id").Value == ChannelWatch.ChannelName); if (xElem.Attributes("usewhitelist") == null) { XAttribute whiteList = new XAttribute("usewhitelist", value.ToString()); xElem.Add(whiteList); } else { if (value) { xElem.Attribute("usewhitelist").SetValue("true"); ChannelWatch.UseWhiteList = true; } else { xElem.Attribute("usewhitelist").SetValue("false"); ChannelWatch.UseWhiteList = false; } } returnvalue = true; ConfigDocument.Save(FileName); ModifyingConfig = false; return returnvalue; }
/// <inheritdoc cref="SendAction(IList{IIrcMessageTarget}, string)"/> /// <summary> /// Sends an action message to the specified list of users. /// </summary> /// <param name="user">The user to which to send the request.</param> public void SendAction(IIrcMessageTarget user, string text) { SendMessageAction(new[] { user }, text); }
/// <inheritdoc cref="GetVersion(IList{IIrcMessageTarget})"/> /// <summary> /// Gets the client version of the specified user. /// </summary> /// <param name="user">The user to which to send the request.</param> public void GetVersion(IIrcMessageTarget user) { GetVersion(new[] { user }); }
private void OnUnsuccessfulLogin(IIrcMessageSource ircMessageSource, IIrcMessageTarget[] targets) { var handler = this.UnsuccessfulLogin; if (handler != null) handler(this, ircMessageSource, targets); }
/// <inheritdoc cref="SendNotice(IEnumerable{IIrcMessageTarget}, string)"/> /// <param name="target">The <see cref="IIrcMessageTarget"/> to which to send the notice.</param> public void SendNotice(IIrcMessageTarget target, string text) { if (target == null) return; if (text == null) return; SendNotice(new[] { target }, text); }
public static void SendSafeNotice(this IrcLocalUser user, IIrcMessageTarget target, string format, params object[] args) { var message = String.Format(format, args).Replace("\r\n", " ").Replace('\r', ' ').Replace('\n', ' '); user.SendNotice(target, message); }
public bool ChangeAnnounceMessage(string MsgTitle, string newMsg, Channels ChannelWatch, IIrcMessageTarget target, IIrcMessageSource source, IrcClient ircConnection) { ModifyingConfig = true; bool returnvalue = false; XElement xElem = ConfigDocument.Descendants("servers").FirstOrDefault().Descendants("server").FirstOrDefault().Elements("channel").First(x => x.Attribute("id").Value == ChannelWatch.ChannelName); XElement announce = new XElement(MsgTitle); if (xElem.Descendants(MsgTitle).Count() > 0) { announce = xElem.Descendants(MsgTitle).FirstOrDefault(); } announce.SetValue(newMsg); if (xElem.Descendants(MsgTitle).Count() == 0) { xElem.Add(announce); } ChannelWatch.AnnounceMessage = newMsg; //ChannelWatch.WhiteList.Add(game); returnvalue = true; ConfigDocument.Save(FileName); ModifyingConfig = false; return returnvalue; }
/// <summary> /// Sends a notice to the target. /// </summary> /// <param name="target"></param> /// <param name="message"></param> /// <returns></returns> public async Task SendNoticeAsync(IIrcMessageTarget target, string message) { await SendRawMessageAsync(string.Format("NOTICE {0} :{1}", target.TargetName, message)); }
public async Task SendMessageAsync(IIrcMessageTarget target, string message) { await SendMessageAsync(target.TargetName, message); }
public bool RemoveUser(string username, Channels ChannelWatch, IIrcMessageTarget target, IIrcMessageSource source, IrcClient ircConnection) { ModifyingConfig = true; bool returnvalue = false; IrcChannel findChannel = null; foreach (IrcChannel ircChannel in ircConnection.Channels) { if (ircChannel.Name == target.Name) { findChannel = ircChannel; } } if (Utilities.CheckOp(source.Name, findChannel)) { try { Channels Watch = new Channels(); foreach (Channels c in TwitchChannels) { if (findChannel.Name == c.ChannelName) { Watch = c; }//if (findChannel.Name == c.ChannelName) }//foreach (Channels c in TwitchChannels) Watch.Streamers.Remove(username); TwitchStuff twitchInfo = new TwitchStuff(); foreach (TwitchStuff huntInfo in Watch.StreamInfo) { if (huntInfo.streamername == username) { twitchInfo = huntInfo; }//if (huntInfo.streamername == username) }//foreach (TwitchStuff huntInfo in Watch.StreamInfo) Watch.StreamInfo.Remove(twitchInfo); // config writing if(AllStreamers.Keys.Contains(username)) { AllStreamers.Remove(username); } XElement chanNode = ConfigDocument.Descendants("servers").FirstOrDefault().Descendants("server").FirstOrDefault().Elements("channel").First(x => x.Attribute("id").Value == Watch.ChannelName); XElement streamercheck = chanNode.Element("streamers").Descendants("streamer").First(x => x.Attribute("value").Value == username); if (streamercheck != null) streamercheck.Remove(); returnvalue = true; ConfigDocument.Save(FileName); }//try catch (Exception ex) { Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine("ERROR: " + ex.Message); Console.ForegroundColor = ConsoleColor.Gray; returnvalue = false; }//catch } ModifyingConfig = false; return returnvalue; }
void m_client_UnsuccessfulLogin(IrcClient source, IIrcMessageSource ircMessageSource, IIrcMessageTarget[] targets) { m_loginFailed = true; m_registeredEvent.Set(); }
public static void SendMessage(this IrcLocalUser user, IIrcMessageTarget target, string format, params object[] args) { user.SendMessage(target, String.Format(format, args)); }
public static void Execute(string str, IrcUser sender, IIrcMessageTarget target) { var args = new IRCCommandEventArgs(str, sender, target); string commandName = args[-1].ToLowerInvariant(); if (TShockIRC.Config.IgnoredCommands.Contains(commandName)) return; var ircCommand = Commands.FirstOrDefault(c => c.Names.Contains(commandName)); var senderGroup = TShockIRC.IrcUsers[sender]; if (ircCommand != null) { if (String.IsNullOrEmpty(ircCommand.Permission) || senderGroup.HasPermission(ircCommand.Permission)) { if (ircCommand.DoLog) Log.Info("{0} executed: /{1}.", sender.NickName, str); ircCommand.Execute(args); } else { Log.Warn("{0} tried to execute /{1}.", sender.NickName, str); TShockIRC.SendMessage(target, "\u00035You do not have access to this command."); } } else if (senderGroup.HasPermission("tshockirc.command")) { var tsIrcPlayer = new TSIrcPlayer(sender.NickName, senderGroup, target); var commands = TShockAPI.Commands.ChatCommands.Where(c => c.HasAlias(commandName)); if (commands.Count() != 0) { Main.rand = new Random(); WorldGen.genRand = new Random(); foreach (Command command in commands) { if (!command.CanRun(tsIrcPlayer)) { Log.Warn("{0} tried to execute /{1}.", sender.NickName, str); TShockIRC.SendMessage(target, "\u00035You do not have access to this command."); } else if (!command.AllowServer) TShockIRC.SendMessage(target, "\u00035You must use this command in-game."); else { var parms = args.ParameterRange(0, args.Length); if (TShockAPI.Hooks.PlayerHooks.OnPlayerCommand(tsIrcPlayer, command.Name, str, parms, ref commands)) return; if (command.DoLog) Log.Info("{0} executed: /{1}.", sender.NickName, str); command.Run(str, tsIrcPlayer, parms); } } } else TShockIRC.SendMessage(target, "\u00035Invalid command."); } else { Log.Warn("{0} tried to execute /{1}.", sender.NickName, str); TShockIRC.SendMessage(target, "\u00035You do not have access to this command."); } }
/// <inheritdoc cref="CheckErrorOccurred(IList{IIrcMessageTarget})"/> /// <summary> /// Asks the specified user whether an error just occurred. /// </summary> /// <param name="user">The user to which to send the request.</param> public void CheckErrorOccurred(IIrcMessageTarget user) { CheckErrorOccurred(new[] { user }); }
/// <inheritdoc cref="GetTime(IList{IIrcMessageTarget})"/> /// <summary> /// Gets the local date/time of the specified user. /// </summary> /// <param name="user">The user to which to send the request.</param> public void GetTime(IIrcMessageTarget user) { GetTime(new[] { user }); }
/// <inheritdoc cref="SendNotice(IEnumerable{IIrcMessageTarget}, string)"/> /// <param name="target">The <see cref="IIrcMessageTarget"/> to which to send the notice.</param> public void SendNotice(IIrcMessageTarget target, string text) { if (target == null) throw new ArgumentNullException("target"); if (text == null) throw new ArgumentNullException("text"); SendNotice(new[] { target }, text); }
public bool SetNotice(string username, Channels ChannelWatch, IIrcMessageTarget target, IIrcMessageSource source, IrcClient ircConnection, bool SetNoticeValue) { ModifyingConfig = true; bool returnvalue = false; IrcChannel findChannel = null; foreach (IrcChannel ircChannel in ircConnection.Channels) { if (ircChannel.Name == target.Name) { findChannel = ircChannel; } } if (ChannelWatch.Streamers.Contains(username)) { try { TwitchStuff twitchInfo = new TwitchStuff(); foreach (TwitchStuff huntInfo in ChannelWatch.StreamInfo) { if (huntInfo.streamername == username) { twitchInfo = huntInfo; }//if (huntInfo.streamername == username) }//foreach (TwitchStuff huntInfo in Watch.StreamInfo) XElement chanNode = ConfigDocument.Descendants("servers").FirstOrDefault().Descendants("server").FirstOrDefault().Elements("channel").First(x => x.Attribute("id").Value == ChannelWatch.ChannelName); XElement streamercheck = chanNode.Element("streamers").Descendants("streamer").First(x => x.Attribute("value").Value == username); if (streamercheck != null) { if (SetNoticeValue) { try { streamercheck.Attribute("setnotice").SetValue("true"); } catch { streamercheck.Add(new XAttribute("setnotice", "true")); } twitchInfo.setnotice = true; } else { streamercheck.Attribute("setnotice").SetValue("false"); twitchInfo.setnotice = false; } } returnvalue = true; ConfigDocument.Save(FileName); }//try catch (Exception ex) { returnvalue = false; Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine("ERROR: " + ex.Message); Console.ForegroundColor = ConsoleColor.Gray; }//catch } else { ircConnection.LocalUser.SendNotice(source.Name, "You are not on the streamer list."); } ModifyingConfig = false; return returnvalue; }
private void SendGreeting(IrcLocalUser localUser, IIrcMessageTarget target) { localUser.SendNotice(target, "This is the {0}, welcome.", ProgramInfo.AssemblyTitle); localUser.SendNotice(target, "Message me with '.help' for instructions on how to use me."); localUser.SendNotice(target, "Remember to log in via a private message and not via the channel."); }
public static void Execute(string str, IrcUser sender, IIrcMessageTarget target) { var args = new IRCCommandEventArgs(str, sender, target); string commandName = args[-1].ToLowerInvariant(); if (TShockIRC.Config.IgnoredCommands.Contains(commandName)) { return; } var ircCommand = Commands.FirstOrDefault(c => c.Names.Contains(commandName)); var senderGroup = TShockIRC.IrcUsers[sender]; if (ircCommand != null) { if (String.IsNullOrEmpty(ircCommand.Permission) || senderGroup.HasPermission(ircCommand.Permission)) { if (ircCommand.DoLog) { Log.Info("{0} executed: /{1}.", sender.NickName, str); } ircCommand.Execute(args); } else { Log.Warn("{0} tried to execute /{1}.", sender.NickName, str); TShockIRC.SendMessage(target, "\u00035You do not have access to this command."); } } else if (senderGroup.HasPermission("tshockirc.command")) { var tsIrcPlayer = new TSIrcPlayer(sender.NickName, senderGroup, target); var commands = TShockAPI.Commands.ChatCommands.Where(c => c.HasAlias(commandName)); if (commands.Count() != 0) { Main.rand = new Random(); WorldGen.genRand = new Random(); foreach (Command command in commands) { if (!command.CanRun(tsIrcPlayer)) { Log.Warn("{0} tried to execute /{1}.", sender.NickName, str); TShockIRC.SendMessage(target, "\u00035You do not have access to this command."); } else if (!command.AllowServer) { TShockIRC.SendMessage(target, "\u00035You must use this command in-game."); } else { var parms = args.ParameterRange(0, args.Length); if (TShockAPI.Hooks.PlayerHooks.OnPlayerCommand(tsIrcPlayer, command.Name, str, parms, ref commands)) { return; } if (command.DoLog) { Log.Info("{0} executed: /{1}.", sender.NickName, str); } command.Run(str, tsIrcPlayer, parms); } } } else { TShockIRC.SendMessage(target, "\u00035Invalid command."); } } else { Log.Warn("{0} tried to execute /{1}.", sender.NickName, str); TShockIRC.SendMessage(target, "\u00035You do not have access to this command."); } }