コード例 #1
0
        public async Task Eval(CommandContext ctx, [Description("comandos de hacker")][RemainingText] string comando)
        {
            if (string.IsNullOrEmpty(comando) || await BotPermissions.CheckAdm(ctx.User) != TiposAdms.Dono)
            {
                throw new Exception();
            }
            string comandoformatado = comando.Replace("```", "");
            await ctx.TriggerTypingAsync();

            DiscordEmbedBuilder eb = new DiscordEmbedBuilder
            {
                Title = "Result:",
            };


            try
            {
                ScriptOptions escopo = ScriptOptions.Default;
                escopo = escopo.WithImports("System", "System.Collections.Generic", "System.Linq", "System.Text", "System.Threading.Tasks", "DSharpPlus", "DSharpPlus.CommandsNext");
                escopo = escopo.WithReferences(AppDomain.CurrentDomain.GetAssemblies().Where(xa => !xa.IsDynamic && !string.IsNullOrWhiteSpace(xa.Location)));

                Script <object> code = CSharpScript.Create(comandoformatado, escopo, typeof(CommandContext));
                code.Compile();
                ScriptState <object> resultado = await code.RunAsync(ctx);

                if (resultado != null && !string.IsNullOrWhiteSpace(resultado.ReturnValue.ToString()))
                {
                    await ctx.RespondAsync(embed : eb.WithDescription($"```{resultado.ReturnValue}```").WithColor(DiscordColor.Cyan).Build());
                }
            }
            catch (Exception e)
            {
                await ctx.RespondAsync(embed : eb.WithDescription($"```{e.Message}```").WithColor(DiscordColor.Red).Build());
            }
        }
コード例 #2
0
 public async Task Sudo(CommandContext ctx, [Description("Amiguxo")] DiscordUser user, [Description("Comandos de hacker")][RemainingText] string cmd)
 {
     if (ctx.Channel.IsPrivate || string.IsNullOrEmpty(cmd) || (byte)await BotPermissions.CheckAdm(ctx.User) != (byte)TiposAdms.Dono)
     {
         throw new Exception();
     }
     await ctx.CommandsNext.SudoAsync(user, ctx.Channel, cmd);
 }
コード例 #3
0
 public static bool HasPermission(BotPermissions them, BotPermissions testFor)
 {
     if (((them & BotPermissions.Ignore) != 0) && (testFor & BotPermissions.Ignore) == 0)
     {
         return(false);
     }
     return((them & testFor) != 0);
 }
コード例 #4
0
        public async Task SetEspecial(CommandContext ctx, [Description("O fdp")] DiscordGuild guild, [Description("\nInal = 0\nNor = 1\nLoli = 2\nPikachu = 3")] int tipo = 0)
        {
            if (ctx.Channel.IsPrivate || await BotPermissions.CheckAdm(ctx.User) != TiposAdms.Dono)
            {
                throw new Exception();
            }

            await new ServidoresDAO().Atualizar(new Servidores
            {
                ID       = guild.Id,
                Especial = (TiposServidores)tipo
            });

            await ctx.RespondAsync("mais um para o porão ?");
        }
コード例 #5
0
        private void Inventory_OnInventoryObjectReceived(object sender, InventoryObjectOfferedEventArgs e)
        {
            if (AcceptAllInventoryItems)
            {
                e.Accept = true;
                return; // accept everything}
            }
            BotPermissions them = GetSecurityLevel(e.Offer);

            if (HasPermission(them, BotPermissions.AcceptInventory))
            {
                e.Accept = true;
                return;
            }
            e.Accept = false;
        }
コード例 #6
0
        public override CmdResult ExecuteRequest(CmdRequest args)
        {
            if (args.Length < 1)
            {
                int nfound = 0;
                foreach (var sl in TheBotClient.SecurityLevels)
                {
                    nfound++;
                    AddSuccess(string.Format("{0}={1}", sl.Key, sl.Value));
                }
                foreach (var sl in TheBotClient.SecurityLevelsByName)
                {
                    nfound++;
                    AddSuccess(string.Format("{0}={1}", sl.Key, sl.Value));
                }
                return(Success(nfound + " entries found"));
            }
            int argsUsed;
            List <SimObject> worldSystemGetPrimitives = WorldSystem.GetSingleArg(args, out argsUsed);

            if (IsEmpty(worldSystemGetPrimitives))
            {
                return(Failure("Cannot find objects from " + args.str));
            }
            BotPermissions who = BotPermissions.Stranger;

            object value;

            if (TryEnumParse(typeof(BotPermissions), args, argsUsed, out argsUsed, out value))
            {
                who = (BotPermissions)value;
            }

            foreach (var p in worldSystemGetPrimitives)
            {
                BotPermissions perms = TheBotClient.GetSecurityLevel(p.ID, null);
                if (argsUsed == 0)
                {
                    AddSuccess("Perms for " + p + " was " + perms);
                    continue;
                }
                AddSuccess("Perms for " + p + " was " + perms + " now setting to " + who);
                TheBotClient.SetSecurityLevel(p.ID, null, who);
            }
            return(SuccessOrFailure());
        }
