예제 #1
0
        private static void Client_OnGiftedSubscription(object sender, OnGiftedSubscriptionArgs e)
        {
            string giftee = e.GiftedSubscription.MsgParamRecipientDisplayName;
            string gifter = e.GiftedSubscription.DisplayName;

            BotTools.LogLine($"{gifter} gifted a sub to {giftee}");
        }
예제 #2
0
 private void GiftSub(OnGiftedSubscriptionArgs args)
 {
     if (Config.Currency.Enabled)
     {
         HandleCurrency(args);
     }
 }
예제 #3
0
        private void HandleCurrency(OnGiftedSubscriptionArgs args)
        {
            var currencyToAward = 0;

            switch (args.GiftedSubscription.MsgParamSubPlan)
            {
            case TwitchLib.Client.Enums.SubscriptionPlan.Prime:
                currencyToAward = Config.Currency.AwardForSub_Prime;
                break;

            case TwitchLib.Client.Enums.SubscriptionPlan.Tier1:
                currencyToAward = Config.Currency.AwardForSub_Tier1;
                break;

            case TwitchLib.Client.Enums.SubscriptionPlan.Tier2:
                currencyToAward = Config.Currency.AwardForSub_Tier2;
                break;

            case TwitchLib.Client.Enums.SubscriptionPlan.Tier3:
                currencyToAward = Config.Currency.AwardForSub_Tier3;
                break;
            }



            CurrencyRepository.AddForUser(args.GiftedSubscription.DisplayName, Config.Currency.AwardForGiftSub, "Bot-SubGifter");
            CurrencyRepository.AddForUser(args.GiftedSubscription.MsgParamRecipientDisplayName, currencyToAward, "PixelBot-SubGift");
        }
예제 #4
0
        private async void Client_OnGiftedSubscription(object sender, OnGiftedSubscriptionArgs e)
        {
            try
            {
                if (e.GiftedSubscription.DisplayName != "AnAnonymousGifter")
                {
                    var user = await dataHelper.GetUserFromGifted(e);

                    db.EditExpViaGiftedSub(user);
                    logService.Add($":{e.GiftedSubscription.DisplayName}", MessageType.Type.SUBGIFT,
                                   MethodBase.GetCurrentMethod().DeclaringType);
                }
                else
                {
                    logService.Add($":{e.GiftedSubscription.DisplayName}", MessageType.Type.ANONGIFT,
                                   MethodBase.GetCurrentMethod().DeclaringType);
                }
                //    client.SendMessage(Startup.streamerName, "olyashFonarik olyashFonarik olyashFonarik olyashFonarik");
            }
            catch (Exception ex)
            {
                logService.Add(ex, MessageType.Type.ERROR,
                               MethodBase.GetCurrentMethod().DeclaringType);
            }
        }
예제 #5
0
 private void Client_OnGiftedSubscription(object sender, OnGiftedSubscriptionArgs e)
 {
     if (Settings.UseGiftedSubMessage)
     {
         // TODO: Implement gifted subscription messages. Currently the GiftedSubscription type does not contain the information we need.
     }
 }
        public static void CheckForGiftedSubEvents(object sender, OnGiftedSubscriptionArgs e)
        {
            GiftedSubscription g = e.GiftedSubscription;

            Log.Message($"GiftedSubscription = Anonymous: {g.IsAnonymous} - Months: {g.MsgParamMonths} - Recipient: {g.MsgParamRecipientDisplayName} SubPlan: {g.MsgParamSubPlan} - SubPlanName: {g.MsgParamSubPlanName}");

            List <Event> eventsWithGiftedSubTriggers = Events.All.Where((x) => x.giftSubs).ToList();

            foreach (Event evt in eventsWithGiftedSubTriggers)
            {
                bool fire = false;

                if (e.GiftedSubscription.MsgParamSubPlan.ToString() == "Tier1" && evt.tierOneSubs)
                {
                    fire = true;
                }
                else if (e.GiftedSubscription.MsgParamSubPlan.ToString() == "Tier2" && evt.tierTwoSubs)
                {
                    fire = true;
                }
                else if (e.GiftedSubscription.MsgParamSubPlan.ToString() == "Tier3" && evt.tierThreeSubs)
                {
                    fire = true;
                }

                if (fire)
                {
                    evt.FireEvents(e.GiftedSubscription.DisplayName);
                }
            }
        }
        private void Client_OnGiftedSubscription(object sender, OnGiftedSubscriptionArgs e)
        {
            ChannelUser  user         = new ChannelUser(e.GiftedSubscription.MsgParamRecipientId, e.GiftedSubscription.MsgParamRecipientUserName, e.GiftedSubscription.MsgParamRecipientUserName);
            ChannelUser  resolvedUser = usernameResolver.ResolveUsername(user);
            SubGiftEvent subgift      = new SubGiftEvent(resolvedUser);

            bus.Publish(subgift);
        }
