コード例 #1
0
        public override async Task HandleAsync(IBotServer game, ITwitchCommandClient twitch, ICommand cmd)
        {
            var channel = cmd.Channel;
            var session = game.GetSession(channel);

            if (session != null)
            {
                var connection = game.GetConnection(session);
                if (connection != null)
                {
                    var destination = cmd.Arguments?.ToLower();
                    if (string.IsNullOrEmpty(destination))
                    {
                        twitch.Broadcast(channel, cmd.Sender.Username, Localization.TRAVEL_NO_ARG);
                        return;
                    }

                    var player = session.Get(cmd.Sender);
                    if (player != null)
                    {
                        await connection.TravelAsync(player, destination);
                    }
                }
            }
        }
コード例 #2
0
ファイル: SetExpLimit.cs プロジェクト: zerratar/RavenBot
        public override async Task HandleAsync(IBotServer game, ITwitchCommandClient twitch, ICommand cmd)
        {
            var channel = cmd.Channel;
            var session = game.GetSession(channel);

            if (session != null)
            {
                var connection = game.GetConnection(session);
                if (connection != null)
                {
                    var player = session.Get(cmd.Sender);

                    var numOfSubs = 1;
                    if (!string.IsNullOrEmpty(cmd.Arguments))
                    {
                        int.TryParse(cmd.Arguments, out numOfSubs);
                    }
                    if (numOfSubs < 15)
                    {
                        return;
                    }

                    await connection.SetExpMultiplierLimitAsync(player, numOfSubs);
                }
            }
        }
コード例 #3
0
        public override async Task HandleAsync(IBotServer game, ITwitchCommandClient twitch, ICommand cmd)
        {
            var channel = cmd.Channel;
            var session = game.GetSession(channel);

            if (session != null)
            {
                var connection = game.GetConnection(session);
                if (connection != null)
                {
                    if (!cmd.Sender.IsBroadcaster && !cmd.Sender.IsModerator && !cmd.Sender.IsSubscriber)
                    {
                        twitch.Broadcast(channel, cmd.Sender.Username, Localization.OBSERVE_PERM);
                        return;
                    }

                    var targetPlayerName = cmd.Arguments?.Trim();
                    var player           = string.IsNullOrEmpty(targetPlayerName)
                        ? session.Get(cmd.Sender)
                        : session.GetUserByName(targetPlayerName);

                    await connection.ObservePlayerAsync(player);
                }
            }
        }
コード例 #4
0
        public override async Task HandleAsync(IBotServer game, ITwitchCommandClient twitch, ICommand cmd)
        {
            var channel = cmd.Channel;
            var session = game.GetSession(channel);

            if (session != null)
            {
                var connection = game.GetConnection(session);
                if (connection != null)
                {
                    if (!cmd.Sender.IsBroadcaster && !cmd.Sender.IsModerator)
                    {
                        twitch.Broadcast(channel, cmd.Sender.Username, Localization.KICK_PERM);
                        return;
                    }

                    var targetPlayerName = cmd.Arguments?.Trim();
                    if (string.IsNullOrEmpty(targetPlayerName))
                    {
                        twitch.Broadcast(channel, cmd.Sender.Username, Localization.KICK_NO_USER);
                        return;
                    }

                    await connection.KickAsync(session.GetUserByName(targetPlayerName));
                }
            }
        }
コード例 #5
0
ファイル: Unstuck.cs プロジェクト: zerratar/RavenBot
        public override async Task HandleAsync(IBotServer game, ITwitchCommandClient twitch, ICommand cmd)
        {
            var channel = cmd.Channel;
            var session = game.GetSession(channel);

            if (session != null)
            {
                var connection = game.GetConnection(session);
                if (connection != null)
                {
                    if (!string.IsNullOrEmpty(cmd.Arguments) && (cmd.Sender.IsBroadcaster || cmd.Sender.IsModerator))
                    {
                        var player = session.GetUserByName(cmd.Arguments);
                        if (player != null)
                        {
                            await connection.UnstuckAsync(player);
                        }
                    }
                    else
                    {
                        var player = session.Get(cmd.Sender);
                        await connection.UnstuckAsync(player);
                    }
                }
            }
        }
