Esempio n. 1
0
        private void CreateRegistrarDomain(int packageId)
        {
            // create command arguments
            CommandParams args = PrepeareAccountParams();

            // ensure user settings are ok & copy them
            EnsureUserSettings(args);

            // get package info
            PackageSettings nsSettings = PackageController.GetPackageSettings(
                packageId,
                PackageSettings.NAME_SERVERS
                );
            // read service cycle
            ServiceLifeCycle lifeCycle = ServiceController.GetServiceLifeCycle(
                ServiceInfo.SpaceId,
                ServiceInfo.ServiceId
                );

            // copy domain name related settings
            args[CommandParams.NAME_SERVERS] = nsSettings[PackageSettings.NAME_SERVERS];
            args[CommandParams.DOMAIN_NAME]  = Domain;
            args[CommandParams.DOMAIN_TLD]   = TLD;
            args[CommandParams.YEARS]        = lifeCycle.CycleLength.ToString();

            // call registrar's API
            RegisterDomainResult rdResult = Registrar.RegisterDomain(args);

            // save registrar's order number
            ServiceSettings[REGISTRAR_ORDER_ID] = rdResult[RegisterDomainResult.ORDER_NUMBER];
            ServiceSettings[REGISTRAR]          = Registrar.RegistrarName;
        }
Esempio n. 2
0
        internal bool Execute(CommandParams param)
        {
            var driver = param.Application.GetDriver();

            driver.SwitchTo().DefaultContent();
            return(true);
        }
        internal string Execute(CommandParams param)
        {
            var         locatecommand = new GetVisibleElement();
            IWebElement element       = locatecommand.Execute(param);

            return(element.GetAttribute(param.InputData));
        }
Esempio n. 4
0
    public override void Execute(CommandParams commandParams)
    {
        StatusEffectChance[] chances = new StatusEffectChance[] {
            new StatusEffectChance(STUN, stun),
            new StatusEffectChance(POISON, poison),
            new StatusEffectChance(BURN, burn),
            new StatusEffectChance(FREEZE, freeze),
            new StatusEffectChance(CRYING, crying),
            new StatusEffectChance(HUNGRY, hungry),
            new StatusEffectChance(FORGET, forget),
        };
        commandParams.GetTargets().ToList().ForEach(target => {
            chances.ToList().ForEach(it => {
                float weakness = UnitUtil.GetWeakness(it.type, target);
                bool hit       = Random.Range(0f, 100f) <= it.chance + weakness;
                if (hit)
                {
                    UnitUtil.SetStatusEffect(target, it.type);
                }
                // Debug.Log(hit + "/" + it.type);
            });
        });

        new DamageFlatUseCase(commandParams).Execute();
    }
        internal bool Execute(CommandParams param)
        {
            var driver = param.Application.GetDriver();

            driver.Navigate().GoToUrl(param.InputData);
            return(true);
        }
Esempio n. 6
0
        private void list_keys(CommandParams p)
        {
            Infobot info = (Infobot)p.SourceChannel.RetrieveObject("Infobot");

            if (info == null)
            {
                return;
            }

            string result = "";

            if (info.Keys.Count == 0)
            {
                result = "No keys defined";
            }
            else
            {
                foreach (Infobot.InfobotKey key in info.Keys)
                {
                    result += key.Key + ", ";
                }
            }

            if (result.EndsWith(", ", StringComparison.InvariantCulture))
            {
                result = result.Substring(0, result.Length - 2);
            }

            if (result.Length > 450)
            {
                result = result.Substring(0, 450) + "...";
            }
            IRC.DeliverMessage(result, p.SourceChannel);
        }
Esempio n. 7
0
            public static void ProcessCommands(Channel chan, string nick, string ident, string host, string message)
            {
                if (!message.StartsWith(Configuration.System.CommandPrefix))
                {
                    return;
                }
                CommandParams p = new CommandParams
                {
                    SourceChannel = chan,
                    User          = new libirc.UserInfo(nick, ident, host),
                    Message       = message
                };

                message   = message.Substring(1);
                p.Command = message;
                if (message.Contains(" "))
                {
                    p.Parameters = message.Substring(message.IndexOf(" ") + 1);
                    p.Command    = message.Substring(0, message.IndexOf(" "));
                }

                GenericCommand command = CommandPool.GetCommand(p.Command);

                if (command != null)
                {
                    command.Launch(p);
                }
            }
