Exemplo n.º 1
0
        private async Task HandleReactionAdded(Cacheable <IUserMessage, ulong> message, ISocketMessageChannel channel, SocketReaction reaction)
        {
            if (reaction.User.IsSpecified && reaction.User.Value.IsBot)
            {
                return;
            }

            string reactionEmote = reaction.Emote.Name;

            // if an Eye emoji was added, let's process it
            if ((reactionEmote == "👁" || reactionEmote == "🖼") &&
                reaction.Message.IsSpecified &&
                (IsAuthorPatron(reaction.UserId) || BotConfig.Instance.OcrAutoIds.Contains(channel.Id)) &&
                reaction.Message.Value.ParseImageUrl() != null)
            {
                if (reaction.Message.Value.Reactions.Any(r => (r.Key.Name == "👁" || r.Key.Name == "🖼") && r.Value.ReactionCount > 1))
                {
                    return;
                }

                await this.HandleMessageReceivedAsync(reaction.Message.Value, reactionEmote);
            }

            var guildChannel = channel as SocketTextChannel;
            var settings     = SettingsConfig.GetSettings(guildChannel.Guild.Id);
            var customEmote  = reaction.Emote as Emote;

            if ((reactionEmote == "💬" || reactionEmote == "🗨️" || reactionEmote == "❓" || reactionEmote == "🤖") && reaction.Message.IsSpecified && !string.IsNullOrEmpty(reaction.Message.Value?.Content))
            {
                // if the reaction already exists, don't re-process.
                if (reaction.Message.Value.Reactions.Any(r => (r.Key.Name == "💬" || r.Key.Name == "🗨️" || r.Key.Name == "❓" || r.Key.Name == "🤖") && r.Value.ReactionCount > 1))
                {
                    return;
                }

                await this.HandleMessageReceivedAsync(reaction.Message.Value, reactionEmote, reaction.User.Value);
            }
            else if (reactionEmote == "➕" || reactionEmote == "➖" || customEmote?.Id == settings.RoleAddEmoteId || customEmote?.Id == settings.RoleRemoveEmoteId)
            {
                // handle possible role adds/removes
                IUserMessage reactionMessage = null;
                if (reaction.Message.IsSpecified)
                {
                    reactionMessage = reaction.Message.Value;
                }
                else
                {
                    reactionMessage = await reaction.Channel.GetMessageAsync(reaction.MessageId) as IUserMessage;
                }

                if (await RoleCommand.AddRoleViaReaction(reactionMessage, reaction))
                {
                    await reactionMessage.RemoveReactionAsync(reaction.Emote, reaction.User.Value);
                }
            }
        }
Exemplo n.º 2
0
        public ActionResult CreateRole(RoleCommand command)
        {
            if (ModelState.IsValid)
            {
                return(View());
            }
            var result = _commandBus.Send(command);

            return(JsonMessage(result));
        }
    public void SetCommand(RoleCommand _command, params System.Object[] _params)
    {
        switch(_command)
        {
        case RoleCommand.Display:
            Display((bool)_params[0]);
            break;

        case RoleCommand.Action:
            AddAction((RoleAction)_params[0]);
            break;
        }
    }
Exemplo n.º 4
0
 public override PlayerStateEnum Command(RoleCommand cmd, params object[] args)
 {
     if (cmd == RoleCommand.Walk)
     {
         return(PlayerStateEnum.Walk);
     }
     if (cmd == RoleCommand.Run)
     {
         return(PlayerStateEnum.Run);
     }
     else
     {
         return(state);
     }
 }
