Class SubscriptionManager

java.lang.Object
de.klassenserver7b.k7bot.subscriptions.SubscriptionManager

public class SubscriptionManager extends Object
Author:
Klassenserver7b
  • Field Details

  • Constructor Details

    • SubscriptionManager

      public SubscriptionManager()
  • Method Details

    • provideSubscriptionNotification

      public void provideSubscriptionNotification(SubscriptionTarget target, net.dv8tion.jda.api.utils.messages.MessageCreateData data)
      Provides the Message to every (target)-matching subscription
      Parameters:
      target - The target of the notification e.g a new Lernplan
      data - The message which should be sent to all subscribers
    • createSubscription

      public boolean createSubscription(SubscriptionDeliveryType type, SubscriptionTarget target, Long deliverytargetid)
      Creates a new Subscription for the submitted target and saves it to the database.
      Parameters:
      type - The SubscriptionDeliveryType of the Channel the Bot should deliver the Subscription in
      target - The SubscriptionTarget of the new Subscription
      deliverytargetid - The DiscordID of the DeliveryTarget, e.g. TYPE.getIdLong().
    • registerSubscription

      private boolean registerSubscription(Subscription sub)
    • removeSubscription

      public boolean removeSubscription(Long subscriptionid)
    • removeSubscription

      public boolean removeSubscription(SubscriptionDeliveryType type, SubscriptionTarget target, Long deliverytargetid)
      Removes a Subscription from the database
      Parameters:
      type - The SubscriptionDeliveryType of the Channel the Bot should deliver the Subscription in
      target - The SubscriptionTarget of the new Subscription
      deliverytargetid - The DiscordID of the DeliveryTarget, e.g. TYPE.getIdLong().
    • refreshList

      private void refreshList()
      Requests the database-saved subscriptions and loads them into the local SubscriptionList
    • calculateSubId

      private Long calculateSubId(Subscription sub)
      Parameters:
      sub - The Subscription to calculate the ID for
      Returns:
      The calculated SubscriptionID
    • calculateSubId

      private Long calculateSubId(SubscriptionDeliveryType type, SubscriptionTarget target, Long deliverytargetid)
      Parameters:
      type - The SubscriptionDeliveryType of the Subscription
      target - The SubscriptionTarget of the Subscription
      deliverytargetid - The DiscordID of the DeliveryTarget, e.g.
      Returns:
      The calculated SubscriptionID