Esempio n. 8
0
        public void cmNotify(CommandParams pm)
        {
            if (String.IsNullOrEmpty(pm.Parameters))
                return;

            this.NotifyUser(pm.Message, pm.User, pm.SourceChannel);
        }
    private void Next(int i)
    {
        // Get the skill
        SkillSO skill = activeUnit.skills[i];
        // Create wrapper object with the skill
        CommandParams commandParams = new CommandParams(activeUnit, null, skill);

        // Go to the next state: select one target or select item
        if (skill.targeting.Equals(SINGLE_OPPONENT) || skill.targeting.Equals(SINGLE_ALLY) || skill.targeting.Equals(REVIVE))
        {
            base.owner.ChangeState(new SelectOneTargetState(base.owner, commandParams));
        }
        else if (skill.targeting.Equals(SELF))
        {
            commandParams = new CommandParams(activeUnit, activeUnit, null, skill);
            base.owner.ChangeState(new AttackState(base.owner, commandParams));
        }
        else if (skill.targeting.Equals(ITEM_STATE))
        {
            base.owner.ChangeState(new SelectItemState(base.owner, owner.GetInventory(), commandParams));
        }
        else
        {
            // Multiple opponents or allies
        }
    }
        internal bool Execute(CommandParams param)
        {
            var driver        = param.Application.GetDriver();
            var parenthandle  = param.Application.ParentWindowHandle;
            var WindowHandles = driver.WindowHandles;

            if (WindowHandles.Count == 1)
            {
                throw new ContinueRetryException("No child window exists");
            }
            if (WindowHandles.Count > 2)
            {
                throw new Exception("More than one child window is available");
            }
            string ChildHandle = string.Empty;

            for (int counter = 0; counter < WindowHandles.Count; counter++)
            {
                if (!string.Equals(WindowHandles[counter], parenthandle))
                {
                    ChildHandle = WindowHandles[counter];
                    break;
                }
            }
            driver.SwitchTo().Window(ChildHandle);
            Trace.WriteLine(string.Format("Switched to child window {0}", ChildHandle));
            return(true);
        }
Esempio n. 11
0
        public Query(Connection conn, SqlStringTemplate sql, CommandParams cmdParams)
        {
            //*** query use conn resource such as parser,writer
            //so 1 query 1 connection      
            Query bindingQuery = conn.BindingQuery;
            if (bindingQuery != null)
            {
                //check if binding query can be close 
                if (!bindingQuery.LateClose())
                {
                    //can't use this conn
                    throw new Exception("connection is in used");
                }
            }
            //--------------------------------------------------------------
            conn.BindingQuery = this;
            //--------------------------------------------------------------
            if (sql == null)
            {
                throw new Exception("Sql command can not null.");
            }
            //--------------------------------------------------------------
            this._conn = conn;
            this._cmdParams = cmdParams;
            //--------------------------------------------------------------

            nestTables = false;
            _sqlParserMx = conn.MySqlParserMx;
            _writer = conn.PacketWriter;
            //_receiveBuffer = null;
            _sqlStrTemplate = sql;
        }
Esempio n. 12
0
        private void translate(CommandParams p)
        {
            if (string.IsNullOrEmpty(p.Parameters))
            {
                return;
            }


            List <string> parts = new List <string>(p.Parameters.Split(' '));

            if (parts.Count < 3)
            {
                IRC.DeliverMessage("Invalid number of parameters", p.SourceChannel);
                return;
            }
            string target          = null;
            string source_language = parts[0];
            string target_language = parts[1];

            if (!IsValid(source_language) || !IsValid(target_language))
            {
                IRC.DeliverMessage(p.User.Nick + ": invalid language!", p.SourceChannel);
                return;
            }
            string text = p.Parameters.Substring(p.Parameters.IndexOf(parts[1]) + parts[1].Length + 1);

            if (text.Contains("|"))
            {
                target = text.Substring(text.IndexOf("|") + 1).Trim();
                text   = text.Substring(0, text.IndexOf("|"));
            }
            // schedule a message
            Ring.Add(new Buffer.Item(p.SourceChannel, source_language, target_language, target, text));
        }
    public override void OnStateExit()
    {
        CommandParams newParams = new CommandParams(commandParams.GetSubject(), target, null, commandParams.GetSkill());

        targetSelector.Hide();
        targetSelector.OnTargetClicked -= Next;
    }
Esempio n. 14
0
        internal Query(Connection conn, SqlStringTemplate sql, CommandParams cmdParams)
        {
            //***a query uses conn resource such as parser,writer
            //so 1 query=> 1 connection
            if (sql == null)
            {
                throw new Exception("Sql command can not null.");
            }

            Query bindingQuery = conn.BindingQuery;

            if (bindingQuery != null)
            {
                //check if binding query can be close
                if (!bindingQuery.LateClose())
                {
                    //can't use this conn
                    throw new Exception("connection is in used");
                }
            }
            //--------------------------------------------------------------
            conn.BindingQuery = this;
            //--------------------------------------------------------------
            _conn      = conn;
            _cmdParams = cmdParams;
            //--------------------------------------------------------------

            _nestTables  = false;
            _sqlParserMx = conn.MySqlParserMx;
            _writer      = conn.PacketWriter;
            //_receiveBuffer = null;
            _sqlStrTemplate = sql;
        }
Esempio n. 15
0
        private void time(CommandParams p)
        {
            DateTime time = DateTime.UtcNow;

            //DateTime eastern = TimeZoneInfo.ConvertTimeBySystemTimeZoneId(DateTime.UtcNow, "Eastern Standard Time");
            IRC.DeliverMessage(p.User.Nick + ": It is " + time + " UTC", p.SourceChannel);
        }