コード例 #6
0
        public override async Task HandleAsync(IBotServer game, ITwitchCommandClient twitch, ICommand cmd)
        {
            var channel = cmd.Channel;
            var session = game.GetSession(channel);

            if (session != null)
            {
                var connection = game.GetConnection(session);
                if (connection != null)
                {
                    var player = session.Get(cmd.Sender);
                    if (player == null)
                    {
                        return;
                    }

                    var item = cmd.Arguments?.ToLower();
                    if (string.IsNullOrEmpty(item))
                    {
                        twitch.Broadcast(channel, cmd.Sender.Username, "You have to use !equip <item name> or !equip all for equipping your best items.");
                        return;
                    }

                    await connection.EquipAsync(player, item);
                }
            }
        }
コード例 #7
0
ファイル: Sail.cs プロジェクト: zerratar/RavenBot
        public override async Task HandleAsync(IBotServer game, ITwitchCommandClient twitch, ICommand cmd)
        {
            var channel = cmd.Channel;
            var session = game.GetSession(channel);

            if (session != null)
            {
                var connection = game.GetConnection(session);
                if (connection != null)
                {
                    var player = session.Get(cmd.Sender);

                    var destination = cmd.Arguments?.ToLower();
                    if (string.IsNullOrEmpty(destination))
                    {
                        await connection.EmbarkFerryAsync(player);

                        return;
                    }

                    if (destination.StartsWith("stop"))
                    {
                        await connection.DisembarkFerryAsync(player);

                        return;
                    }

                    await connection.TravelAsync(player, destination);
                }
            }
        }
コード例 #8
0
ファイル: Pet.cs プロジェクト: zerratar/RavenBot
        public override async Task HandleAsync(IBotServer game, ITwitchCommandClient twitch, ICommand cmd)
        {
            var channel = cmd.Channel;
            var session = game.GetSession(channel);

            if (session != null)
            {
                var connection = game.GetConnection(session);
                if (connection != null)
                {
                    var player = session.Get(cmd.Sender);
                    if (player == null)
                    {
                        return;
                    }

                    var pet = cmd.Arguments?.ToLower();
                    if (string.IsNullOrEmpty(pet))
                    {
                        await connection.GetPetAsync(player);

                        return;
                    }

                    await connection.SetPetAsync(player, pet);
                }
            }
        }
コード例 #9
0
        public override async Task HandleAsync(IBotServer game, ITwitchCommandClient twitch, ICommand cmd)
        {
            var channel = cmd.Channel;
            var session = game.GetSession(channel);

            if (session != null)
            {
                var connection = game.GetConnection(session);
                if (connection != null)
                {
                    var player = session.Get(cmd.Sender);
                    if (string.IsNullOrEmpty(cmd.Arguments))
                    {
                        await connection.ActivateTicTacToeAsync(player);

                        return;
                    }

                    if (cmd.Arguments.Trim().Equals("reset", System.StringComparison.OrdinalIgnoreCase))
                    {
                        await connection.ResetTicTacToeAsync(player);

                        return;
                    }

                    if (int.TryParse(cmd.Arguments.Trim(), out var num))
                    {
                        await connection.PlayTicTacToeAsync(player, num);
                    }
                }
            }
        }
コード例 #10
0
        public Task HandleAsync(IBotServer game, ITwitchCommandClient twitch, ChatMessage msg)
        {
            var channel = msg.Channel;
            var session = game.GetSession(channel);

            if (session != null)
            {
                session.SendChatMessage(msg.Username, msg.Message);

                if (msg.Bits > 0)
                {
                    this.messageBus.Send(
                        nameof(ROBot.Core.Twitch.TwitchCheer),
                        new ROBot.Core.Twitch.TwitchCheer(
                            msg.Channel,
                            msg.Id,
                            msg.Username,
                            msg.DisplayName,
                            msg.IsModerator,
                            msg.IsSubscriber,
                            msg.IsVip,
                            msg.Bits)
                        );
                }
            }
            return(Task.CompletedTask);
        }
コード例 #11
0
ファイル: Toggle.cs プロジェクト: zerratar/RavenBot
        public override async Task HandleAsync(IBotServer game, ITwitchCommandClient twitch, ICommand cmd)
        {
            var channel = cmd.Channel;
            var session = game.GetSession(channel);

            if (session != null)
            {
                var connection = game.GetConnection(session);
                if (connection != null)
                {
                    if (string.IsNullOrEmpty(cmd.Arguments))
                    {
                        twitch.Broadcast(channel, cmd.Sender.Username, Localization.VALUE_NO_ARG, cmd.Command);
                        return;
                    }

                    var player = session.Get(cmd.Sender);
                    if (cmd.Arguments.Contains("helm", StringComparison.OrdinalIgnoreCase))
                    {
                        await connection.ToggleHelmetAsync(player);
                    }
                    else if (cmd.Arguments.Contains("pet", StringComparison.OrdinalIgnoreCase))
                    {
                        await connection.TogglePetAsync(player);
                    }
                    else
                    {
                        twitch.Broadcast(channel, cmd.Sender.Username, Localization.TOGGLE_INVALID, cmd.Arguments);
                    }
                }
            }
        }
