コード例 #1
0
    public HelperMiddleware(IMiddleware next, StatsPlugin statsPlugin, JsonStoragePlugin jsonStoragePlugin)
        : base(next)
    {
        _r = new Random();
        this._statsPlugin    = statsPlugin;
        _jsonStoragePlugin   = jsonStoragePlugin;
        this.HandlerMappings = new HandlerMapping[1]
        {
            new HandlerMapping()
            {
                ValidHandles  = new[] { new AlwaysMatchHandle() },
                Description   = "Gets search result from discourse",
                EvaluatorFunc = DiscourseSearch
            }
        };

        jokes = jsonStoragePlugin.ReadFile <Joke>("jokes").ToList();
        if (!jokes.Any())
        {
            jokes.Add(new Joke()
            {
                Content = "bcash is the superior cryptocurrency because big blocks are cool, I guess"
            });
        }
    }
コード例 #2
0
    public HelperMiddleware(IMiddleware next, StatsPlugin statsPlugin, JsonStoragePlugin jsonStoragePlugin)
        : base(next)
    {
        _r = new Random();
        this._statsPlugin    = statsPlugin;
        _jsonStoragePlugin   = jsonStoragePlugin;
        this.HandlerMappings = new HandlerMapping[1]
        {
            new HandlerMapping()
            {
                ValidHandles  = new[] { new AlwaysMatchHandle() },
                Description   = "Supreme Ruler Roger Ver does not need to explain himself to you",
                EvaluatorFunc = DiscourseSearch
            }
        };
        jokes               = jsonStoragePlugin.ReadFile <Joke>("jokes").ToList();
        PinCodes            = jsonStoragePlugin.ReadFile <PinCode>("pincodes").ToList();
        UpdateSubscriptions = jsonStoragePlugin.ReadFile <UpdateSubscription>("subscriptions").ToList();
        if (!jokes.Any())
        {
            jokes.Add(new Joke()
            {
                Content = "bcash is the superior cryptocurrency because big blocks are cool, I guess"
            });
        }

        if (!PinCodes.Any())
        {
            PinCodes.Add(new PinCode()
            {
                Pin    = "7dd7aa3a-a5e3-42d5-b651-1de152c75bcb",
                UserId = "U96S14QGY"
            });
        }

        _httpClient = new HttpClient();
    }