Esempio n. 16
0
        private void cmRevoke(CommandParams pm)
        {
            if (String.IsNullOrEmpty(pm.Parameters))
            {
                return;
            }

            string        name       = pm.Parameters.Trim();
            List <string> parameters = new List <string>(name.Split(' '));

            if (parameters.Count != 2)
            {
                IRC.DeliverMessage("Invalid number of parameters", pm.SourceChannel);
                return;
            }
            string role = pm.SourceChannel.Name + "." + parameters[0];

            lock (Security.Roles)
            {
                if (!Security.Roles.ContainsKey(role))
                {
                    IRC.DeliverMessage("There is no role of that name", pm.SourceChannel);
                    return;
                }
                Security.Roles[role].Revoke(parameters[1]);
            }
            IRC.DeliverMessage("Successfuly revoked " + parameters[1] + " from " + role, pm.SourceChannel);
            IsUpdated = true;
            return;
        }
Esempio n. 17
0
        public ActionResult <CommandRest> CreateCommand(CommandParams command)
        {
            var commandModel = _mapper.Map <Command>(command);

            _repository.CreateCommand(commandModel);
            return(Ok(_mapper.Map <CommandRest>(commandModel)));
        }
Esempio n. 18
0
        public TransferDomainResult TransferDomain(CommandParams args, DomainContacts contacts)
        {
            TransferDomainResult result = new TransferDomainResult();

            result[TransferDomainResult.TRANSFER_ORDER_NUMBER] = DateTime.Now.ToString("yyyy-MM-dd") + "-" + args[CommandParams.DOMAIN_NAME];

            return(result);
        }
Esempio n. 19
0
        public ActionResult <CommandRest> UpdateCommand(int id, CommandParams command)
        {
            var commandModel = _repository.GetCommandById(id);

            _mapper.Map(command, commandModel);
            _repository.UpdateCommand(id, commandModel);
            return(NoContent());
        }
Esempio n. 20
0
        internal bool Execute(CommandParams param)
        {
            var         locatecommand = new GetVisibleElement();
            IWebElement element       = locatecommand.Execute(param);

            element.Clear();
            return(true);
        }
Esempio n. 21
0
        public void cmNotify(CommandParams pm)
        {
            if (String.IsNullOrEmpty(pm.Parameters))
            {
                return;
            }

            this.NotifyUser(pm.Message, pm.User, pm.SourceChannel);
        }
Esempio n. 22
0
        internal bool Execute(CommandParams param)
        {
            var         locatecommand = new GetVisibleElement();
            IWebElement frame         = (IWebElement)locatecommand.Execute(param);
            var         driver        = param.Application.GetDriver();

            driver.SwitchTo().Frame(frame);
            return(true);
        }
        internal bool Execute(CommandParams param)
        {
            var           locatecommand = new GetVisibleElement();
            IWebElement   element       = locatecommand.Execute(param);
            SelectElement select        = new SelectElement(element);

            select.SelectByText(param.InputData);
            return(true);
        }
Esempio n. 24
0
        internal bool Execute(CommandParams param)
        {
            var driver       = param.Application.GetDriver();
            var parenthandle = param.Application.ParentWindowHandle;

            driver.SwitchTo().Window(parenthandle);
            Trace.WriteLine(string.Format("Switched to parent window {0}", parenthandle));
            return(true);
        }
