コード例 #1
0
ファイル: ReportModule.cs プロジェクト: Stratege/DiscordBot
        public ReportModule(VirtualServer _server) : base(_server, "report")
        {
            ReportUsers = PersistantList.Create(server, "ReportUsers.txt");
            BannedUsers = PersistantList.Create(server, "ReportBannedUsers.txt");

            // Report channel to send reports to
            var res = server.FileSetup(_channelFile);

            if (res.Count > 0)
            {
                ReportChannel = server.getServer().TextChannels.FirstOrDefault(x => x.Name == res[0]);
            }
        }
コード例 #2
0
        /// <summary>
        /// Default constructor
        /// Initializes the whitelisted roles from the file
        /// </summary>
        /// <param name="_server"></param>
        public RoleCommand(VirtualServer _server, LobbyGreet _lg) : base(_server, "role")
        {
            WhitelistedRoles    = PersistantList.Create(server, "WhitelistedRoles.txt");
            server.RoleUpdated += (s, tup) => roleUpdated(tup.Item1, tup.Item2);
            server.RoleDeleted += (s, r) => roleDeleted(r);
            // Get the strike channel to print admin alerts in
            var res = server.FileSetup(_timeoutFile);

            if (res.Count > 0)
            {
                TimeoutRole = server.getServer().Roles.FirstOrDefault(x => x.Name == res[0]);
            }
            lg = _lg;
            if (lg != null)
            {
                string statusString = String.Join("\n", server.FileSetup("lobbyselfserviceenableStatus.txt"));
                if (statusString == "off")
                {
                    lssOn = false;
                }
            }
        }
コード例 #3
0
        public VirtualServer(DiscordSocketClient _DC, SocketGuild _server)
        {
            try
            {
                serverpath = _server.Id + "/";
                if (!Directory.Exists(serverpath))
                {
                    Directory.CreateDirectory(serverpath);
                }
                DC          = _DC;
                server      = _server;
                Commandlist = new Dictionary <string, Command>();

                var virtualServerCommands = new List <Command>(4);
                virtualServerCommands.Add(new Command(this, "help", help, PrivilegeLevel.BotAdmin, new HelpMsgStrings("", ""))); //help is very very special
                virtualServerCommands.Add(new Command(this, "shutdown", shutdown, PrivilegeLevel.BotAdmin, new HelpMsgStrings("", "shutdown <on/off>")));
                virtualServerCommands.Add(new Command(this, "addbotadmin", addBotAdmin, PrivilegeLevel.BotAdmin, new HelpMsgStrings("", "addbotadmin <mention-target>")));
                virtualServerCommands.Add(new Command(this, "removebotadmin", removeBotAdmin, PrivilegeLevel.BotAdmin, new HelpMsgStrings("", "removebotadmin <mention-target>")));
                addCommands(virtualServerCommands);
                Admins = PersistantList.Create(this, adminfilePath);
                var adminChannel = new AdminMessageChannel(this);
                addCommands(adminChannel.getCommands());
                addCommands(new Admingreet(this, adminChannel).getCommands());
                addCommands(new Adminleave(this, adminChannel).getCommands());
                addCommands(new Autogreet(this).getCommands());
                var lobbyGreet = new LobbyGreet(this);
                addCommands(lobbyGreet.getCommands());
                addCommands(new Dice(this).getCommands());
                addCommands(new Roulette(this).getCommands());
                addCommands(new Echo(this).getCommands());
                addCommands(new Math(this).getCommands());
                addCommands(new Bork(this).getCommands());
                addCommands(new KillUserMessages(this).getCommands());
                addCommands(new PurgeTheEnclave(this).getCommands());
                addCommands(new UntaggedUsers(this).getCommands());
                addCommands(new Reminder(this).getCommands());
                addCommands(new RunQuery(this).getCommands());
                altCommand = new AlternativeCommand(this);
                addCommands(altCommand.getCommands());
                addCommands(new GloriousDirectDemocracy(this).getCommands());
                addCommands(new RoleCommand(this, lobbyGreet).getCommands());
                addCommands(new StrikeModule(this).getCommands());
                addCommands(new EmoteModule(this).getCommands());
                addCommands(new ReportModule(this).getCommands());
//                addCommands(new Inktober(this).getCommands());
                addCommands(new Userinfo(this).getCommands());
                addCommands(new Someone(this).getCommands());
                addCommands(new Move(this).getCommands());

                var temp = new List <Command>();
                Action <ServerMessage, string> h = (x, y) =>
                {
                    String[] split = y.Split(new String[] { "\n" }, StringSplitOptions.RemoveEmptyEntries);
                    Console.WriteLine("invoking " + split.Length + " commands");
                    foreach (string s in split)
                    {
                        var res = parseMessageString(s);
                        Commandlist[res.Item1].invoke(x, res.Item2);
                    }
                    Console.WriteLine("invocation complete");
                };
                temp.Add(Command.AdminCommand(this, "multicommand", h, new HelpMsgStrings("", "")));
                addCommands(temp);
            }
            catch (Exception e)
            {
                Console.WriteLine("something went wrong setting up the server: " + e);
            }

            Console.WriteLine("Connected with server: " + server.Name);
        }