Esempio n. 1
0
        public void Init(DiscloseOptions options)
        {
            string identifier = Regex.Escape(options.CommandCharacter);
            string regex;

            if (options.UseAlias)
            {
                string aliases = String.Join("|", options.Aliases);

                regex = $"^(?:{identifier}(?:{aliases}))\\s+(\\S+)(?:\\s+([\\s\\S]+))?";
            }
            else
            {
                regex = $"^(?:{identifier})(\\S+)(?:\\s+([\\s\\S]+))?";
            }

            _commandRegex = new Regex(regex, RegexOptions.Singleline | RegexOptions.Compiled);

            if (options.SimpleDirectMessages)
            {
                string directMessageRegex = "^(\\S+)(?:\\s+([\\s\\S]+))?";

                _directMessageCommandRegex = new Regex(directMessageRegex, RegexOptions.Singleline | RegexOptions.Compiled);
            }
            else
            {
                _directMessageCommandRegex = _commandRegex;
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Sets the Disclose options. Must be called before Connect is called.
        /// </summary>
        /// <param name="options"></param>
        public void Init(DiscloseOptions options)
        {
            _options = options;
            _parser.Init(_options);

            _discordClient.OnMessageReceived  += OnMessageReceived;
            _discordClient.OnUserJoinedServer += OnUserJoinedServer;
            _discordClient.OnServerAvailable  += OnServerAvailable;
        }
Esempio n. 3
0
        /// <summary>
        /// Creates an instance of the DiscloseClient with default implementations and calls Init to set the disclose options.
        /// </summary>
        /// <param name="setOptions">Set your Disclose options here.</param>
        /// <returns></returns>
        public static DiscloseClient Bootstrap(Action <DiscloseOptions> setOptions)
        {
            DiscloseOptions options = new DiscloseOptions();

            setOptions(options);

            DiscloseClient client = new DiscloseClient(new DiscordNetClient(), new CommandParser());

            client.Init(options);

            return(client);
        }