Esempio n. 25
0
 private void github_Insert(CommandParams p)
 {
     if (string.IsNullOrEmpty(p.Parameters))
     {
         IRC.DeliverMessage("This command requires exactly 1 parameter", p.SourceChannel);
         return;
     }
     lock (Core.DB.DatabaseLock)
     {
         string error = "unknown";
         Core.DB.Connect();
         if (!Core.DB.IsConnected)
         {
             if (Core.DB.ErrorBuffer != null)
             {
                 error = Core.DB.ErrorBuffer;
             }
             IRC.DeliverMessage("Unable to connect to SQL: " + error, p.SourceChannel);
             return;
         }
         // first check if repository isn't already there
         List <List <string> > result = Core.DB.Select("github_repo_info", "name, channel", "WHERE name = '" + Core.DB.EscapeInput(p.Parameters) + "' AND channel = '" +
                                                       Core.DB.EscapeInput(p.SourceChannel.Name) + "'");
         if (result.Count != 0)
         {
             IRC.DeliverMessage("This repository is already in DB", p.SourceChannel);
             Core.DB.Disconnect();
             return;
         }
         Database.Row row = new Database.Row();
         row.Values.Add(new Database.Row.Value(0));
         row.Values.Add(new Database.Row.Value(p.Parameters, Database.DataType.Varchar));
         row.Values.Add(new Database.Row.Value(p.SourceChannel.Name, Database.DataType.Varchar));
         if (GetConfig(p.SourceChannel, "NetCat.Token", false))
         {
             row.Values.Add(new Database.Row.Value(GetConfig(p.SourceChannel, "NetCat.TokenData", ""), Database.DataType.Varchar));
         }
         else
         {
             row.Values.Add(new Database.Row.Value("", Database.DataType.Varchar));
         }
         row.Values.Add(new Database.Row.Value(true));
         if (!Core.DB.InsertRow("github_repo_info", row))
         {
             if (Core.DB.ErrorBuffer != null)
             {
                 error = Core.DB.ErrorBuffer;
             }
             IRC.DeliverMessage("Failed to insert row: " + error, p.SourceChannel);
             Core.DB.Disconnect();
             return;
         }
         Core.DB.Commit();
         Core.DB.Disconnect();
     }
     IRC.DeliverMessage("Hooks from " + p.Parameters + " will be now displayed in this channel", p.SourceChannel);
 }
        public string BindValues(CommandParams cmdParams, bool forPrepareStmt)
        {
            StringBuilder strBuilder = new StringBuilder();
            int           count      = _sqlSections.Count;

            for (int i = 0; i < count; i++)
            {
                var sqlSection = _sqlSections[i];
                switch (sqlSection.sectionKind)
                {
                default:
                    throw new NotSupportedException();

                case SqlSectionKind.SqlText:
                    strBuilder.Append(sqlSection.Text);
                    break;

                case SqlSectionKind.ValueKey:


                    if (forPrepareStmt)
                    {
                        strBuilder.Append('?');
                    }
                    else
                    {
                        //get bind data
                        MyStructData bindedData;
                        if (!cmdParams.TryGetData(sqlSection.Text, out bindedData))
                        {
                            throw new Exception("Error : This key not assign." + sqlSection.Text);
                        }
                        else
                        {
                            //format data
                            FormatAndAppendData(strBuilder, ref bindedData);
                        }
                    }
                    break;

                case SqlSectionKind.SpecialKey:
                    string found;
                    if (cmdParams.TryGetSqlPart(sqlSection.Text, out found))
                    {
                        strBuilder.Append(found);
                    }
                    else
                    {
                        throw new Exception("not found " + sqlSection.Text);
                    }
                    break;
                }
            }

            return(strBuilder.ToString());
        }
    private void Next(string targetId)
    {
        // Get the target
        UnitSO target = base.owner.allUnits.First(it => it.unitId.Equals(targetId));
        // Create wrapper object with the subject, target and skill
        CommandParams newParams = new CommandParams(commandParams.GetSubject(), target, commandParams.GetItem(), commandParams.GetSkill());

        // Go to the next state: select one target or select item
        base.owner.ChangeState(new AttackState(base.owner, newParams));
    }
        internal bool Execute(CommandParams param)
        {
            var         locatecommand = new GetVisibleElement();
            IWebElement element       = (IWebElement)locatecommand.Execute(param);
            var         driver        = param.Application.GetDriver();
            Actions     action        = new Actions(driver);

            action.MoveToElement(element).Build().Perform();
            return(true);
        }
Esempio n. 29
0
        private void token_on(CommandParams p)
        {
            string token = GenerateToken();

            SetConfig(p.SourceChannel, "NetCat.Token", true);
            SetConfig(p.SourceChannel, "NetCat.TokenData", token);
            p.SourceChannel.SaveConfig();
            IRC.DeliverMessage("New token was generated for this channel, and it was sent to you in a private message", p.SourceChannel.Name);
            IRC.DeliverMessage("Token for " + p.SourceChannel.Name + " is: " + token, p.SourceUser.Nick);
        }
Esempio n. 30
0
        public MyStructData[] PrepareBoundData(CommandParams cmdParams)
        {
            //1. check proper type and
            //2. check all values are in its range
            //extract and arrange

            int j = _keys.Count;

            for (int i = 0; i < j; ++i)
            {
                SqlBoundSection key = _keys[i];
                if (!cmdParams.TryGetData(key.Text, out _preparedValues[i]))
                {
                    //not found key
                    throw new Exception("not found " + _keys[i].Text);
                }
                else
                {
                    //-------------------------------
                    //TODO: check here
                    //all field type is 253 ?
                    //error
                    //-------------------------------
                    //check
                    //FieldPacket fieldInfo = key.fieldInfo;
                    //switch ((MySqlDataType)fieldInfo.columnType)
                    //{
                    //    case MySqlDataType.VARCHAR:
                    //    case MySqlDataType.VAR_STRING:
                    //        {
                    //            //check length
                    //            if (_preparedValues[i].myString.Length > fieldInfo.maxLengthOfField)
                    //            {
                    //                //TODO: notify user how to handle this data
                    //                //before error
                    //            }
                    //        }
                    //        break;
                    //    case MySqlDataType.BLOB:
                    //    case MySqlDataType.LONG_BLOB:
                    //    case MySqlDataType.MEDIUM_BLOB:
                    //        {
                    //            if (_preparedValues[i].myString.Length > fieldInfo.maxLengthOfField)
                    //            {
                    //                //TODO: notify user how to handle this data
                    //                //before error
                    //            }
                    //        }
                    //        break;
                    //}
                }
            }

            return(_preparedValues);
        }