예제 #8
0
        private void OnGiftedSub(object sender, OnGiftedSubscriptionArgs e)
        {
            this.messageBus.Send(nameof(TwitchSubscription),
                                 new TwitchSubscription(e.GiftedSubscription.Id,
                                                        e.GiftedSubscription.Login,
                                                        e.GiftedSubscription.DisplayName, 1, false));

            this.Broadcast($"Thank you {e.GiftedSubscription.DisplayName} for the gifted sub!!! <3");
        }
예제 #9
0
        public static void SubGifted(object sender, OnGiftedSubscriptionArgs e)
        {
            string Id = UserHandler.UserFromUsername(e.GiftedSubscription.DisplayName).Matches[0].Id;

            Shared.Data.UserData.CreateUser(Id, Shared.IDType.Twitch);
            int Reward = int.Parse(Shared.ConfigHandler.Config["Rewards"]["Twitch"]["GiftedSub"].ToString());

            Shared.Data.Accounts.GiveUser(Id, Shared.IDType.Twitch, Reward);
            MessageHandler.SendMessage(e.Channel, Shared.ConfigHandler.Config["EventMessages"]["GiftedSub"].ToString(), e.GiftedSubscription.DisplayName, e.GiftedSubscription.MsgParamRecipientDisplayName, Reward);
        }
예제 #10
0
        private void _Client_OnGiftedSubscription(object sender, OnGiftedSubscriptionArgs e)
        {
            if (!EnableSubPixels)
            {
                return;
            }

            _GoogleSheet.AddPixelsForUser(e.GiftedSubscription.DisplayName, 2, "PixelBot-SubGifter");
            _GoogleSheet.AddPixelsForUser(e.GiftedSubscription.MsgParamRecipientDisplayName, _PixelRewards[e.GiftedSubscription.MsgParamSubPlan], "PixelBot-SubGift");
        }
        public void Client_OnGiftedSubscription(object sender, OnGiftedSubscriptionArgs e)
        {
            var info = new SubscriptionInfo
            {
                UserDisplayName         = e.GiftedSubscription.MsgParamRecipientDisplayName,
                GiftedByUserDisplayName = e.GiftedSubscription.DisplayName,
                PlanName = e.GiftedSubscription.MsgParamSubPlanName,
                Months   = int.Parse(e.GiftedSubscription.MsgParamMonths),
            };

            OnSub(info);
        }
예제 #12
0
        public static void KiraOnGiftedSubscription(object s, OnGiftedSubscriptionArgs e, CallbackArgs args)
        {
            if (!string.Equals(e.GiftedSubscription.MsgParamRecipientDisplayName, BotService.BotUsername,
                               BotService.StringComparison))
            {
                return;
            }

            var answer = "спасибо большое за подписку kupaLove kupaLove kupaLove";

            BotService.BotTwitchClient.SendMessage(e.Channel, $"{e.GiftedSubscription.DisplayName}, {answer}");
        }