コード例 #12
0
        public override async Task HandleAsync(IBotServer game, ITwitchCommandClient twitch, ICommand cmd)
        {
            var channel = cmd.Channel;
            var session = game.GetSession(channel);

            if (session != null)
            {
                var connection = game.GetConnection(session);
                if (connection != null)
                {
                    var    targetPlayerName = cmd.Arguments?.Trim();
                    Player player           = null;
                    if ((cmd.Sender.IsBroadcaster || cmd.Sender.IsModerator) && !string.IsNullOrEmpty(targetPlayerName))
                    {
                        player = session.GetUserByName(targetPlayerName);
                    }
                    else
                    {
                        player = session.Get(cmd.Sender);
                    }

                    await connection.TurnIntoMonsterAsync(player);
                }
            }
        }
コード例 #13
0
ファイル: Dungeon.cs プロジェクト: zerratar/RavenBot
        public override async Task HandleAsync(IBotServer game, ITwitchCommandClient twitch, ICommand cmd)
        {
            var channel = cmd.Channel;
            var session = game.GetSession(channel);

            if (session != null)
            {
                var connection = game.GetConnection(session);
                if (connection != null)
                {
                    var player = session.Get(cmd.Sender);

                    if (string.IsNullOrEmpty(cmd.Arguments))
                    {
                        await connection.JoinDungeonAsync(player);

                        return;
                    }
                    else if (cmd.Arguments.Contains("stop", System.StringComparison.OrdinalIgnoreCase))
                    {
                        if (player.IsBroadcaster || player.IsModerator)
                        {
                            await connection.StopDungeonAsync(player);
                        }
                    }
                    else
                    {
                        await connection.DungeonStartAsync(player);
                    }
                }
            }
        }
コード例 #14
0
ファイル: Train.cs プロジェクト: zerratar/RavenBot
        public override async Task HandleAsync(IBotServer game, ITwitchCommandClient twitch, ICommand cmd)
        {
            var channel = cmd.Channel;
            var session = game.GetSession(channel);

            if (session != null)
            {
                var connection = game.GetConnection(session);
                if (connection != null)
                {
                    var player = session.Get(cmd.Sender);

                    if (GetCombatTypeFromString(cmd.Command) != -1)
                    {
                        await connection.SendPlayerTaskAsync(player, PlayerTask.Fighting, cmd.Command);

                        return;
                    }

                    var commandSkillTarget = GetSkillTypeFromString(cmd.Command);
                    if (commandSkillTarget != -1)
                    {
                        await connection.SendPlayerTaskAsync(player, (PlayerTask)commandSkillTarget, cmd.Command);

                        return;
                    }

                    var arg   = cmd.Arguments?.ToLower();
                    var skill = arg?.Split(' ').LastOrDefault();
                    if (string.IsNullOrEmpty(skill))
                    {
                        twitch.Broadcast(channel, cmd.Sender.Username, Localization.TRAIN_NO_ARG, string.Join(", ", trainableSkills));
                        return;
                    }

                    if (GetCombatTypeFromString(skill) != -1)
                    {
                        await connection.SendPlayerTaskAsync(player, PlayerTask.Fighting, skill);
                    }
                    else
                    {
                        var value = GetSkillTypeFromString(skill);
                        if (value == -1)
                        {
                            twitch.Broadcast(channel, cmd.Sender.Username, Localization.TRAIN_INVALID, skill);
                        }
                        else
                        {
                            await connection.SendPlayerTaskAsync(player, (PlayerTask)value, skill);
                        }
                    }
                }
            }
        }
コード例 #15
0
        public override async Task HandleAsync(IBotServer game, ITwitchCommandClient twitch, ICommand cmd)
        {
            var channel = cmd.Channel;
            var session = game.GetSession(channel);

            if (session != null)
            {
                var connection = game.GetConnection(session);
                if (connection != null)
                {
                    var player = session.Get(cmd.Sender);
                    await connection.RequestPlayerResourcesAsync(player);
                }
            }
        }
コード例 #16
0
ファイル: Join.cs プロジェクト: zerratar/RavenBot
        public override async Task HandleAsync(IBotServer game, ITwitchCommandClient twitch, ICommand cmd)
        {
            var channel = cmd.Channel;
            var session = game.GetSession(channel);

            if (session != null)
            {
                var connection = game.GetConnection(session);
                if (connection != null)
                {
                    var player = session.Join(cmd.Sender, cmd.Arguments);
                    await connection.JoinAsync(player);
                }
            }
        }