Esempio n. 31
0
 private void On(CommandParams p)
 {
     if (GetConfig(p.SourceChannel, "OP.Enabled", false))
     {
         IRC.DeliverMessage(messages.Localize("OpE1", p.SourceChannel.Language), p.SourceChannel);
         return;
     }
     IRC.DeliverMessage(messages.Localize("OpM1", p.SourceChannel.Language), p.SourceChannel.Name);
     SetConfig(p.SourceChannel, "OP.Enabled", true);
     p.SourceChannel.SaveConfig();
 }
Esempio n. 32
0
 private void PermanentOff(CommandParams p)
 {
     if (!GetConfig(p.SourceChannel, "OP.Permanent", false))
     {
         IRC.DeliverMessage(messages.Localize("OpE2", p.SourceChannel.Language), p.SourceChannel);
         return;
     }
     IRC.DeliverMessage(messages.Localize("OpM2", p.SourceChannel.Language), p.SourceChannel);
     SetConfig(p.SourceChannel, "OP.Permanent", false);
     p.SourceChannel.SaveConfig();
 }
Esempio n. 33
0
 private void github_Insert(CommandParams p)
 {
     if (string.IsNullOrEmpty(p.Parameters))
     {
         IRC.DeliverMessage("This command requires exactly 1 parameter", p.SourceChannel);
         return;
     }
     lock (Core.MysqlDB.DatabaseLock)
     {
         string error = "unknown";
         Core.MysqlDB.Connect();
         if (!Core.MysqlDB.IsConnected)
         {
             if (Core.MysqlDB.ErrorBuffer != null)
             {
                 error = Core.MysqlDB.ErrorBuffer;
             }
             IRC.DeliverMessage("Unable to connect to SQL: " + error, p.SourceChannel);
             return;
         }
         // first check if repository isn't already there
         List<List<string>> result = Core.MysqlDB.Select("github_repo_info", "name, channel", "WHERE name = '" + Core.MysqlDB.EscapeInput(p.Parameters) + "' AND channel = '" +
             Core.MysqlDB.EscapeInput(p.SourceChannel.Name) + "'");
         if (result.Count != 0)
         {
             IRC.DeliverMessage("This repository is already in DB", p.SourceChannel);
             Core.MysqlDB.Disconnect();
             return;
         }
         Database.Row row = new Database.Row();
         row.Values.Add(new Database.Row.Value(0));
         row.Values.Add(new Database.Row.Value(p.Parameters, Database.DataType.Varchar));
         row.Values.Add(new Database.Row.Value(p.SourceChannel.Name, Database.DataType.Varchar));
         if (GetConfig(p.SourceChannel, "NetCat.Token", false))
             row.Values.Add(new Database.Row.Value(GetConfig(p.SourceChannel, "NetCat.TokenData", ""), Database.DataType.Varchar));
         else
             row.Values.Add(new Database.Row.Value("", Database.DataType.Varchar));
         row.Values.Add(new Database.Row.Value(true));
         if (!Core.MysqlDB.InsertRow("github_repo_info", row))
         {
             if (Core.MysqlDB.ErrorBuffer != null)
             {
                 error = Core.DB.ErrorBuffer;
             }
             IRC.DeliverMessage("Failed to insert row: " + error, p.SourceChannel);
             Core.MysqlDB.Disconnect();
             return;
         }
         Core.MysqlDB.Commit();
         Core.MysqlDB.Disconnect();
     }
     IRC.DeliverMessage("Hooks from " + p.Parameters + " will be now displayed in this channel", p.SourceChannel);
 }
Esempio n. 34
0
 private void DisplayInfo(CommandParams pm)
 {
     if (pm.SourceChannel.Name == Configuration.System.DebugChan)
     {
         foreach (Instance instance in Instance.Instances.Values)
         {
             instance.Network.Act("is online; channels: " + instance.ChannelCount +
                 " connected: " + instance.IsConnected + " working: " +
                 instance.IsWorking + " queue: " + instance.QueueSize(), pm.SourceChannel.Name);
         }
     }
 }
Esempio n. 35
0
            public static void ProcessCommands(Channel chan, string nick, string ident, string host, string message)
            {
                if (!message.StartsWith(Configuration.System.CommandPrefix))
                    return;
                CommandParams p = new CommandParams
                {
                    SourceChannel = chan,
                    User = new libirc.UserInfo(nick, ident, host),
                    Message = message
                };
                message = message.Substring(1);
                p.Command = message;
                if (message.Contains(" "))
                {
                    p.Parameters = message.Substring(message.IndexOf(" ") + 1);
                    p.Command = message.Substring(0, message.IndexOf(" "));
                }

                GenericCommand command = CommandPool.GetCommand(p.Command);
                if (command != null)
                    command.Launch(p);
            }
Esempio n. 36
0
 private void cmd_off(CommandParams pm)
 {
     if (!GetConfig(pm.SourceChannel, "RC.Enabled", false))
     {
         IRC.DeliverMessage(messages.Localize("Feed6", pm.SourceChannel.Language), pm.SourceChannel);
         return;
     }
     IRC.DeliverMessage(messages.Localize("Feed7", pm.SourceChannel.Language), pm.SourceChannel);
     SetConfig(pm.SourceChannel, "RC.Enabled", false);
     pm.SourceChannel.SaveConfig();
 }