예제 #13
0
    private void OnGiftedSubscription(object sender, OnGiftedSubscriptionArgs e)
    {
        AddDebugLine(
            $"Gift subscription received {e.GiftedSubscription.MsgParamRecipientUserName} from {e.GiftedSubscription.Id}");

        AddDebugLine($"{e.GiftedSubscription.Id} " +
                     $"/ {e.GiftedSubscription.Login} " +
                     $"/ {e.GiftedSubscription.DisplayName} " +
                     $"/ {e.GiftedSubscription.MsgParamRecipientId} " +
                     $"/ {e.GiftedSubscription.MsgParamRecipientUserName} " +
                     $"/ {e.GiftedSubscription.MsgParamRecipientDisplayName} " +
                     $"/ {e.GiftedSubscription.MsgParamSubPlan}");
    }
        public static void InvokeGiftedSubscription(this TwitchClient client, string badges, string color, string displayName, string emotes, string id, string login, bool isModerator,
                                                    string msgId, string msgParamMonths, string msgParamRecipientDisplayName, string msgParamRecipientId, string msgParamRecipientUserName,
                                                    string msgParamSubPlanName, SubscriptionPlan msgParamSubPlan, string roomId, bool isSubscriber, string systemMsg, string systemMsgParsed,
                                                    string tmiSentTs, bool isTurbo, UserType userType)
        {
            var model = new OnGiftedSubscriptionArgs()
            {
                GiftedSubscription = new GiftedSubscription(badges, color, displayName, emotes, id, login, isModerator, msgId, msgParamMonths, msgParamRecipientDisplayName,
                                                            msgParamRecipientId, msgParamRecipientUserName, msgParamSubPlanName, msgParamSubPlan, roomId, isSubscriber, systemMsg, systemMsgParsed, tmiSentTs, isTurbo,
                                                            userType)
            };

            client.RaiseEvent("OnGiftedSubscription", model);
        }
예제 #15
0
        private async void Client_OnGiftSubscriber(object sender, OnGiftedSubscriptionArgs e)
        {
            try
            {
                await _connection.InvokeAsync("SendMessage", e.GiftedSubscription.DisplayName, "Waffling", MessageTypeEnum.Cannon);

                _client.SendMessage(e.Channel,
                                    $"Woweee! {e.GiftedSubscription.DisplayName} just gifted {e.GiftedSubscription}! Thank you so much <3");
            }
            catch (Exception ex)
            {
                Console.WriteLine($"Gifted sub action failed: {ex.Message}");
            }
        }
예제 #16
0
        /// <summary>
        /// Invokes the gifted subscription.
        /// </summary>
        /// <param name="client">The client.</param>
        /// <param name="badges">The badges.</param>
        /// <param name="color">The color.</param>
        /// <param name="displayName">The display name.</param>
        /// <param name="emotes">The emotes.</param>
        /// <param name="id">The identifier.</param>
        /// <param name="login">The login.</param>
        /// <param name="isModerator">if set to <c>true</c> [is moderator].</param>
        /// <param name="msgId">The MSG identifier.</param>
        /// <param name="msgParamMonths">The MSG parameter months.</param>
        /// <param name="msgParamRecipientDisplayName">Display name of the MSG parameter recipient.</param>
        /// <param name="msgParamRecipientId">The MSG parameter recipient identifier.</param>
        /// <param name="msgParamRecipientUserName">Name of the MSG parameter recipient user.</param>
        /// <param name="msgParamSubPlanName">Name of the MSG parameter sub plan.</param>
        /// <param name="msgParamSubPlan">The MSG parameter sub plan.</param>
        /// <param name="roomId">The room identifier.</param>
        /// <param name="isSubscriber">if set to <c>true</c> [is subscriber].</param>
        /// <param name="systemMsg">The system MSG.</param>
        /// <param name="systemMsgParsed">The system MSG parsed.</param>
        /// <param name="tmiSentTs">The tmi sent ts.</param>
        /// <param name="isTurbo">if set to <c>true</c> [is turbo].</param>
        /// <param name="userType">Type of the user.</param>
        /// <param name="userId">Id of the user.</param>
        public static void InvokeGiftedSubscription(this TwitchClient client, List <KeyValuePair <string, string> > badges, List <KeyValuePair <string, string> > badgeInfo, string color, string displayName, string emotes, string id, string login, bool isModerator,
                                                    string msgId, string msgParamMonths, string msgParamRecipientDisplayName, string msgParamRecipientId, string msgParamRecipientUserName,
                                                    string msgParamSubPlanName, string msgMultiMonthGiftDuration, SubscriptionPlan msgParamSubPlan, string roomId, bool isSubscriber, string systemMsg, string systemMsgParsed,
                                                    string tmiSentTs, bool isTurbo, UserType userType, string userId)
        {
            OnGiftedSubscriptionArgs model = new OnGiftedSubscriptionArgs()
            {
                GiftedSubscription = new GiftedSubscription(badges, badgeInfo, color, displayName, emotes, id, login, isModerator, msgId, msgParamMonths, msgParamRecipientDisplayName,
                                                            msgParamRecipientId, msgParamRecipientUserName, msgParamSubPlanName, msgMultiMonthGiftDuration, msgParamSubPlan, roomId, isSubscriber, systemMsg, systemMsgParsed, tmiSentTs, isTurbo,
                                                            userType, userId)
            };

            client.RaiseEvent("OnGiftedSubscription", model);
        }