コード例 #17
0
        public async Task HandleAsync(IBotServer game, ITwitchCommandClient twitch, ChatCommand command)
        {
            var key       = command.CommandText.ToLower();
            var session   = game.GetSession(command.ChatMessage.Channel);
            var argString = !string.IsNullOrEmpty(command.ArgumentsAsString) ? " (args: " + command.ArgumentsAsString + ") " : "";

            if (session != null)
            {
                logger.LogDebug("[" + session.Name + "] Command: " + key + argString + " from " + command.ChatMessage.Username);
            }
            else
            {
                logger.LogDebug("Twitch Command Received: " + key + argString + " from " + command.ChatMessage.Username + " in #" + command.ChatMessage.Channel);
            }

            await HandleAsync(game, twitch, new TwitchCommand(command));
        }
コード例 #18
0
ファイル: Night.cs プロジェクト: zerratar/RavenBot
        public override async Task HandleAsync(IBotServer game, ITwitchCommandClient twitch, ICommand cmd)
        {
            var channel = cmd.Channel;
            var session = game.GetSession(channel);

            if (session != null)
            {
                var connection = game.GetConnection(session);
                if (connection != null)
                {
                    var player = session.Get(cmd.Sender);
                    if (player != null)
                    {
                        await connection.SetTimeOfDayAsync(player, 230, 30);
                    }
                }
            }
        }
コード例 #19
0
        public override async Task HandleAsync(IBotServer game, ITwitchCommandClient twitch, ICommand cmd)
        {
            var channel = cmd.Channel;
            var session = game.GetSession(channel);

            if (session != null)
            {
                var connection = game.GetConnection(session);
                if (connection != null)
                {
                    var player = session.Get(cmd.Sender);
                    if (!string.IsNullOrEmpty(cmd.Arguments))
                    {
                        player = session.GetUserByName(cmd.Arguments);
                    }

                    await connection.InspectPlayerAsync(player);
                }
            }
        }
コード例 #20
0
        public override async Task HandleAsync(IBotServer game, ITwitchCommandClient twitch, ICommand cmd)
        {
            var channel = cmd.Channel;
            var session = game.GetSession(channel);

            if (session != null)
            {
                var connection = game.GetConnection(session);
                if (connection != null)
                {
                    var player = session.Get(cmd.Sender);
                    if (string.IsNullOrEmpty(cmd.Arguments))
                    {
                        twitch.Broadcast(channel, cmd.Sender.Username, Localization.REDEEM_NO_ARG);
                        return;
                    }

                    await connection.RedeemStreamerTokenAsync(player, cmd.Arguments);
                }
            }
        }
コード例 #21
0
        public override async Task HandleAsync(IBotServer game, ITwitchCommandClient twitch, ICommand cmd)
        {
            var channel = cmd.Channel;
            var session = game.GetSession(channel);

            if (session != null)
            {
                var connection = game.GetConnection(session);
                if (connection != null)
                {
                    var player = session.Get(cmd.Sender);

                    if (string.IsNullOrEmpty(cmd.Arguments) || !cmd.Arguments.Trim().Contains(" "))
                    {
                        twitch.Broadcast(channel, cmd.Sender.Username, Localization.TRADE_NO_ARG, cmd.Command);
                        return;
                    }

                    await connection.BuyItemAsync(player, cmd.Arguments);
                }
            }
        }
コード例 #22
0
ファイル: Leave.cs プロジェクト: zerratar/RavenBot
        public override async Task HandleAsync(IBotServer game, ITwitchCommandClient twitch, ICommand cmd)
        {
            var session = game.GetSession(cmd.Channel);

            if (session == null)
            {
                return;
            }

            // client might not accept a leave.
            //session.Leave(cmd.Sender.UserId);

            var connection = game.GetConnection(session);

            if (connection != null)
            {
                var player = session.Get(cmd.Sender);
                if (player != null)
                {
                    await connection.LeaveAsync(player);
                }
            }
        }
