Class SubscriptionManager
java.lang.Object
de.klassenserver7b.k7bot.subscriptions.SubscriptionManager
- Author:
- Klassenserver7b
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final org.slf4j.Logger(package private) final SubMessageSendHandlerprivate final ArrayList<Subscription> -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate Longprivate LongcalculateSubId(SubscriptionDeliveryType type, SubscriptionTarget target, Long deliverytargetid) booleancreateSubscription(SubscriptionDeliveryType type, SubscriptionTarget target, Long deliverytargetid) Creates a new Subscription for the submitted target and saves it to the database.voidprovideSubscriptionNotification(SubscriptionTarget target, net.dv8tion.jda.api.utils.messages.MessageCreateData data) Provides theMessageto every (target)-matching subscriptionprivate voidRequests the database-saved subscriptions and loads them into the local SubscriptionListprivate booleanbooleanremoveSubscription(SubscriptionDeliveryType type, SubscriptionTarget target, Long deliverytargetid) Removes a Subscription from the databasebooleanremoveSubscription(Long subscriptionid)
-
Field Details
-
sublist
-
sendhandler
-
log
private final org.slf4j.Logger log
-
-
Constructor Details
-
SubscriptionManager
public SubscriptionManager()
-
-
Method Details
-
provideSubscriptionNotification
public void provideSubscriptionNotification(SubscriptionTarget target, net.dv8tion.jda.api.utils.messages.MessageCreateData data) Provides theMessageto every (target)-matching subscription- Parameters:
target- The target of the notification e.g a new Lernplandata- 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- TheSubscriptionDeliveryTypeof the Channel the Bot should deliver the Subscription intarget- TheSubscriptionTargetof the new Subscriptiondeliverytargetid- The DiscordID of the DeliveryTarget, e.g.TYPE.getIdLong().
-
registerSubscription
-
removeSubscription
-
removeSubscription
public boolean removeSubscription(SubscriptionDeliveryType type, SubscriptionTarget target, Long deliverytargetid) Removes a Subscription from the database- Parameters:
type- TheSubscriptionDeliveryTypeof the Channel the Bot should deliver the Subscription intarget- TheSubscriptionTargetof the new Subscriptiondeliverytargetid- 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
- 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 Subscriptiontarget- The SubscriptionTarget of the Subscriptiondeliverytargetid- The DiscordID of the DeliveryTarget, e.g.- Returns:
- The calculated SubscriptionID
-