コード例 #7
0
        public async Task SetAdm(CommandContext ctx, [Description("Mais um corno")] DiscordUser user, [Description("\nNada = 0\nMod = 1\nAdm = 2\nDono = 3")] int tipo = 0)
        {
            if (ctx.Channel.IsPrivate || await BotPermissions.CheckAdm(ctx.User) != TiposAdms.Dono)
            {
                throw new Exception();
            }

            await new AdmsBotDAO().Atualizar(new AdmsBot
            {
                Usuario = new Usuarios
                {
                    ID = user.Id
                },
                Permissao = (TiposAdms)tipo
            });

            await ctx.RespondAsync("kkk mais um corno");
        }
コード例 #8
0
        public void SetSecurityLevel(UUID uuid, string name, BotPermissions perms)
        {
            BotPermissions bp;

            if (uuid != UUID.Zero)
            {
                lock (SecurityLevels) SecurityLevels[uuid] = perms;
            }
            if (!string.IsNullOrEmpty(name))
            {
                // dont take whitepaces
                name = name.Trim();
                if (name != "")
                {
                    lock (SecurityLevelsByName) SecurityLevelsByName[name] = perms;
                }
            }
        }
コード例 #9
0
        public BotPermissions GetSecurityLevel(UUID uuid, string name)
        {
            BotPermissions bp = BotPermissions.None;

            if (uuid != UUID.Zero)
            {
                lock (SecurityLevels)
                    if (SecurityLevels.TryGetValue(uuid, out bp))
                    {
                        return(bp);
                    }
            }
            if (!string.IsNullOrEmpty(name))
            {
                lock (SecurityLevelsByName)
                    if (SecurityLevelsByName.TryGetValue(name, out bp))
                    {
                        return(bp);
                    }
            }
            else if (Friends.FriendList != null)
            {
                FriendInfo fi;
                if (Friends.FriendList.TryGetValue(uuid, out fi))
                {
                    BotPermissions start = RecognizedFriendSecurityLevel;
                    if (fi.CanModifyMyObjects)
                    {
                        start |= BotPermissions.Trusted;
                    }
                    if (!fi.CanSeeMeOnMap)
                    {
                        start |= BotPermissions.Friend;
                    }
                    return(start);
                }
            }
            else if (GroupMembers != null && GroupMembers.ContainsKey(uuid))
            {
                return(RecognizedGroupSecurityLevel);
            }
            return(StrangerSecurityLevel);
        }
コード例 #10
0
 public static bool HasPermission(BotPermissions them, BotPermissions testFor)
 {
     if (((them & BotPermissions.Ignore) != 0) && (testFor & BotPermissions.Ignore) == 0) return false;
     return (them & testFor) != 0;
 }
コード例 #11
0
 public void SetSecurityLevel(UUID uuid, string name, BotPermissions perms)
 {
     BotPermissions bp;
     if (uuid != UUID.Zero)
     {
         lock (SecurityLevels) SecurityLevels[uuid] = perms;
     }
     if (!string.IsNullOrEmpty(name))
     {
         // dont take whitepaces
         name = name.Trim();
         if (name != "") lock (SecurityLevelsByName) SecurityLevelsByName[name] = perms;
     }
 }