コード例 #23
0
        public override async Task HandleAsync(IBotServer game, ITwitchCommandClient twitch, ICommand cmd)
        {
            var channel = cmd.Channel;
            var session = game.GetSession(channel);

            if (session != null)
            {
                var connection = game.GetConnection(session);
                if (connection != null)
                {
                    var player = session.Get(cmd.Sender);
                    if (string.IsNullOrWhiteSpace(cmd.Arguments))
                    {
                        //twitch.Broadcast(cmd.Sender.Username, "To duel a player you need to specify their name. ex: '!duel JohnDoe', to accept or decline a duel request use '!duel accept' or '!duel decline'. You may also cancel an ongoing request by using '!duel cancel'");
                        return;
                    }

                    var sub = cmd.Arguments?.Trim();
                    if (sub.Equals("cancel", StringComparison.InvariantCultureIgnoreCase))
                    {
                        await connection.CancelDuelRequestAsync(player);
                    }
                    else if (sub.Equals("accept", StringComparison.InvariantCultureIgnoreCase))
                    {
                        await connection.AcceptDuelRequestAsync(player);
                    }
                    else if (sub.Equals("decline", StringComparison.InvariantCultureIgnoreCase))
                    {
                        await connection.DeclineDuelRequestAsync(player);
                    }
                    else
                    {
                        await connection.DuelRequestAsync(player, session.GetUserByName(sub));
                    }
                }
            }
        }
コード例 #24
0
        public override async Task HandleAsync(IBotServer game, ITwitchCommandClient twitch, ICommand cmd)
        {
            var channel = cmd.Channel;
            var session = game.GetSession(channel);

            if (session != null)
            {
                var connection = game.GetConnection(session);
                if (connection != null)
                {
                    if (string.IsNullOrEmpty(cmd.Arguments))
                    {
                        twitch.Broadcast(channel, cmd.Sender.Username, Localization.VALUE_NO_ARG, cmd.Command);
                        return;
                    }

                    var player = session.Get(cmd.Sender);
                    if (player != null)
                    {
                        await connection.CraftRequirementAsync(player, cmd.Arguments);
                    }
                }
            }
        }
コード例 #25
0
        public async Task HandleAsync(IBotServer game, ITwitchCommandClient twitch, OnChannelPointsRewardRedeemedArgs reward)
        {
            //logger.LogInformation("Channel Point Rewards not implemented.");
            var cmd         = "";
            var usedCommand = "";

            try
            {
                var redeemer  = reward.RewardRedeemed.Redemption.User;
                var arguments = string.Empty;//reward.RewardRedeemed.Redemption.Reward.Prompt;
                var command   = reward.RewardRedeemed.Redemption.Reward.Title;
                var cmdParts  = command.ToLower().Split(' ');



                var session = game.GetSession(reward.ChannelId);

                // In case we use brackets to identify a command
                cmd         = cmdParts.FirstOrDefault(x => x.Contains("["));
                usedCommand = cmd;

                if (!string.IsNullOrEmpty(cmd))
                {
                    cmd = cmd.Replace("[", "").Replace("]", "").Trim();
                }

                ITwitchCommandHandler processor = null;

                // if we did not use any brackets
                if (string.IsNullOrEmpty(cmd))
                {
                    foreach (var part in cmdParts)
                    {
                        var proc = FindHandler(part.ToLower());
                        if (proc != null)
                        {
                            processor   = proc;
                            usedCommand = part;
                            break;
                        }
                    }
                }

                // in case we never found a handler, fallback to identifier
                if (processor == null)
                {
                    processor = FindHandler(cmd.ToLower());
                    if (processor == null)
                    {
                        logger.LogError("Error redeeming reward: " + cmd + ", no handler found");
                        return;
                    }

                    usedCommand = cmd;
                }

                if (string.IsNullOrEmpty(arguments))
                {
                    arguments = redeemer.Login;
                }

                //if (processor.RequiresBroadcaster)
                //{
                //    return new RewardRedeemCommand(broadcaster, usedCommand, redeemer.Username);
                //}
                //else
                //{
                //    return new RewardRedeemCommand(redeemer, usedCommand, arguments);
                //}

                RavenBot.Core.Ravenfall.Models.Player player = null;
                if (processor.RequiresBroadcaster)
                {
                    player = session.GetBroadcaster();
                }
                else
                {
                    player = session.Get(new RewardRedeemUser(redeemer));
                    if (player == null)
                    {
                        logger.LogError("Error redeeming reward: " + usedCommand + ", redeemer does not exist. (" + redeemer.Id + ")");
                        return;
                    }
                }

                await processor.HandleAsync(game, twitch, new RewardRedeemCommand(player, reward.ChannelId, usedCommand, arguments));
            }
            catch (Exception exc)
            {
                logger.LogError("Error redeeming reward:  " + usedCommand + ", " + exc.ToString());
            }
        }