コード例 #1
0
ファイル: TSIRCPlayer.cs プロジェクト: darkunderdog/TShockIRC
 public TSIrcPlayer(string name, Group group, IIrcMessageTarget target)
     : base(name)
 {
     Group = group;
     Target = target;
     UserAccountName = name;
 }
コード例 #2
0
        /// <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.");
        }
コード例 #3
0
 public IRCCommandEventArgs(string text, IrcUser sender, IIrcMessageTarget target)
 {
     parameters = IRCCommands.ParseParameters(text);
     RawText    = text;
     Sender     = sender;
     Target     = target;
 }
コード例 #4
0
 public IRCCommandEventArgs(string text, IrcUser sender, IIrcMessageTarget target)
 {
     parameters = IRCCommands.ParseParameters(text);
     RawText = text;
     Sender = sender;
     Target = target;
 }
コード例 #5
0
ファイル: TSIRCPlayer.cs プロジェクト: bippity/TShockIRC
 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
 }
コード例 #6
0
ファイル: TSIRCPlayer.cs プロジェクト: moisterrific/TShockIRC
 public TSIrcPlayer(string name, Group group, IIrcMessageTarget target)
     : base(name)
 {
     Group           = group;
     Target          = target;
     UserAccountName = name;
 }
コード例 #7
0
ファイル: TSIRCPlayer.cs プロジェクト: Enerdy/TShockIRC
 public TSIrcPlayer(string name, Group group, IIrcMessageTarget target)
     : base(name)
 {
     Group = group;
     Target = target;
     if (User != null)
         User.Name = name;
 }
コード例 #8
0
 /// <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);
 }
コード例 #9
0
 /// <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);
 }
コード例 #10
0
 public IrcMessageCommand(
     IrcBot bot, 
     IrcBotUser user,
     IrcClient client, 
     string[] parameters, 
     IIrcMessageTarget target, 
     IIrcMessageSource source
 )
     : base(bot, user, client, parameters, target, source)
 {
 }
コード例 #11
0
ファイル: IrcLocalUser.cs プロジェクト: w0rd-driven/ircdotnet
        /// <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);
        }
コード例 #12
0
        /// <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);
        }
コード例 #13
0
 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;
 }
コード例 #14
0
ファイル: IrcCommand.cs プロジェクト: koushikajay/Alfred
        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);
        }
コード例 #15
0
ファイル: TShockIRC.cs プロジェクト: bippity/TShockIRC
        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());
        }
コード例 #16
0
        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());
        }
コード例 #17
0
 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;
 }
コード例 #18
0
ファイル: CtcpClient.cs プロジェクト: mattias197711/Jackett2
 /// <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 });
 }
コード例 #19
0
 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;
 }
コード例 #20
0
 /// <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);
 }
コード例 #21
0
 /// <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 });
 }
コード例 #22
0
ファイル: IrcClient.cs プロジェクト: carriercomm/TwitchIrc
 private void OnUnsuccessfulLogin(IIrcMessageSource ircMessageSource, IIrcMessageTarget[] targets)
 {
     var handler = this.UnsuccessfulLogin;
     if (handler != null)
         handler(this, ircMessageSource, targets);
 }
コード例 #23
0
ファイル: IrcLocalUser.cs プロジェクト: jfarre20/Ubiquitous
        /// <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);
        }
コード例 #24
0
ファイル: Extensions.cs プロジェクト: Sharparam/PdhoBot
        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);
        }
コード例 #25
0
 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;
 }
コード例 #26
0
 /// <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));
 }
コード例 #27
0
 public async Task SendMessageAsync(IIrcMessageTarget target, string message)
 {
     await SendMessageAsync(target.TargetName, message);
 }
コード例 #28
0
        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;
        }
コード例 #29
0
ファイル: TwitchClient.cs プロジェクト: NitroXenon/WinterBot
 void m_client_UnsuccessfulLogin(IrcClient source, IIrcMessageSource ircMessageSource, IIrcMessageTarget[] targets)
 {
     m_loginFailed = true;
     m_registeredEvent.Set();
 }
コード例 #30
0
ファイル: Extensions.cs プロジェクト: Sharparam/PdhoBot
 public static void SendMessage(this IrcLocalUser user, IIrcMessageTarget target, string format, params object[] args)
 {
     user.SendMessage(target, String.Format(format, args));
 }
コード例 #31
0
ファイル: IRCCommands.cs プロジェクト: darkunderdog/TShockIRC
        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.");
            }
        }
コード例 #32
0
ファイル: CtcpClient.cs プロジェクト: mattias197711/Jackett2
 /// <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);
 }
コード例 #33
0
ファイル: CtcpClient.cs プロジェクト: NitroXenon/WinterBot
 /// <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 });
 }
コード例 #34
0
ファイル: CtcpClient.cs プロジェクト: mattias197711/Jackett2
 /// <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 });
 }
コード例 #35
0
 /// <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 });
 }
コード例 #36
0
ファイル: CtcpClient.cs プロジェクト: mattias197711/Jackett2
 /// <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 });
 }
コード例 #37
0
 /// <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 });
 }
コード例 #38
0
ファイル: CtcpClient.cs プロジェクト: mattias197711/Jackett2
 /// <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 });
 }
コード例 #39
0
ファイル: IrcLocalUser.cs プロジェクト: txdv/ircdotnet
        /// <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);
        }
コード例 #40
0
 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;
 }
コード例 #41
0
 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.");
 }
コード例 #42
0
        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.");
            }
        }