Exemplo n.º 5
0
 public JsonResult NewBackendRoleCommand()
 {
     try
     {
         RoleCommand rCmd = AddEntity <RoleCommand>(new RoleCommand {
             SourceRole_Id = BuiltIns.DefaultRole.Id, TargetRole_Id = BuiltIns.AllRole.Id, Command_Id = BuiltIns.DefaultBackendCommand.Id, IsManagerCommand = false, IsBuiltIn = false
         });
         RoleCommandView view = new RoleCommandView(rCmd, BuiltIns.DefaultBackendCommand);
         return(Json(new { Success = true, Model = new RoleCommandModel(view), Message = string.Empty }, JsonRequestBehavior.AllowGet));
     }
     catch (DatabaseException exception)
     {
         return(Json(new { Success = true, Message = exception.Message }, JsonRequestBehavior.AllowGet));
     }
 }
 public UnitOfWorkEntityFramework(FrapperDbContext context)
 {
     _context             = context;
     AssignedRolesCommand = new AssignedRolesCommand(_context);
     RoleCommand          = new RoleCommand(_context);
     UserMasterCommand    = new UserMasterCommand(_context);
     UserTokensCommand    = new UserTokensCommand(_context);
     MenuCategoryCommand  = new MenuCategoryCommand(_context);
     MenuMasterCommand    = new MenuMasterCommand(_context);
     SubMenuMasterCommand = new SubMenuMasterCommand(_context);
     VerificationCommand  = new VerificationCommand(_context);
     ProfileImageCommand  = new ProfileImageCommand(_context);
     NoticeCommand        = new NoticeCommand(_context);
     NoticeDetailsCommand = new NoticeDetailsCommand(_context);
     DocumentCommand      = new DocumentCommand(_context);
 }
Exemplo n.º 7
0
    public override void Command(RoleCommand _cmd, params object[] _args)
    {
        if (curState == null)
        {
            return;
        }

        PlayerStateEnum nextState = curState.Command(_cmd, _args);

        if (nextState != curState.state)
        {
            curState.Exit();
            curState = GetState(nextState, _args);
            curState.Enter();
        }
    }
Exemplo n.º 8
0
        public ActionResult New(NewRoleRequest req)
        {
            var command = new RoleCommand
            {
                Name           = req.Name,
                Description    = "",
                SourceRoleCode = "",
                Status         = req.Status? Lidia.Identity.Common.Models.EntityStatus.Active: Lidia.Identity.Common.Models.EntityStatus.Passive
            };

            var response = _identityClient.CreateRole(command);

            if (response.Type != Lidia.Identity.Common.Models.ServiceResponseTypes.Completed)
            {
                return(RedirectToAction("New"));
            }
            else
            {
                return(View());
            }
        }
Exemplo n.º 9
0
 public override PlayerStateEnum Command(RoleCommand _cmd, params object[] args)
 {
     if (_cmd == RoleCommand.Run)
     {
         Vector2 _dir = (Vector2)args[0];
         dir = _dir.normalized;
         roleObject.transform.localRotation = Quaternion.LookRotation(new Vector3(dir.x, 0, dir.y));
         return(PlayerStateEnum.None);
     }
     else if (_cmd == RoleCommand.Walk)
     {
         return(PlayerStateEnum.Walk);
     }
     if (_cmd == RoleCommand.Stand)
     {
         return(PlayerStateEnum.Stand);
     }
     else
     {
         return(state);
     }
 }
Exemplo n.º 10
0
        sealed public override void RetrieveCommands()
        {
            // Add all command and responses needed for configuring the BLE module.
            Command command = new AtCommand("AT");

            _commands.Add(command);

            //command = new NotificationCommand("AT+NOTI1");
            //_commands.Add(command);

            command = new AddressCommand("AT+ADDR?");
            _commands.Add(command);

            command = new NameCommand("AT+NAME?");
            _commands.Add(command);

            command = new FilterCommand("AT+FILT1");
            _commands.Add(command);

            command = new ShowCommand("AT+SHOW1");
            _commands.Add(command);


            command = new RoleCommand("AT+ROLE1");
            _commands.Add(command);

            command = new IMMECommand("AT+IMME1");
            _commands.Add(command);

            command = new DiscoveryCommand("AT+DISC?");
            _commands.Add(command);

            command = new ConnectCommand("AT+CON{0}");
            _commands.Add(command);

            command = new StartCommand("AT+START");
            _commands.Add(command);
        }
Exemplo n.º 11
0
    public static void SetRoleCommand(SceneControllerType _roleType, RoleCommand _command, params System.Object[] _params)
    {
        if (Instance == null)
            return;

        IRole role = null;

        switch(_roleType)
        {
        case SceneControllerType.Player:
            role = Instance.mSceneFlowData.Player;
            break;

        case SceneControllerType.Enemy:
            role = Instance.mSceneFlowData.Enemy;
            break;
        }

        if (role == null)
            return;

        role.SetCommand (_command, _params);
    }
