public static void CheckForCommunitySubEvents(object sender, OnCommunitySubscriptionArgs e)
        {
            CommunitySubscription g = e.GiftedSubscription;

            Log.Message($"CommunitySubscription = Anonymous: {g.IsAnonymous} - MassGiftCount: {g.MsgParamMassGiftCount} - SenderCounter: {g.MsgParamSenderCount} SubPlan: {g.MsgParamSubPlan}");

            List <Event> eventsWithCommunitySubTriggers = Events.All.Where((x) => x.communitySubs).ToList();

            foreach (Event evt in eventsWithCommunitySubTriggers)
            {
                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);
                }
            }
        }
Example #2
0
 public async Task SaveCommunitySubscribtionAsync(CommunitySubscription communitySubscription)
 {
     try
     {
         using var connection = new SqlConnection(ConnectionString);
         await connection.InsertAsync(communitySubscription);
     }
     catch (Exception ex)
     {
         logger.LogError(ex, $"Error while saving {nameof(CommunitySubscription)}");
     }
 }