예제 #17
0
        private void onGiftedSubscription(object sender, OnGiftedSubscriptionArgs e)
        {
            try {
                Logger.Log("Gifted subscription in " + e.Channel);

                // TODO: Find out if this event is fired by itself or alongside another.

                //User user = UserManager.GetUserTwitch(e.Channel);
                //// It seems you can't gift sub tiers higher than one yet
                //BitbarManager.AddBits(user, 250);
            }
            catch (Exception ex) {
                Logger.Log(ex);
            }
        }
예제 #18
0
        private static void Client_OnGiftedSubscription(object sender, OnGiftedSubscriptionArgs e)
        {
            if (!e.GiftedSubscription.MsgParamRecipientDisplayName.ToLower().Equals(self))
            {
                return;
            }
            string toWrite = $"Got a {e.GiftedSubscription.MsgParamSubPlan} {e.GiftedSubscription.MsgParamMonths} Month sub in channel {e.Channel} by {e.GiftedSubscription.DisplayName}";

            //Console.WriteLine(toWrite);
            string[] linesToWrite = { toWrite };
            subgift  next;

            metrics.tryparsegift(toWrite, out next);
            Redis.addGiftsub(next);
            DrawEvent.Set();
        }
예제 #19
0
        private void OnGiftedSub(object sender, OnGiftedSubscriptionArgs e)
        {
            this.messageBus.Send(nameof(TwitchSubscription),
                                 new TwitchSubscription(
                                     e.Channel,
                                     e.GiftedSubscription.Id,
                                     e.GiftedSubscription.Login,
                                     e.GiftedSubscription.DisplayName,
                                     e.GiftedSubscription.MsgParamRecipientId,
                                     e.GiftedSubscription.IsModerator,
                                     e.GiftedSubscription.IsSubscriber,
                                     1,
                                     false));

            this.Broadcast("", Localization.Twitch.THANK_YOU_GIFT_SUB, e.GiftedSubscription.DisplayName);
        }
예제 #20
0
        private static void OnGifted(object sender, OnGiftedSubscriptionArgs e)
        {
            if (!Context.IsWorldReady)
            {
                return;
            }

            if (BNC_Core.config.Spawn_GiftSub_Subscriber_Mobs)
            {
                Spawner.AddMonsterToSpawnFromType(TwitchMobType.Slime, e.GiftedSubscription.MsgParamRecipientDisplayName, true);
            }

            if (Config.ShowDebug())
            {
                BNC_Core.Logger.Log($"Adding GiftSub Slime:{e.GiftedSubscription.MsgParamRecipientDisplayName} to queue...", LogLevel.Info);
            }
        }
예제 #21
0
        public void Test_Client_OnGiftedSubscription()
        {
            var    chatBot        = new TwitchStreamChatBot();
            string chatMessageRaw = "TODO";
            var    ircMessage     = GetIrcMessage(chatMessageRaw);
            var    args           = new OnGiftedSubscriptionArgs()
            {
                GiftedSubscription = new TwitchLib.Client.Models.GiftedSubscription(ircMessage),
            };

            Assert.True(chatBot.EndOfStreamRaid == null);
            chatBot.Client_OnGiftedSubscription(null, args);
            Assert.True(chatBot.EndOfStreamRaid != null);

            var template = chatBot.PopulateMarkdownTemplate().ToString();

            Assert.Contains("TODO", template);
        }