Exemplo n.º 12
0
        public T GetEntity <T>(int[] ids) where T : ModelEntity
        {
            DSClient client = new DSClient(Models.Const.ApplicationId);
            int      userId;
            string   token;

            if (GetToken(out userId, out token))
            {
                var t = typeof(T);
                if (t == typeof(Application))
                {
                    Application app = client.GetApplication(userId, token, ids[0]);
                    return(app as T);
                }
                else if (t == typeof(Role))
                {
                    Role role = client.GetRole(userId, token, ids[0]);
                    return(role as T);
                }
                else if (t == typeof(Image))
                {
                    Image image = client.GetImage(userId, token, ids[0]);
                    return(image as T);
                }
                else if (t == typeof(Command))
                {
                    Command cmd = client.GetCommand(userId, token, ids[0]);
                    return(cmd as T);
                }
                else if (t == typeof(RoleCommand))
                {
                    RoleCommand rc = client.GetRoleCommand(userId, token, ids[0]);
                    return(rc as T);
                }
                else if (t == typeof(RoleCommandView))
                {
                    RoleCommandView rc = client.GetRoleCommandView(userId, token, ids[0]);
                    return(rc as T);
                }
                else if (t == typeof(User))
                {
                    User user = client.GetUser(userId, token, ids[0]);
                    return(user as T);
                }
                else if (t == typeof(UserApplicationInfo))
                {
                    UserApplicationInfo info = client.GetUserInfo(userId, token, ids[0], ids[1]);
                    return(info as T);
                }
                else if (t == typeof(RoomGroup))
                {
                    RoomGroup roomGroup = client.GetRoomGroup(userId, token, ids[0]);
                    return(roomGroup as T);
                }
                else if (t == typeof(Room))
                {
                    Room room = client.GetRoom(userId, token, ids[0]);
                    return(room as T);
                }
                else if (t == typeof(RoomRole))
                {
                    RoomRole rRole = client.GetRoomRole(userId, token, ids[0], ids[1], ids[2]);
                    return(rRole as T);
                }
                else if (t == typeof(GiftGroup))
                {
                    GiftGroup giftGroup = client.GetGiftGroup(userId, token, ids[0]);
                    return(giftGroup as T);
                }
                else if (t == typeof(Gift))
                {
                    Gift gift = client.GetGift(userId, token, ids[0]);
                    return(gift as T);
                }
                else if (t == typeof(BlockType))
                {
                    BlockType b = client.GetBlockType(userId, token, ids[0]);
                    return(b as T);
                }
                else if (t == typeof(BlockList))
                {
                    BlockList b = client.GetBlockList(userId, token, ids[0]);
                    return(b as T);
                }
                else if (t == typeof(RoomRole))
                {
                    RoomRole rr = client.GetRoomRole(userId, token, ids[0], ids[1], ids[2]);
                    return(rr as T);
                }
                else if (t == typeof(RoomConfig))
                {
                    RoomConfig c = client.GetRoomConfig(userId, token, ids[0]);
                    return(c as T);
                }
            }
            return(null);
        }
        public async Task <CommandResult <RoleModel[]> > Handle(RoleCommand request, CancellationToken cancellationToken)
        {
            var lst = await organizationRepo.GetRoles(request.SearchName).ConfigureAwait(false);

            return(await Task.FromResult <CommandResult <RoleModel[]> >(new CommandResult <RoleModel[]>() { Message = "Created successfully", Status = true, ResponseObj = lst }).ConfigureAwait(false));
        }
Exemplo n.º 14
0
        /// <summary>
        /// Adds roles prefixed with '+' to the user and removes roles prefixed with '-' from the user.
        /// </summary>
        private async Task <RoleOperationResult> PerformRoleOperations(IGuildUser user)
        {
            if (string.IsNullOrEmpty(RoleOperations))
            {
                return(RoleOperationResult.Success);
            }

            List <string> conflictingOwnedRoles   = new List <string>();
            List <string> conflictingUnownedRoles = new List <string>();

            foreach (string roleOperation in RoleOperations.Split(','))
            {
                string trimmed = roleOperation.Trim();

                char   operation = trimmed[0];
                string roleName  = trimmed.Substring(1);

                // For example: The RoleOperation "+MyRole" will have '+' as the operation and "MyRole" as the roleName.

                IRole role = RoleCommand.GetRoleByName(user.Guild, roleName);

                if (role == null)
                {
                    throw new InvalidOperationException($"The role {roleName} does not exist.");
                }

                switch (operation)
                {
                case '+':
                    if (!user.HasRole(roleName))
                    {
                        await user.AddRoleAsync(role);
                    }
                    else
                    {
                        conflictingOwnedRoles.Add(roleName);
                    }
                    break;

                case '-':
                    if (user.HasRole(roleName))
                    {
                        await user.RemoveRoleAsync(role);
                    }
                    else
                    {
                        conflictingUnownedRoles.Add(roleName);
                    }
                    break;

                default:
                    throw new InvalidOperationException("A role must be prefixed by either '+' or '-' in order to be processed.");
                }
            }

            return(new RoleOperationResult
            {
                ConflictingOwnedRoles = conflictingOwnedRoles.ToArray(),
                ConflictingUnownedRoles = conflictingUnownedRoles.ToArray(),
                IsError = (conflictingOwnedRoles.Count + conflictingUnownedRoles.Count) > 0
            });
        }