Esempio n. 37
0
 private void github_Off(CommandParams p)
 {
     if (GetConfig(p.SourceChannel, "github.enabled", false))
     {
         SetConfig(p.SourceChannel, "github.enabled", false);
         IRC.DeliverMessage("GitHub was turned off for this channel", p.SourceChannel);
         return;
     }
     else
     {
         IRC.DeliverMessage("GitHub is already off, nothing done", p.SourceChannel);
     }
 }
Esempio n. 38
0
 private void minor_on(CommandParams pm)
 {
     if (GetConfig(pm.SourceChannel, "Minor.Enabled", false))
     {
         IRC.DeliverMessage(messages.Localize("Feed13", pm.SourceChannel.Language), pm.SourceChannel);
         return;
     }
     IRC.DeliverMessage(messages.Localize("Feed9", pm.SourceChannel.Language), pm.SourceChannel);
     SetConfig(pm.SourceChannel, "Minor.Enabled", true);
     pm.SourceChannel.SaveConfig();
 }
Esempio n. 39
0
        private void translate(CommandParams p)
        {
            if (string.IsNullOrEmpty(p.Parameters))
                return;

            List<string> parts = new List<string>(p.Parameters.Split(' '));
            if (parts.Count < 3)
            {
                IRC.DeliverMessage("Invalid number of parameters", p.SourceChannel);
                return;
            }
            string target = null;
            string source_language = parts[0];
            string target_language = parts[1];
            if (!IsValid(source_language) || !IsValid(target_language))
            {
                IRC.DeliverMessage(p.User.Nick + ": invalid language!", p.SourceChannel);
                return;
            }
            string text = p.Parameters.Substring(p.Parameters.IndexOf(parts[1]) + parts[1].Length + 1);
            if (text.Contains("|"))
            {
                target = text.Substring(text.IndexOf("|") + 1).Trim();
                text = text.Substring(0, text.IndexOf("|"));
            }
            // schedule a message
            Ring.Add(new Buffer.Item(p.SourceChannel, source_language, target_language, target, text));
        }
Esempio n. 40
0
 private void PermanentOn(CommandParams p)
 {
     if (GetConfig(p.SourceChannel, "OP.Permanent", false))
     {
         IRC.DeliverMessage(messages.Localize("OpE3", p.SourceChannel.Language), p.SourceChannel);
         return;
     }
     IRC.DeliverMessage(messages.Localize("OpM3", p.SourceChannel.Language), p.SourceChannel);
     SetConfig(p.SourceChannel, "OP.Permanent", true);
     p.SourceChannel.SaveConfig();
 }
Esempio n. 41
0
        private void cmGrant(CommandParams pm)
        {
            if (String.IsNullOrEmpty(pm.Parameters))
                return;

            string name = pm.Parameters;
            List<string> parameters = new List<string>(name.Split(' '));
            if (parameters.Count != 2)
            {
                IRC.DeliverMessage("Invalid number of parameters", pm.SourceChannel);
                return;
            }
            switch (parameters[1])
            {
                case "root":
                case "terminal":
                case "halt":
                    IRC.DeliverMessage("This permission can't be granted to anyone, sorry", pm.SourceChannel);
                    return;
            }
            string role = pm.SourceChannel.Name + "." + parameters[0];
            lock (Security.Roles)
            {
                if (!Security.Roles.ContainsKey(role))
                {
                    Security.Roles.Add(role, new Security.Role(1));
                }
                Security.Roles[role].Grant(parameters[1]);
            }
            IsUpdated = true;
            IRC.DeliverMessage("Successfuly granted " + parameters[1] + " to " + role, pm.SourceChannel);
            return;
        }
Esempio n. 42
0
 private void cmSeenHost(CommandParams parameters)
 {
     if (parameters.Parameters == null)
         return;
     if (GetConfig(parameters.SourceChannel, "Seen.Enabled", false) && parameters.Parameters != "")
         RetrieveStatusOfHost(parameters.Parameters, parameters.SourceChannel, parameters.User.Nick);
 }
Esempio n. 43
0
        public MyStructData[] PrepareBoundData(CommandParams cmdParams)
        {
            //1. check proper type and 
            //2. check all values are in its range  
            //extract and arrange 

            int j = _keys.Count;
            for (int i = 0; i < j; ++i)
            {
                SqlBoundSection key = _keys[i];
                if (!cmdParams.TryGetData(key.Text, out _preparedValues[i]))
                {
                    //not found key 
                    throw new Exception("not found " + _keys[i].Text);
                }
                else
                {
                    //-------------------------------
                    //TODO: check here 
                    //all field type is 253 ?
                    //error
                    //------------------------------- 
                    //check
                    //FieldPacket fieldInfo = key.fieldInfo;
                    //switch ((MySqlDataType)fieldInfo.columnType)
                    //{
                    //    case MySqlDataType.VARCHAR:
                    //    case MySqlDataType.VAR_STRING:
                    //        {
                    //            //check length
                    //            if (_preparedValues[i].myString.Length > fieldInfo.maxLengthOfField)
                    //            {
                    //                //TODO: notify user how to handle this data
                    //                //before error
                    //            }
                    //        }
                    //        break;
                    //    case MySqlDataType.BLOB:
                    //    case MySqlDataType.LONG_BLOB:
                    //    case MySqlDataType.MEDIUM_BLOB:
                    //        {
                    //            if (_preparedValues[i].myString.Length > fieldInfo.maxLengthOfField)
                    //            {
                    //                //TODO: notify user how to handle this data
                    //                //before error
                    //            }
                    //        }
                    //        break;
                    //}

                }
            }

            return _preparedValues;
        }