예제 #22
0
        internal static void giftsub(object sender, OnGiftedSubscriptionArgs e)
        {
            Form1 fm = new Form1();

            try
            {
                string   holder = GiftSub;
                DateTime dt     = System.DateTime.Now;
                string   stamp  = dt.ToShortDateString() + " " + dt.ToShortTimeString();
                string   gifter = e.GiftedSubscription.DisplayName;

                if (gifter == "")
                {
                    gifter = e.GiftedSubscription.Login;
                }
                string subscriber = e.GiftedSubscription.MsgParamRecipientDisplayName;
                if (subscriber == "")
                {
                    e.GiftedSubscription.MsgParamRecipientUserName.ToString();
                }
                holder = holder.Replace("$time", stamp);
                holder = holder.Replace("$recipant", subscriber);
                holder = holder.Replace("$gifter", gifter);

                using (StreamWriter writer = new StreamWriter(cachedir + @"\giftsub.csv", append: true))
                {
                    writer.WriteLine(stamp + "," + subscriber + "," + gifter);
                }
                holder = GiftSub;
                holder = holder.Replace("$time", stamp);
                holder = holder.Replace("$recipant", "<span class='name'>" + subscriber + "</span>");
                holder = holder.Replace("$gifter", "<span class='name'>" + gifter + "</span>");
                fm.Processmessage(stamp, holder, " GIFTSUB ", " From " + gifter + " to " + subscriber, "", "");
                //processMessage(holder);
            }
            catch (Exception ee)
            {
                File.AppendAllText(cachedir + @"\errorlog.txt", ee.ToString() + Environment.NewLine);
                Console.WriteLine(ee.ToString() + Environment.NewLine);
            }
        }
예제 #23
0
        public async void SubGifted(object sender, OnGiftedSubscriptionArgs e)
        {
            StandardisedUser Gifter = new StandardisedUser(),
                             Giftee = new StandardisedUser();;

            Gifter.ID = e.GiftedSubscription.Id; Gifter.UserName = e.GiftedSubscription.DisplayName;
            Giftee.ID = e.GiftedSubscription.MsgParamRecipientId; Giftee.UserName = e.GiftedSubscription.MsgParamRecipientDisplayName;
            int Reward = int.Parse(BotInstance.CommandConfig["AutoRewards"]["GiftSub"]["Reward"].ToString());

            Data.APIIntergrations.RewardCurrencyAPI.Objects.Viewer V = Data.APIIntergrations.RewardCurrencyAPI.Objects.Viewer.FromTwitchDiscord(MessageType.Twitch, BotInstance, Gifter.ID);
            if (V != null)
            {
                Data.APIIntergrations.RewardCurrencyAPI.Objects.Viewer.AdjustBalance(V, Reward, "+");
            }
            await BotInstance.CommandHandler.SendMessage(BotInstance.CommandConfig["AutoRewards"]["GiftSub"]["Response"].ToString(), e.Channel.ToString(), MessageType.Twitch, Gifter, Reward, OtherString : "@" + Giftee.UserName);

            if (BotInstance.CommandConfig["AutoRewards"]["DiscordSubNotifications"].ToString() == "True")
            {
                await BotInstance.CommandHandler.SendMessage(BotInstance.CommandConfig["AutoRewards"]["GiftSub"]["Response"].ToString(), BotInstance.CommandConfig["Discord"]["NotificationChannel"].ToString(), MessageType.Discord, Gifter, Reward, OtherString : "<@" + Giftee.UserName + ">");
            }
        }
