コード例 #1
0
 void GiftSub(object source, TwitchLib.Client.Events.OnGiftedSubscriptionArgs args)
 {
     try
     {
         int tier = 1;
         if (args.GiftedSubscription.MsgParamSubPlan == TwitchLib.Client.Enums.SubscriptionPlan.Prime || args.GiftedSubscription.MsgParamSubPlan == TwitchLib.Client.Enums.SubscriptionPlan.Tier1)
         {
             tier = 1;
             if (int.TryParse(args.GiftedSubscription.MsgParamMonths, out int m))
             {
                 resubs += 5;
             }
             else
             {
                 subs += 5;
             }
         }
         else if (args.GiftedSubscription.MsgParamSubPlan == TwitchLib.Client.Enums.SubscriptionPlan.Tier2)
         {
             tier = 2;
             if (int.TryParse(args.GiftedSubscription.MsgParamMonths, out int m))
             {
                 resubs += 10;
             }
             else
             {
                 subs += 10;
             }
         }
         else if (args.GiftedSubscription.MsgParamSubPlan == TwitchLib.Client.Enums.SubscriptionPlan.Tier3)
         {
             tier = 3;
             if (int.TryParse(args.GiftedSubscription.MsgParamMonths, out int m))
             {
                 resubs += 25;
             }
             else
             {
                 subs += 25;
             }
         }
         if (int.TryParse(args.GiftedSubscription.MsgParamMonths, out int months))
         {
             DoGiveaway(args.GiftedSubscription.MsgParamRecipientUserName, tier, Math.Max(months, 1)).GetAwaiter().GetResult();
         }
         else
         {
             DoGiveaway(args.GiftedSubscription.MsgParamRecipientUserName, tier, 1).GetAwaiter().GetResult();
         }
         UpdateFiles().GetAwaiter().GetResult();
     }
     catch (Exception ex)
     {
         bot.LogError("GiftedSub", ex.Message + $" {args.GiftedSubscription.MsgParamMonths}");
     }
 }
コード例 #2
0
        public int months; // This seems highly unreliable

        public TwitchSubGiftEventArguments(TwitchLib.Client.Events.OnGiftedSubscriptionArgs e)
        {
            int.TryParse(e.GiftedSubscription.Id, out twitchUserID);
            userDisplayname = e.GiftedSubscription.DisplayName;
            username        = e.GiftedSubscription.Login;

            int.TryParse(e.GiftedSubscription.MsgParamRecipientId, out recipientUserID);
            recipientUsername    = e.GiftedSubscription.MsgParamRecipientUserName;
            recipientDisplayname = e.GiftedSubscription.MsgParamRecipientDisplayName;

            twitchChannelname = e.Channel;

            subscriptionplan = (SubscriptionPlan)e.GiftedSubscription.MsgParamSubPlan;
            int.TryParse(e.GiftedSubscription.MsgParamMonths, out months);

            subscriptionplanName = e.GiftedSubscription.MsgParamSubPlanName;
        }