disco package#
No module description available.
Subpackages#
Submodules#
disco.configuration module#
No module description available.
- class disco.configuration.Configuration#
Bases:
objectAll configurations for the application.
- bot = _DcConfiguration(path=PosixPath('/home/docs/.disco/run/bot.toml'), schema=_DcSchema(name='bot', version=1, _definition={'additionalProperties': False, 'description': 'This configuration stores everything related to the bot itself.', 'properties': {'$schema': {'description': 'Which JSONSchema the file follows.', 'format': 'uri', 'type': 'string'}, 'no-reply': {'additionalProperties': False, 'description': "Configuration for the 'no-reply' feature. If this is not set, the bot will not send any automatic replies.", 'properties': {'enabled': {'description': "Whether the 'no-reply' feature is enabled.", 'type': 'boolean'}, 'message': {'description': 'The message to send back when the bot receives a message. If empty or not set, a default message in English will be sent.', 'type': 'string'}}, 'required': ['enabled'], 'type': 'object'}}, 'title': 'Bot', 'type': 'object'}, _example={'no-reply': {'enabled': True, 'message': '⚠️ I am a bot. My inbox is not monitored.'}}))#
- classmethod get_discord_bot_token(scrub_token: bool = False) str#
Get the Discord bot token from the secrets file and scrub it from the secrets file atomically using atomicwrites.
- Parameters:
scrub_token – Whether to scrub the token from the config file (currently not compatible with Docker build)
- Returns:
The Discord bot token
- podcasts = _DcConfiguration(path=PosixPath('/home/docs/.disco/run/podcasts.toml'), schema=_DcSchema(name='podcasts', version=1, _definition={'description': 'This configuration stores everything related to podcast feeds.', 'properties': {'$schema': {'description': 'Which JSONSchema the file follows.', 'format': 'uri', 'type': 'string'}, 'podcast': {'description': 'Podcast feeds to forward to a Discord channel.', 'items': {'additionalProperties': False, 'properties': {'forward_channel': {'description': 'The exact name of the channel where podcast episodes shall appear.', 'type': 'string'}, 'forward_guild': {'description': "The exact name of the Discord server ('guild') where `forward_channel` is located.", 'type': 'string'}, 'name': {'description': 'Your chosen name of the podcast (must be unique). May appear in user-facing text.', 'type': 'string'}, 'url_artwork': {'description': 'The URL for the podcast cover art. This is also be used as a fallback whenever episode artwork is not available.', 'format': 'uri', 'type': 'string'}, 'url_feed': {'description': 'The URL for the podcast RSS feed.', 'format': 'uri', 'type': 'string'}}, 'required': ['name', 'forward_guild', 'forward_channel', 'url_feed'], 'type': 'object'}, 'type': 'array'}}, 'title': 'Podcasts', 'type': 'object'}, _example={'podcast': [{'name': 'My Podcast', 'forward_channel': 'podcast', 'forward_guild': 'My Server', 'url_artwork': 'https://example.com/podcast.jpg', 'url_feed': 'https://example.com/podcast.rss'}, {'name': 'My Other Podcast', '...': '...'}]}))#
- secrets = _DcConfiguration(path=PosixPath('/home/docs/.disco/run/secrets.toml'), schema=_DcSchema(name='secrets', version=1, _definition={'additionalProperties': False, 'description': 'This holds all the secrets required for your bot to function.', 'properties': {'$schema': {'description': 'Which JSONSchema the file follows.', 'format': 'uri', 'type': 'string'}, 'disco': {'additionalProperties': False, 'description': 'This holds all the actual secrets data.', 'properties': {'token': {'description': "The 'Bot Token' from your Discord App.", 'type': 'string'}}, 'required': ['token'], 'type': 'object'}}, 'required': ['disco'], 'title': 'Secrets', 'type': 'object'}, _example={'disco': {'token': 'ABCDEFGHIJKLMNOPQRSTUVWXYZ.A1b2C3.abcdefghijklmnopqrstuvwxyzABCDEFGHIJKL'}}))#
disco.definitions module#
No module description available.
disco.models module#
No module description available.
- class disco.models.Episode(id, title, subtitle, summary, url_episode, url_artwork, date_published, date_forwarded, podcast)#
Bases:
Model- exception DoesNotExist#
Bases:
ObjectDoesNotExist
- exception MultipleObjectsReturned#
Bases:
MultipleObjectsReturned
- exception NotUpdated#
Bases:
ObjectNotUpdated,DatabaseError
- date_forwarded#
When it was published to Discord
- date_published#
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- get_next_by_date_published(*, field=<django.db.models.fields.DateTimeField: date_published>, is_next=True, **kwargs)#
- get_previous_by_date_published(*, field=<django.db.models.fields.DateTimeField: date_published>, is_next=False, **kwargs)#
- id#
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- classmethod load_all(podcast: Podcast, from_feed: FeedParserDict | None) list[Episode]#
Load all episodes for a podcast.
- Parameters:
podcast – Podcast to load episodes for
from_feed – Cached copy of the podcast feed if available, otherwise fetch it
- Returns:
loaded episodes
- classmethod make_id(*, url_episode: str, date_published: datetime) str#
ID factory
- Parameters:
url_episode – Title of the episode
date_published – Date the episode was published
- Returns:
ID for an instance
- objects: Manager = <django.db.models.manager.Manager object>#
- podcast#
Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.
In the example:
class Child(Model): parent = ForeignKey(Parent, related_name='children')
Child.parentis aForwardManyToOneDescriptorinstance.
- podcast_id#
- subtitle#
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- summary#
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- title#
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- url_artwork#
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- url_episode#
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- class disco.models.Podcast(id, name, forward_guild, forward_channel, url_feed, url_artwork, date_cutoff, date_checked, date_updated)#
Bases:
Model- exception DoesNotExist#
Bases:
ObjectDoesNotExist
- exception MultipleObjectsReturned#
Bases:
MultipleObjectsReturned
- exception NotUpdated#
Bases:
ObjectNotUpdated,DatabaseError
- date_checked#
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- date_cutoff#
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- date_updated#
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- episode_set#
Accessor to the related objects manager on the reverse side of a many-to-one relation.
In the example:
class Child(Model): parent = ForeignKey(Parent, related_name='children')
Parent.childrenis aReverseManyToOneDescriptorinstance.Most of the implementation is delegated to a dynamically defined manager class built by
create_reverse_many_to_one_manager()defined below.
- forward_channel#
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- forward_guild#
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- get_feed() FeedParserDict#
Get a live copy of the feed
- Returns:
Feedparser dict
- get_next_by_date_checked(*, field=<django.db.models.fields.DateTimeField: date_checked>, is_next=True, **kwargs)#
- get_next_by_date_cutoff(*, field=<django.db.models.fields.DateTimeField: date_cutoff>, is_next=True, **kwargs)#
- get_next_by_date_updated(*, field=<django.db.models.fields.DateTimeField: date_updated>, is_next=True, **kwargs)#
- get_previous_by_date_checked(*, field=<django.db.models.fields.DateTimeField: date_checked>, is_next=False, **kwargs)#
- get_previous_by_date_cutoff(*, field=<django.db.models.fields.DateTimeField: date_cutoff>, is_next=False, **kwargs)#
- get_previous_by_date_updated(*, field=<django.db.models.fields.DateTimeField: date_updated>, is_next=False, **kwargs)#
- id#
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- classmethod load_from_configuration() None#
Load all podcasts from the configuration into the DB
- classmethod make_id(*, name: str) str#
ID factory
- Parameters:
name – Name of the podcast
- Returns:
ID for an instance
- name#
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- objects: Manager = <django.db.models.manager.Manager object>#
- update() None#
Update this podcast
- url_artwork#
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- url_feed#
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- disco.models.generate_hash(*args) str#
Generate a hash from the provided arguments.
- Parameters:
args – Arguments to hash
- Returns:
Hash as hex string
disco.paths module#
No module description available.
disco.settings module#
No module description available.
disco.tryouts module#
No module description available.