Esempio n. 44
0
 private void cmSeenrx(CommandParams parameters)
 {
     if (string.IsNullOrEmpty(parameters.Parameters))
         return;
     if (GetConfig(parameters.SourceChannel, "Seen.Enabled", false))
     {
         RegEx(parameters.Parameters, parameters.SourceChannel, parameters.User.Nick);
     }
 }
Esempio n. 45
0
        //------------
        //we create query for each command and not reuse it
        //------------

        internal Query(Connection conn, string sql, CommandParams cmdParams)
            : this(conn, new SqlStringTemplate(sql), cmdParams)
        {
        }
Esempio n. 46
0
 private void github_Remove(CommandParams p)
 {
     if (string.IsNullOrEmpty(p.Parameters))
     {
         IRC.DeliverMessage("This command requires exactly 1 parameter", p.SourceChannel);
         return;
     }
     lock (Core.MysqlDB.DatabaseLock)
     {
         string error = "unknown";
         Core.MysqlDB.Connect();
         if (!Core.MysqlDB.IsConnected)
         {
             if (Core.MysqlDB.ErrorBuffer != null)
             {
                 error = Core.MysqlDB.ErrorBuffer;
             }
             IRC.DeliverMessage("Unable to connect to SQL: " + error, p.SourceChannel);
             return;
         }
         // first check if repository isn't already there
         List<List<string>> result = Core.MysqlDB.Select("github_repo_info", "name, channel", "WHERE name = '" + Core.MysqlDB.EscapeInput(p.Parameters) + "' AND channel = '" +
             Core.MysqlDB.EscapeInput(p.SourceChannel.Name) + "'");
         if (result.Count == 0)
         {
             IRC.DeliverMessage("This repository is not in DB", p.SourceChannel);
             Core.MysqlDB.Disconnect();
             return;
         }
         Core.MysqlDB.Delete("github_repo_info", "WHERE name = '" + Core.MysqlDB.EscapeInput(p.Parameters)
             + "' AND channel = '"
             + Core.MysqlDB.EscapeInput(p.SourceChannel.Name) + "'");
         Core.MysqlDB.Commit();
         Core.MysqlDB.Disconnect();
     }
     IRC.DeliverMessage("Hooks from " + p.Parameters + " were disabled for this channel", p.SourceChannel);
 }
Esempio n. 47
0
 public void Exec(CommandParams pm)
 {
     lock (Tasks)
     {
         Task tx = new Task();
         if (pm.SourceUser != null)
             tx.user = pm.SourceUser;
         else
             tx.channel = pm.SourceChannel;
         tx.task = this;
         tx.parameters = this.Parameters;
         if (this.RequireParameters && string.IsNullOrEmpty(pm.Parameters))
         {
             if (pm.SourceUser != null)
                 IRC.DeliverMessage("You need to provide some parameters", pm.SourceUser);
             else
                 IRC.DeliverMessage("You need to provide some parameters", pm.SourceChannel);
             return;
         }
         string parameters = pm.Parameters;
         if (this.SingleParameter && parameters != null)
             parameters = "\"" + parameters.Replace("'", "\\'").Replace("\"", "\\\"") + "\"";
         else if (this.Escape && parameters != null)
             parameters = parameters.Replace("'", "\\'").Replace("\"", "\\\"");
         if (this.AcceptInput && parameters != null)
             tx.parameters += " " + parameters;
         Tasks.Add(tx);
     }
 }
Esempio n. 48
0
 private void On(CommandParams p)
 {
     if (GetConfig(p.SourceChannel, "OP.Enabled", false))
     {
         IRC.DeliverMessage(messages.Localize("OpE1", p.SourceChannel.Language), p.SourceChannel);
         return;
     }
     IRC.DeliverMessage(messages.Localize("OpM1", p.SourceChannel.Language), p.SourceChannel.Name);
     SetConfig(p.SourceChannel, "OP.Enabled", true);
     p.SourceChannel.SaveConfig();
 }
Esempio n. 49
0
 private void cmSeenOn(CommandParams parameters)
 {
     if (GetConfig(parameters.SourceChannel, "Seen.Enabled", false))
     {
         IRC.DeliverMessage(messages.Localize("seen-oe", parameters.SourceChannel.Language), parameters.SourceChannel.Name);
         return;
     }
     SetConfig(parameters.SourceChannel, "Seen.Enabled", true);
     parameters.SourceChannel.SaveConfig();
     IRC.DeliverMessage(messages.Localize("seen-on", parameters.SourceChannel.Language), parameters.SourceChannel.Name);
 }