예제 #24
0
        public async Task <TwitchUserModel> GetUserFromGifted(OnGiftedSubscriptionArgs data)
        {
            try
            {
                var    badges        = GetDataFromBadges(data.GiftedSubscription.Badges);
                string vipfrombadges = badges.Where(x => x.Key == "vip").Select(x => x.Value).FirstOrDefault();
                bool   vip;
                if (vipfrombadges == "1")
                {
                    vip = true;
                }
                else
                {
                    vip = false;
                }
                var user = (new TwitchUserModel
                {
                    userId = await GetUseridByName(data.GiftedSubscription.DisplayName),
                    userName = data.GiftedSubscription.DisplayName,
                    userType = data.GiftedSubscription.UserType.ToString(),
                    isSub = data.GiftedSubscription.IsSubscriber,
                    isVip = vip,
                    isModer = data.GiftedSubscription.IsModerator,
                    giftsCount = Int32.Parse(badges.Where(x => x.Key == "sub-gifter").Select(x => x.Value).FirstOrDefault()),
                    subMounthsCount = Int32.Parse(badges.Where(x => x.Key == "subscriber").Select(x => x.Value).FirstOrDefault()),
                    SubPlan = (string)"1",
                });

                return(user);
            }
            catch (Exception ex)
            {
                //logService.Add(ex, MessageType.Type.ERROR,
                //     MethodBase.GetCurrentMethod().DeclaringType);
                Console.WriteLine(ex.Message + "in " + MethodBase.GetCurrentMethod().DeclaringType);
                return(null);
            }
        }
예제 #25
0
        private void OnGiftedSubscription(object sender, OnGiftedSubscriptionArgs e)
        {
            switch (e.GiftedSubscription.MsgParamSubPlan)
            {
            case SubscriptionPlan.Tier1:
                form.WriteChat(e.GiftedSubscription.DisplayName + " just gifted a Tier 1 sub to " + e.GiftedSubscription.MsgParamRecipientDisplayName + " a sub!!! itslitHype itslitHype itslitHype", true);
                form.AddEvent("Tier 1 gift from " + e.GiftedSubscription.DisplayName + " to " + e.GiftedSubscription.MsgParamRecipientDisplayName);

                break;

            case SubscriptionPlan.Tier2:
                form.WriteChat(e.GiftedSubscription.DisplayName + " just gifted a Tier 2 sub to " + e.GiftedSubscription.MsgParamRecipientDisplayName + " a sub!!! itslitHype itslitHype itslitHype", true);
                form.AddEvent("Tier 2 gift from " + e.GiftedSubscription.DisplayName + " to " + e.GiftedSubscription.MsgParamRecipientDisplayName);

                break;

            case SubscriptionPlan.Tier3:
                form.WriteChat(e.GiftedSubscription.DisplayName + " just gifted a Tier 3 sub to " + e.GiftedSubscription.MsgParamRecipientDisplayName + " a sub!!! itslitHype itslitHype itslitHype", true);
                form.AddEvent("Tier 3 gift from " + e.GiftedSubscription.DisplayName + " to " + e.GiftedSubscription.MsgParamRecipientDisplayName);

                break;
            }
        }
예제 #26
0
 private async void TwitchOnGiftedSubscription(object sender, OnGiftedSubscriptionArgs e)
 {
     BotChannel bChan = await Program.Channels.GetTwitchChannelByName(e.Channel);
     Program.BotEvents.RaiseTwitchOnSubGift(bChan,  new TwitchSubGiftEventArguments(e));
 }
예제 #27
0
 private void onGiftedSubscription(object sender, OnGiftedSubscriptionArgs e)
 {
     //e.GiftedSubscription.
     SubHype();
 }
예제 #28
0
 private void Client_GiftedSubscription(object sender, OnGiftedSubscriptionArgs e)
 {
 }
 private void OnGiftSubscriber(object sender, OnGiftedSubscriptionArgs e)
 {
     ConsoleHelper.WriteLine($"{e.GiftedSubscription.DisplayName} just bought {e.GiftedSubscription.MsgParamRecipientDisplayName} a {e.GiftedSubscription.MsgParamSubPlan} subscription!");
     speechSynthesizer.SpeakAsync($"Much thanks to {e.GiftedSubscription.DisplayName} for buying {e.GiftedSubscription.MsgParamRecipientDisplayName} a sub!");
 }
예제 #30
0
 private void onGiftedSubscription(object sender, OnGiftedSubscriptionArgs e)
 {
     MessageBox.Show($"Gifted subscription detected!\n\nDonated by: {e.GiftedSubscription.Login}\nRecipient: {e.GiftedSubscription.MsgParamRecipientUserName}");
 }