コード例 #12
0
        private void Self_OnMessage(string FromAgentName, UUID FromAgentID, UUID ToAgentID,
                                    string Message, UUID IMSessionID, bool GroupIM,
                                    UUID RegionID, Vector3 Position,
                                    InstantMessageDialog Dialog, ChatType Type, EventArgs origin)
        {
            if (Dialog == InstantMessageDialog.GroupNotice)
            {
                GroupIM = true;
            }

            BotPermissions perms = GetSecurityLevel(FromAgentID, FromAgentName);

            // Received an IM from someone that is authenticated
            if (Type == ChatType.OwnerSay)
            {
                perms |= BotPermissions.Owner;
            }

            bool displayedMessage = false;

            if (origin is ChatEventArgs && Message.Length > 0 && Dialog == InstantMessageDialog.MessageFromAgent)
            {
                WriteLine(String.Format("{0} says, \"{1}\".", FromAgentName, Message));
                PosterBoard["/posterboard/onchat"] = Message;
                if (FromAgentName == Self.Name)
                {
                    PosterBoard["/posterboard/onchat-said"] = Message;
                }
                else
                {
                    PosterBoard["/posterboard/onchat-heard"] = Message;
                }
            }

            bool groupIM = GroupIM && GroupMembers != null && GroupMembers.ContainsKey(FromAgentID) ? true : false;


            switch (Dialog)
            {
            case InstantMessageDialog.MessageBox:
                break;

            case InstantMessageDialog.GroupInvitation:
                if ((perms & BotPermissions.AcceptGroupAndFriendRequests) != 0)
                {
                    string groupName = Message;
                    int    found     = groupName.IndexOf("Group:");
                    if (found > 0)
                    {
                        groupName = groupName.Substring(found + 6);
                    }
                    Self.InstantMessage(Self.Name, FromAgentID, string.Empty, IMSessionID,
                                        InstantMessageDialog.GroupInvitationAccept, InstantMessageOnline.Offline,
                                        Self.SimPosition,
                                        UUID.Zero, new byte[0]);
                    found = groupName.IndexOf(":");
                    if (found > 0)
                    {
                        groupName = groupName.Substring(0, found).Trim();
                        ExecuteCommand("joingroup " + groupName, CMDFLAGS.NoResult);
                    }
                }
                break;

            case InstantMessageDialog.InventoryOffered:
                break;

            case InstantMessageDialog.InventoryAccepted:
                break;

            case InstantMessageDialog.InventoryDeclined:
                break;

            case InstantMessageDialog.GroupVote:
                break;

            case InstantMessageDialog.TaskInventoryOffered:
                break;

            case InstantMessageDialog.TaskInventoryAccepted:
                break;

            case InstantMessageDialog.TaskInventoryDeclined:
                break;

            case InstantMessageDialog.NewUserDefault:
                break;

            case InstantMessageDialog.SessionAdd:
                break;

            case InstantMessageDialog.SessionOfflineAdd:
                break;

            case InstantMessageDialog.SessionGroupStart:
                break;

            case InstantMessageDialog.SessionCardlessStart:
                break;

            case InstantMessageDialog.SessionSend:
                break;

            case InstantMessageDialog.SessionDrop:
                break;

            case InstantMessageDialog.BusyAutoResponse:
                break;

            case InstantMessageDialog.ConsoleAndChatHistory:
                break;

            case InstantMessageDialog.Lure911:
            case InstantMessageDialog.RequestTeleport:
                if ((perms & BotPermissions.AcceptTeleport) != 0)
                {
                    TheSimAvatar.StopMoving();
                    if (RegionID != UUID.Zero)
                    {
                        if (!displayedMessage)
                        {
                            DisplayNotificationInChat("TP to Lure from " + FromAgentName);
                            displayedMessage = true;
                        }
                        SimRegion R = SimRegion.GetRegion(RegionID, gridClient);
                        if (R != null)
                        {
                            Self.Teleport(R.RegionHandle, Position);
                            return;
                        }
                    }
                    DisplayNotificationInChat("Accepting TP Lure from " + FromAgentName);
                    displayedMessage = true;
                    Self.TeleportLureRespond(FromAgentID, IMSessionID, true);
                }
                break;

            case InstantMessageDialog.AcceptTeleport:
                break;

            case InstantMessageDialog.DenyTeleport:
                break;

            case InstantMessageDialog.GodLikeRequestTeleport:
                break;

            //  case InstantMessageDialog.CurrentlyUnused:
            //    break;
            case InstantMessageDialog.GotoUrl:
                break;

            case InstantMessageDialog.Session911Start:
                break;

            case InstantMessageDialog.FromTaskAsAlert:
                break;

            case InstantMessageDialog.GroupNotice:
                break;

            case InstantMessageDialog.GroupNoticeInventoryAccepted:
                break;

            case InstantMessageDialog.GroupNoticeInventoryDeclined:
                break;

            case InstantMessageDialog.GroupInvitationAccept:
                break;

            case InstantMessageDialog.GroupInvitationDecline:
                break;

            case InstantMessageDialog.GroupNoticeRequested:
                break;

            case InstantMessageDialog.FriendshipOffered:
                if ((perms & BotPermissions.AcceptGroupAndFriendRequests) != 0)
                {
                    DisplayNotificationInChat("Accepting Friendship from " + FromAgentName);
                    Friends.AcceptFriendship(FromAgentID, IMSessionID);
                    displayedMessage = true;
                }
                break;

            case InstantMessageDialog.FriendshipAccepted:
                break;

            case InstantMessageDialog.FriendshipDeclined:
                break;

            case InstantMessageDialog.StartTyping:
                break;

            case InstantMessageDialog.StopTyping:
                break;

            case InstantMessageDialog.MessageFromObject:
            case InstantMessageDialog.MessageFromAgent:
                // message from self
                if (FromAgentName == GetName())
                {
                    return;
                }
                // message from system
                if (FromAgentName == "System")
                {
                    return;
                }
                // message from others
                CommandInstance ci;
                if (Commands.TryGetValue("im", out ci))
                {
                    var whisper = ci.WithBotClient as Cogbot.Actions.Communication.ImCommand;
                    if (whisper != null)
                    {
                        whisper.currentAvatar  = FromAgentID;
                        whisper.currentSession = IMSessionID;
                    }
                }
                var cea = origin as ChatEventArgs;
                if ((perms & BotPermissions.ExecuteCommands) != 0)
                {
                    OutputDelegate WriteLine;
                    if (origin is InstantMessageEventArgs)
                    {
                        WriteLine = new OutputDelegate(
                            (string text, object[] ps) =>
                        {
                            string reply0 = DLRConsole.SafeFormat(text, ps);
                            InstantMessage(FromAgentID, reply0, IMSessionID);
                        });
                    }
                    else
                    {
                        WriteLine = new OutputDelegate(
                            (string text, object[] ps) =>
                        {
                            string reply0 = DLRConsole.SafeFormat(text, ps);
                            Talk(reply0, 0, Type);
                        });
                    }
                    string   cmd        = Message;
                    CMDFLAGS needResult = CMDFLAGS.Console;
                    if (cmd.StartsWith("cmcmd "))
                    {
                        cmd = cmd.Substring(6);
                        WriteLine("");
                        WriteLine(string.Format("invokecm='{0}'", cmd));
                        ClientManager.DoCommandAll(cmd, FromAgentID, WriteLine);
                    }
                    else if (cmd.StartsWith("cmd "))
                    {
                        cmd = cmd.Substring(4);
                        WriteLine(string.Format("invoke='{0}'", cmd));
                        var res = ExecuteCommand(cmd, FromAgentID, WriteLine, needResult);
                        WriteLine("iresult='" + res + "'");
                    }
                    else if (cmd.StartsWith("/") || cmd.StartsWith("@"))
                    {
                        cmd = cmd.Substring(1);
                        WriteLine("");
                        WriteLine(string.Format("invoke='{0}'", cmd));
                        var res = ExecuteCommand(cmd, FromAgentID, WriteLine, needResult);
                        WriteLine("iresult='" + res + "'");
                    }
                }
                if (cea != null && cea.AudibleLevel == ChatAudibleLevel.Barely)
                {
                    return;
                }
                break;

            default:
                break;
            }
            //if (Dialog != InstantMessageDialog.MessageFromAgent && Dialog != InstantMessageDialog.MessageFromObject)
            {
                string debug = String.Format("{0} {1} {2} {3} {4} {5}: {6}",
                                             groupIM ? "GroupIM" : "IM", Dialog, Type, perms, FromAgentID, FromAgentName,
                                             Helpers.StructToString(origin));
                if (!displayedMessage)
                {
                    DisplayNotificationInChat(debug);
                    displayedMessage = true;
                }
            }
        }
コード例 #13
0
        private BotPermissions GetSecurityLevel(InstantMessage im)
        {
            BotPermissions perms = GetSecurityLevel(im.FromAgentID, im.FromAgentName);

            return(perms);
        }