Esempio n. 50
0
        private void cmGrantRole(CommandParams pm)
        {
            if (String.IsNullOrEmpty(pm.Parameters))
                return;

            string name = pm.Parameters;
            List<string> parameters = new List<string>(name.Split(' '));
            if (parameters.Count != 2)
            {
                IRC.DeliverMessage("Invalid number of parameters", pm.SourceChannel);
                return;
            }
            string role = pm.SourceChannel.Name + "." + parameters[0];
            Security.Role _role;
            lock (Security.Roles)
            {
                // now we need to get the role
                if (!Security.Roles.ContainsKey(parameters[1]))
                {
                    IRC.DeliverMessage("There is no such a role", pm.SourceChannel);
                    return;
                }
                _role = Security.Roles[parameters[1]];
                if (_role.IsPermitted("root"))
                {
                    IRC.DeliverMessage("Sorry but this role can't be granted", pm.SourceChannel);
                    return;
                }
                if (!Security.Roles.ContainsKey(role))
                    Security.Roles.Add(role, new Security.Role(_role.Level));
                else if (Security.Roles[role].Level < _role.Level)
                    Security.Roles[role].Level = _role.Level;
                if (Security.Roles[role].Roles.Contains(_role))
                {
                    IRC.DeliverMessage("This role already has this role as well", pm.SourceChannel);
                    return;
                }
                Security.Roles[role].Grant(_role);
            }
            IsUpdated = true;
            IRC.DeliverMessage("Successfuly granted role " + parameters[1] + " to " + role, pm.SourceChannel);
            return;
        }
Esempio n. 51
0
 private void time(CommandParams p)
 {
     DateTime time = DateTime.UtcNow;
     IRC.DeliverMessage(p.User.Nick + ": It is is " + time + " UTC", p.SourceChannel);
 }
Esempio n. 52
0
        private void cmRevoke(CommandParams pm)
        {
            if (String.IsNullOrEmpty(pm.Parameters))
                return;

            string name = pm.Parameters.Trim();
            List<string> parameters = new List<string>(name.Split(' '));
            if (parameters.Count != 2)
            {
                IRC.DeliverMessage("Invalid number of parameters", pm.SourceChannel);
                return;
            }
            string role = pm.SourceChannel.Name + "." + parameters[0];
            lock (Security.Roles)
            {
                if (!Security.Roles.ContainsKey(role))
                {
                    IRC.DeliverMessage("There is no role of that name", pm.SourceChannel);
                    return;
                }
                Security.Roles[role].Revoke(parameters[1]);
            }
            IRC.DeliverMessage("Successfuly revoked " + parameters[1] + " from " + role, pm.SourceChannel);
            IsUpdated = true;
            return;
        }
Esempio n. 53
0
 private void github_On(CommandParams p)
 {
     if (!GetConfig(p.SourceChannel, "github.enabled", false))
     {
         SetConfig(p.SourceChannel, "github.enabled", true);
         IRC.DeliverMessage("GitHub was enabled for this channel, use github+ to add some repos", p.SourceChannel);
         return;
     }
     else
     {
         IRC.DeliverMessage("GitHub is already enabled, nothing done", p.SourceChannel);
     }
 }
Esempio n. 54
0
        private void cmRevokeRole(CommandParams pm)
        {
            if (String.IsNullOrEmpty(pm.Parameters))
                return;

            string name = pm.Parameters;
            List<string> parameters = new List<string>(name.Split(' '));
            if (parameters.Count != 2)
            {
                IRC.DeliverMessage("Invalid number of parameters", pm.SourceChannel);
                return;
            }
            string role = pm.SourceChannel.Name + "." + parameters[0];
            Security.Role _role;
            lock (Security.Roles)
            {
                // now we need to get the role
                if (!Security.Roles.ContainsKey(parameters[1]))
                {
                    IRC.DeliverMessage("There is no such a role", pm.SourceChannel);
                    return;
                }
                _role = Security.Roles[parameters[1]];
                if (!Security.Roles.ContainsKey(role))
                {
                    IRC.DeliverMessage("There is no such a role", pm.SourceChannel);
                    return;
                }
                if (!Security.Roles[role].Roles.Contains(_role))
                {
                    IRC.DeliverMessage("This role doesn't has this role so I can't revoke it!!", pm.SourceChannel);
                    return;
                }
                Security.Roles[role].Revoke(_role);
            }
            IsUpdated = true;
            IRC.DeliverMessage("Successfuly revoked role" + parameters[1] + " to " + role, pm.SourceChannel);
            return;
        }
Esempio n. 55
0
 private void cmd_restart(CommandParams pm)
 {
     IRC.DeliverMessage("Reconnecting to RC feed", pm.SourceChannel);
     RecentChanges.Provider.Disconnect();
     RecentChanges.Provider.Connect();
 }
Esempio n. 56
0
 private void LastPing(CommandParams info)
 {
     IRC.DeliverMessage(RecentChanges.LastMessage.ToString(), info.SourceChannel);
 }