Пример #1
0
        private void onNewSubscriber(object sender, OnNewSubscriberArgs e)
        {
            try {
                Logger.Log("New subscriber in " + e.Channel);

                User user = UserManager.GetUserTwitch(e.Channel);
                BitbarManager.AddBits(user, subPlanToBits(e.Subscriber.SubscriptionPlan));
            }
            catch (Exception ex) {
                Logger.Log(ex);
            }
        }
Пример #2
0
        public static IActionResult Index(RequestHandler <IActionResult> req)
        {
            if (req.User == null)
            {
                throw new UnauthorizedException();
            }

            Bitbar bitbar = BitbarManager.GetBitbar(req.User);

            req.View.Bitbar = bitbar;

            return(req.Controller.View());
        }
Пример #3
0
 private void onMessageReceived(object sender, OnMessageReceivedArgs e)
 {
     try {
         if (e.ChatMessage.Bits > 0)
         {
             Logger.Log(e.ChatMessage.Bits + " bits cheered in " + e.ChatMessage.Channel);
             User user = UserManager.GetUserTwitch(e.ChatMessage.Channel);
             BitbarManager.AddBits(user, e.ChatMessage.Bits);
         }
     }
     catch (Exception ex) {
         Logger.Log(ex);
     }
 }
Пример #4
0
        public static JToken Bitbar(RequestHandler <JToken> req)
        {
            string id = req.Request.Query["id"];

            Bitbar  bitbar = BitbarManager.GetBitbar(id);
            JObject source = new JObject();

            source["source_id"]    = bitbar.Id;
            source["value"]        = bitbar.Value;
            source["max_value"]    = bitbar.MaxValue;
            source["target_color"] = "#" + bitbar.TargetColor;
            source["fill_color"]   = "#" + bitbar.FillColor;

            return(source);
        }
Пример #5
0
        // TODO: Move this logic up one level when we create a new hub!
        public async Task ReceiveSource(string source)
        {
            JObject json   = JObject.Parse(source);
            Bitbar  bitbar = BitbarManager.GetBitbar((string)json["source_id"]);

            string userid = bitbar.User.UserId;

            connectionUsers[this] = userid;
            if (!userConnections.ContainsKey(userid))
            {
                userConnections[userid] = new HashSet <BitbarHub>();
            }
            userConnections[userid].Add(this);

            await UpdateSource(bitbar);
        }
Пример #6
0
        public static IActionResult BitbarSubmit(RequestHandler <IActionResult> req)
        {
            IFormCollection form = req.Request.Form;

            if (req.User == null)
            {
                throw new UnauthorizedException();
            }

            try {
                int    value       = int.Parse(form["value"]);
                int    maxValue    = int.Parse(form["max_value"]);
                string targetColor = form["target_color"].ToString();
                string fillColor   = form["fill_color"].ToString();

                byte[] image = null;
                if (form.Files.Count > 0)
                {
                    image = new byte[form.Files["image"].Length];
                    form.Files["image"].OpenReadStream().Read(image, 0, image.Length);
                }


                Bitbar bitbar = BitbarManager.GetBitbar(req.User);
                bitbar.Value    = value;
                bitbar.MaxValue = maxValue;
                if (image != null)
                {
                    bitbar.Image = image;
                }
                bitbar.TargetColor = targetColor;
                bitbar.FillColor   = fillColor;

                BitbarManager.UpdateBitbar(bitbar);
            }
            catch (Exception ex) {
                throw new BadRequestException();
            }

            return(req.Controller.RedirectToAction("Index", "Streamkit"));
        }