Exemplo n.º 15
0
 public abstract PlayerStateEnum Command(RoleCommand cmd, params object[] args);
Exemplo n.º 16
0
 public abstract void Command(RoleCommand cmd, params object[] args);
Exemplo n.º 17
0
            public Bot()
            {
                BotUser = new DiscordClient(x =>
                {
                    x.LogLevel = LogSeverity.Info;
                });
                BotUser.Log.Message += (s, e) => Console.WriteLine($"[{e.Severity}] {e.Source}: {e.Message}");

                BotUser.UsingCommands(x =>
                {
                    x.PrefixChar         = '-';
                    x.AllowMentionPrefix = true;
                });
                commands = BotUser.GetService <CommandService>();
                RoleManagementCommands    rmc = new RoleManagementCommands(BotUser, commands);
                AccountManagementCommands amc = new AccountManagementCommands(BotUser, commands);
                RoleManagementTrigger     roleManagementTrigger = new RoleManagementTrigger(BotUser, commands);
                RegionCommands            regionCommands        = new RegionCommands(BotUser, commands);
                RoleCommand          roleCommand        = new RoleCommand(BotUser, commands);
                ManagementTools      managementTools    = new ManagementTools(BotUser, commands);
                ServerInfoCommands   serverInfoCommands = new ServerInfoCommands(BotUser, commands);
                MasteryCommands      masteryCommands    = new MasteryCommands(BotUser, commands);
                ServerManagement     serverManagement   = new ServerManagement(BotUser, commands);
                RankCommands         rankCommands       = new RankCommands(BotUser, commands);
                SummonerInfo         summonerInfo       = new SummonerInfo(commands);
                BotManagement        botManagement      = new BotManagement(commands, BotUser);
                Interaction          inter               = new Interaction(BotUser, commands);
                CreateRoles          createRoles         = new CreateRoles(commands);
                Matchmaking_Settings matchmakingSettings = new Matchmaking_Settings(commands);
                CoachCommands        coachCommands       = new CoachCommands(commands);
                Stopwatch            stopwatch           = new Stopwatch();

                stopwatch.Start();
                MatchmakingTrigger  trigger             = new MatchmakingTrigger(BotUser, commands);
                MatchmakingCommands matchmakingCommands = new MatchmakingCommands(commands, BotUser, trigger);

                new HelpCommand(BotUser, commands);
                Task.Run(() => trigger.TimedClear(stopwatch));
                matchmakingCommands.CreateCommands();
                matchmakingSettings.ChannelSettings();
                coachCommands.CreateCommands();
                createRoles.CreateRank();
                summonerInfo.SelfInfo();
                summonerInfo.OtherInfo();
                serverManagement.ServerAdded();
                serverManagement.VerifyServer();
                serverInfoCommands.InviteLink();
                amc.ClaimAccount();
                amc.Claim();
                rankCommands.GetRank();
                new Universal_Role(BotUser, commands).UniversalRole();
                regionCommands.GetRegion();
                roleCommand.GetRole();
                rmc.Update();
                rmc.GetRoles();
                managementTools.ChangeType();
                managementTools.ChangeCommandAllowed();
                managementTools.OverrideSystem();
                serverInfoCommands.ServerInfo();
                serverInfoCommands.Description();
                serverManagement.CheckForNewServer();
                managementTools.Admin();
                roleCommand.GetRoleParameter();
                Legal();
                roleManagementTrigger.JoiningRoleGive();
                masteryCommands.GetMasteryPoints();
                managementTools.AdminMastery();

                Test();
                BotUser.ExecuteAndWait(async() =>
                {
                    await BotUser.Connect(global::Keys.Keys.discordKey, TokenType.Bot);
                });
            }