From 50b41b46781fe3595db18bb89711f4100af2d857 Mon Sep 17 00:00:00 2001 From: JR Date: Mon, 17 Jul 2023 22:37:15 +0200 Subject: [PATCH] notes -> note, quotes -> quote, webtitles -> webtitle ...and chanqueries -> chanquery. Use the singular form everywhere. Configuration files should not break. --- dub.sdl | 8 +- source/kameloso/configreader.d | 22 ++++++ source/kameloso/plugins/{notes.d => note.d} | 72 ++++++++--------- source/kameloso/plugins/printer/base.d | 2 +- source/kameloso/plugins/{quotes.d => quote.d} | 78 +++++++++---------- source/kameloso/plugins/seen.d | 4 +- .../services/{chanqueries.d => chanquery.d} | 36 ++++----- source/kameloso/plugins/services/package.d | 2 +- .../plugins/{webtitles.d => webtitle.d} | 40 +++++----- 9 files changed, 143 insertions(+), 121 deletions(-) rename source/kameloso/plugins/{notes.d => note.d} (90%) rename source/kameloso/plugins/{quotes.d => quote.d} (95%) rename source/kameloso/plugins/services/{chanqueries.d => chanquery.d} (93%) rename source/kameloso/plugins/{webtitles.d => webtitle.d} (96%) diff --git a/dub.sdl b/dub.sdl index 8c7950eb0a..399251508c 100644 --- a/dub.sdl +++ b/dub.sdl @@ -33,17 +33,17 @@ versions \ "WithChatbotPlugin" \ "WithCounterPlugin" \ "WithHelpPlugin" \ - "WithNotesPlugin" \ + "WithNotePlugin" \ "WithOnelinerPlugin" \ "WithPipelinePlugin" \ "WithPrinterPlugin" \ - "WithQuotesPlugin" \ + "WithQuotePlugin" \ "WithSedReplacePlugin" \ "WithSeenPlugin" \ "WithStopwatchPlugin" \ "WithPollPlugin" \ "WithTimerPlugin" \ - "WithWebtitlesPlugin" \ + "WithWebtitlePlugin" \ "WithTimePlugin" \ "WithBashPlugin" //"WithSamePlugin" @@ -55,7 +55,7 @@ versions \ */ versions \ "WithCTCPService" \ - "WithChanQueriesService" \ + "WithChanQueryService" \ "WithConnectService" \ "WithPersistenceService" diff --git a/source/kameloso/configreader.d b/source/kameloso/configreader.d index 2c3c404727..645fe5fd25 100644 --- a/source/kameloso/configreader.d +++ b/source/kameloso/configreader.d @@ -133,15 +133,37 @@ auto configurationText(const string configFile) import std.array : replace; import std.string : chomp; + // Ideally we'd do this, but it increases compilation memory by ~15 Mb + /*return configFile + .readText + .substitute( + "[Notes]\n", "[Note]\n", + "[Notes]\r\n", "[Note]\r\n", + "[Votes]\n", "[Poll]\n", + "[Votes]\r\n", "[Poll]\r\n", + "[Quotes]\n", "[Quote]\n", + "[Quotes]\r\n", "[Quote]\r\n", + "[TwitchBot]\n", "[Twitch]\n", + "[TwitchBot]\r\n", "[Twitch]\r\n", + "[Oneliners]\n", "[Oneliner]\n", + "[Oneliners]\r\n", "[Oneliner]\r\n") + .to!string + .chomp;*/ + return configFile .readText + .replace("[Notes]\n", "[Note]\n") + .replace("[Notes]\r\n", "[Note]\r\n") .replace("[Votes]\n", "[Poll]\n") .replace("[Votes]\r\n", "[Poll]\r\n") + .replace("[Quotes]\n", "[Quote]\n") + .replace("[Quotes]\r\n", "[Quote]\r\n") .replace("[TwitchBot]\n", "[Twitch]\n") .replace("[TwitchBot]\r\n", "[Twitch]\r\n") .replace("[Oneliners]\n", "[Oneliner]\n") .replace("[Oneliners]\r\n", "[Oneliner]\r\n") .chomp; + } catch (Exception e) { diff --git a/source/kameloso/plugins/notes.d b/source/kameloso/plugins/note.d similarity index 90% rename from source/kameloso/plugins/notes.d rename to source/kameloso/plugins/note.d index 1c00586fd0..84c4b64ca8 100644 --- a/source/kameloso/plugins/notes.d +++ b/source/kameloso/plugins/note.d @@ -1,5 +1,5 @@ /++ - The Notes plugin allows for storing notes to offline users, to be replayed + The Note plugin allows for storing notes to offline users, to be replayed when they next join the channel. If a note is left in a channel, it is stored as a note under that channel @@ -12,7 +12,7 @@ but anything will trigger private message playback. See_Also: - https://github.com/zorael/kameloso/wiki/Current-plugins#notes, + https://github.com/zorael/kameloso/wiki/Current-plugins#note, [kameloso.plugins.common.core], [kameloso.plugins.common.misc] @@ -22,9 +22,9 @@ Authors: [JR](https://github.com/zorael) +/ -module kameloso.plugins.notes; +module kameloso.plugins.note; -version(WithNotesPlugin): +version(WithNotePlugin): private: @@ -36,21 +36,21 @@ import kameloso.messaging; import dialect.defs; import std.typecons : Flag, No, Yes; -version(WithChanQueriesService) {} +version(WithChanQueryService) {} else { - pragma(msg, "Warning: The `Notes` plugin will work but not well without the `ChanQueries` service."); + pragma(msg, "Warning: The `Note` plugin will work but not well without the `ChanQuery` service."); } mixin MinimalAuthentication; -mixin PluginRegistration!NotesPlugin; +mixin PluginRegistration!NotePlugin; -// NotesSettings +// NoteSettings /++ - Notes plugin settings. + Note plugin settings. +/ -@Settings struct NotesSettings +@Settings struct NoteSettings { /++ Toggles whether or not the plugin should react to events at all. @@ -155,7 +155,7 @@ public: .permissionsRequired(Permissions.anyone) .channelPolicy(ChannelPolicy.home) ) -void onJoinOrAccount(NotesPlugin plugin, const ref IRCEvent event) +void onJoinOrAccount(NotePlugin plugin, const ref IRCEvent event) { version(TwitchSupport) { @@ -173,7 +173,7 @@ void onJoinOrAccount(NotesPlugin plugin, const ref IRCEvent event) // onChannelMessage /++ Plays back notes upon someone saying something in the channel, provided - [NotesSettings.playBackOnAnyActivity] is set. + [NoteSettings.playBackOnAnyActivity] is set. +/ @(IRCEventHandler() .onEvent(IRCEvent.Type.CHAN) @@ -183,9 +183,9 @@ void onJoinOrAccount(NotesPlugin plugin, const ref IRCEvent event) .channelPolicy(ChannelPolicy.home) .chainable(true) ) -void onChannelMessage(NotesPlugin plugin, const ref IRCEvent event) +void onChannelMessage(NotePlugin plugin, const ref IRCEvent event) { - if (plugin.notesSettings.playBackOnAnyActivity || + if (plugin.noteSettings.playBackOnAnyActivity || (plugin.state.server.daemon == IRCServer.Daemon.twitch)) { playbackNotes(plugin, event); @@ -220,7 +220,7 @@ version(TwitchSupport) .channelPolicy(ChannelPolicy.home) .chainable(true) ) -void onTwitchChannelEvent(NotesPlugin plugin, const ref IRCEvent event) +void onTwitchChannelEvent(NotePlugin plugin, const ref IRCEvent event) { // No need to check whether we're on Twitch playbackNotes(plugin, event); @@ -235,7 +235,7 @@ void onTwitchChannelEvent(NotesPlugin plugin, const ref IRCEvent event) Do nothing if [kameloso.pods.CoreSettings.eagerLookups|CoreSettings.eagerLookups] is true, - as we'd collide with ChanQueries' queries. + as we'd collide with ChanQuery queries. Passes `Yes.background` to [playbackNotes] to ensure it does low-priority background WHOIS queries. @@ -244,7 +244,7 @@ void onTwitchChannelEvent(NotesPlugin plugin, const ref IRCEvent event) .onEvent(IRCEvent.Type.RPL_WHOREPLY) .channelPolicy(ChannelPolicy.home) ) -void onWhoReply(NotesPlugin plugin, const ref IRCEvent event) +void onWhoReply(NotePlugin plugin, const ref IRCEvent event) { if (plugin.state.settings.eagerLookups) return; playbackNotes(plugin, event, Yes.background); @@ -261,12 +261,12 @@ void onWhoReply(NotesPlugin plugin, const ref IRCEvent event) member is empty, only private message ones. Params: - plugin = The current [NotesPlugin]. + plugin = The current [NotePlugin]. event = The triggering [dialect.defs.IRCEvent|IRCEvent]. background = Whether or not to issue WHOIS queries as low-priority background messages. +/ void playbackNotes( - NotesPlugin plugin, + NotePlugin plugin, const /*ref*/ IRCEvent event, const Flag!"background" background = No.background) { @@ -296,14 +296,14 @@ void playbackNotes( Plays back notes. Implementation function. Params: - plugin = The current [NotesPlugin]. + plugin = The current [NotePlugin]. channelName = The name of the channel in which the playback is to take place, or an empty string if it's supposed to take place in a private message. user = [dialect.defs.IRCUser|IRCUser] to replay notes for. background = Whether or not to issue WHOIS queries as low-priority background messages. +/ void playbackNotesImpl( - NotesPlugin plugin, + NotePlugin plugin, const string channelName, const IRCUser user, const Flag!"background" background) @@ -407,7 +407,7 @@ void playbackNotesImpl( .addSyntax("$command [nickname] [note text]") ) ) -void onCommandAddNote(NotesPlugin plugin, const ref IRCEvent event) +void onCommandAddNote(NotePlugin plugin, const ref IRCEvent event) { import kameloso.plugins.common.misc : nameOf; import lu.string : SplitResults, beginsWith, splitInto, stripped; @@ -452,12 +452,12 @@ void onCommandAddNote(NotesPlugin plugin, const ref IRCEvent event) // onWelcome /++ - Initialises the Notes plugin. Loads the notes from disk. + Initialises the Note plugin. Loads the notes from disk. +/ @(IRCEventHandler() .onEvent(IRCEvent.Type.RPL_WELCOME) ) -void onWelcome(NotesPlugin plugin) +void onWelcome(NotePlugin plugin) { loadNotes(plugin); } @@ -465,9 +465,9 @@ void onWelcome(NotesPlugin plugin) // saveNotes /++ - Saves notes to disk, to the [NotesPlugin.notesFile] JSON file. + Saves notes to disk, to the [NotePlugin.notesFile] JSON file. +/ -void saveNotes(NotesPlugin plugin) +void saveNotes(NotePlugin plugin) { import lu.json : JSONStorage; import std.json : JSONType; @@ -500,9 +500,9 @@ void saveNotes(NotesPlugin plugin) // loadNotes /++ - Loads notes from disk into [NotesPlugin.notes]. + Loads notes from disk into [NotePlugin.notes]. +/ -void loadNotes(NotesPlugin plugin) +void loadNotes(NotePlugin plugin) { import lu.json : JSONStorage; @@ -531,7 +531,7 @@ void loadNotes(NotesPlugin plugin) /++ Reloads notes from disk. +/ -void reload(NotesPlugin plugin) +void reload(NotePlugin plugin) { loadNotes(plugin); } @@ -541,7 +541,7 @@ void reload(NotesPlugin plugin) /++ Ensures that there is a notes file, creating one if there isn't. +/ -void initResources(NotesPlugin plugin) +void initResources(NotePlugin plugin) { import lu.json : JSONStorage; import std.json : JSONException; @@ -573,21 +573,21 @@ void initResources(NotesPlugin plugin) public: -// NotesPlugin +// NotePlugin /++ - The Notes plugin, which allows people to leave messages to each other, + The Note plugin, which allows people to leave messages to each other, for offline communication and such. +/ -final class NotesPlugin : IRCPlugin +final class NotePlugin : IRCPlugin { private: import lu.json : JSONStorage; - // notesSettings + // noteSettings /++ - All Notes plugin settings gathered. + All Note plugin settings gathered. +/ - NotesSettings notesSettings; + NoteSettings noteSettings; // notes /++ diff --git a/source/kameloso/plugins/printer/base.d b/source/kameloso/plugins/printer/base.d index 41eb6bcc97..3bdd03b2bb 100644 --- a/source/kameloso/plugins/printer/base.d +++ b/source/kameloso/plugins/printer/base.d @@ -721,7 +721,7 @@ void teardown(PrinterPlugin plugin) /++ Receives a passed [kameloso.thread.Boxed|Boxed] instance with the "`printer`" header, listening for cues to ignore the next events caused by the - [kameloso.plugins.services.chanqueries.ChanQueriesService|ChanQueriesService] + [kameloso.plugins.services.chanquery.ChanQueryService|ChanQueryService] querying current channel for information on the channels and their users. Params: diff --git a/source/kameloso/plugins/quotes.d b/source/kameloso/plugins/quote.d similarity index 95% rename from source/kameloso/plugins/quotes.d rename to source/kameloso/plugins/quote.d index b2db3713ee..7061c7bed8 100644 --- a/source/kameloso/plugins/quotes.d +++ b/source/kameloso/plugins/quote.d @@ -1,11 +1,11 @@ /++ - The Quotes plugin allows for saving and replaying user quotes. + The Quote plugin allows for saving and replaying user quotes. On Twitch, the commands do not take a nickname parameter; instead the owner of the channel (the broadcaster) is assumed to be the target. See_Also: - https://github.com/zorael/kameloso/wiki/Current-plugins#quotes, + https://github.com/zorael/kameloso/wiki/Current-plugins#quote, [kameloso.plugins.common.core], [kameloso.plugins.common.misc] @@ -15,9 +15,9 @@ Authors: [JR](https://github.com/zorael) +/ -module kameloso.plugins.quotes; +module kameloso.plugins.quote; -version(WithQuotesPlugin): +version(WithQuotePlugin): private: @@ -29,17 +29,17 @@ import kameloso.messaging; import dialect.defs; mixin UserAwareness; -mixin PluginRegistration!QuotesPlugin; +mixin PluginRegistration!QuotePlugin; -// QuotesSettings +// QuoteSettings /++ - All settings for a Quotes plugin, gathered in a struct. + All settings for a Quote plugin, gathered in a struct. +/ -@Settings struct QuotesSettings +@Settings struct QuoteSettings { /++ - Whether or not the Quotes plugin should react to events at all. + Whether or not the Quote plugin should react to events at all. +/ @Enabler bool enabled = true; @@ -128,7 +128,7 @@ public: .addSyntax("Elsewhere: $command [nickname] [#index]") ) ) -void onCommandQuote(QuotesPlugin plugin, const ref IRCEvent event) +void onCommandQuote(QuotePlugin plugin, const ref IRCEvent event) { import dialect.common : isValidNickname; import lu.string : stripped; @@ -268,7 +268,7 @@ void onCommandQuote(QuotesPlugin plugin, const ref IRCEvent event) .addSyntax("Elsewhere: $command [nickname] [new quote]") ) ) -void onCommandAddQuote(QuotesPlugin plugin, const ref IRCEvent event) +void onCommandAddQuote(QuotePlugin plugin, const ref IRCEvent event) { import lu.string : stripped, strippedRight, unquoted; import std.format : format; @@ -357,7 +357,7 @@ void onCommandAddQuote(QuotesPlugin plugin, const ref IRCEvent event) .addSyntax("Elsewhere: $command [nickname] [index] [new quote text]") ) ) -void onCommandModQuote(QuotesPlugin plugin, const ref IRCEvent event) +void onCommandModQuote(QuotePlugin plugin, const ref IRCEvent event) { import lu.string : SplitResults, splitInto, stripped, strippedRight, unquoted; import std.conv : ConvException, to; @@ -474,7 +474,7 @@ void onCommandModQuote(QuotesPlugin plugin, const ref IRCEvent event) .addSyntax("$command [source nickname] [target nickname]") ) ) -void onCommandMergeQuotes(QuotesPlugin plugin, const ref IRCEvent event) +void onCommandMergeQuotes(QuotePlugin plugin, const ref IRCEvent event) { import dialect.common : isValidNickname; import lu.string : SplitResults, plurality, splitInto, stripped; @@ -549,7 +549,7 @@ void onCommandMergeQuotes(QuotesPlugin plugin, const ref IRCEvent event) .addSyntax("Elsewhere: $command [nickname] [index]") ) ) -void onCommandDelQuote(QuotesPlugin plugin, const ref IRCEvent event) +void onCommandDelQuote(QuotePlugin plugin, const ref IRCEvent event) { import lu.string : SplitResults, splitInto, stripped; import std.algorithm.mutation : SwapStrategy, remove; @@ -638,14 +638,14 @@ void onCommandDelQuote(QuotesPlugin plugin, const ref IRCEvent event) Sends a [Quote] to a channel. Params: - plugin = The current [QuotesPlugin]. + plugin = The current [QuotePlugin]. quote = The [Quote] to report. channelName = Name of the channel to send to. nickname = Nickname whose quote it is. index = Index of the quote in the local storage. +/ void sendQuoteToChannel( - QuotesPlugin plugin, + QuotePlugin plugin, const Quote quote, const string channelName, const string nickname, @@ -680,12 +680,12 @@ void sendQuoteToChannel( // onWelcome /++ - Initialises the passed [QuotesPlugin]. Loads the quotes from disk. + Initialises the passed [QuotePlugin]. Loads the quotes from disk. +/ @(IRCEventHandler() .onEvent(IRCEvent.Type.RPL_WELCOME) ) -void onWelcome(QuotesPlugin plugin) +void onWelcome(QuotePlugin plugin) { loadQuotes(plugin); } @@ -705,13 +705,13 @@ private: Called when a supplied quote index was out of range. Params: - plugin = The current [QuotesPlugin]. + plugin = The current [QuotePlugin]. event = The original triggering [dialect.defs.IRCEvent|IRCEvent]. indexGiven = The index given by the triggering user. upperBound = The actual upper bounds that `indexGiven` failed to fall within. +/ static void sendIndexOutOfRange( - QuotesPlugin plugin, + QuotePlugin plugin, const ref IRCEvent event, const ptrdiff_t indexGiven, const size_t upperBound) @@ -726,12 +726,12 @@ private: Called when a passed nickname contained invalid characters (or similar). Params: - plugin = The current [QuotesPlugin]. + plugin = The current [QuotePlugin]. event = The original triggering [dialect.defs.IRCEvent|IRCEvent]. nickname = The would-be nickname given by the triggering user. +/ static void sendInvalidNickname( - QuotesPlugin plugin, + QuotePlugin plugin, const ref IRCEvent event, const string nickname) { @@ -745,12 +745,12 @@ private: Called when there were no quotes to be found for a given nickname. Params: - plugin = The current [QuotesPlugin]. + plugin = The current [QuotePlugin]. event = The original triggering [dialect.defs.IRCEvent|IRCEvent]. nickname = The nickname given by the triggering user. +/ static void sendNoQuotesForNickname( - QuotesPlugin plugin, + QuotePlugin plugin, const ref IRCEvent event, const string nickname) { @@ -775,11 +775,11 @@ private: Called when a non-integer or negative integer was given as index. Params: - plugin = The current [QuotesPlugin]. + plugin = The current [QuotePlugin]. event = The original triggering [dialect.defs.IRCEvent|IRCEvent]. +/ static void sendIndexMustBePositiveNumber( - QuotesPlugin plugin, + QuotePlugin plugin, const ref IRCEvent event) { enum message = "Index must be a positive number."; @@ -867,7 +867,7 @@ auto getQuoteByIndexString( Fetches a [Quote] whose line matches the passed search terms. Params: - plugin = The current [QuotesPlugin]. + plugin = The current [QuotePlugin]. quotes = Array of [Quote]s to get a specific one from based on search terms. searchTermsCased = Search terms to apply to the `quotes` array, with letters in original casing. @@ -877,7 +877,7 @@ auto getQuoteByIndexString( A [Quote] whose line matches the passed search terms. +/ Quote getQuoteBySearchTerms( - QuotesPlugin plugin, + QuotePlugin plugin, const Quote[] quotes, const string searchTermsCased, out size_t index) @@ -951,7 +951,7 @@ Quote getQuoteBySearchTerms( { if (!flattenedQuote.contains(searchTerms)) continue; - if (plugin.quotesSettings.alwaysPickFirstMatch) + if (plugin.quoteSettings.alwaysPickFirstMatch) { index = i; return quotes[index]; @@ -977,7 +977,7 @@ Quote getQuoteBySearchTerms( { if (!stripBoth(flattenedQuote).contains(strippedSearchTerms)) continue; - if (plugin.quotesSettings.alwaysPickFirstMatch) + if (plugin.quoteSettings.alwaysPickFirstMatch) { index = i; return quotes[index]; @@ -1131,7 +1131,7 @@ unittest /++ Loads quotes from disk into an associative array of [Quote]s. +/ -void loadQuotes(QuotesPlugin plugin) +void loadQuotes(QuotePlugin plugin) { import lu.json : JSONStorage; import std.json : JSONException; @@ -1162,7 +1162,7 @@ void loadQuotes(QuotesPlugin plugin) /++ Saves quotes to disk in JSON file format. +/ -void saveQuotes(QuotesPlugin plugin) +void saveQuotes(QuotePlugin plugin) { import lu.json : JSONStorage; @@ -1313,7 +1313,7 @@ final class NoQuotesSearchMatchException : Exception /++ Reads and writes the file of quotes to disk, ensuring that it's there. +/ -void initResources(QuotesPlugin plugin) +void initResources(QuotePlugin plugin) { import lu.json : JSONStorage; import lu.string : beginsWith; @@ -1374,7 +1374,7 @@ void initResources(QuotesPlugin plugin) /++ Reloads the JSON quotes from disk. +/ -void reload(QuotesPlugin plugin) +void reload(QuotePlugin plugin) { loadQuotes(plugin); } @@ -1383,24 +1383,24 @@ void reload(QuotesPlugin plugin) public: -// QuotesPlugin +// QuotePlugin /++ - The Quotes plugin provides the ability to save and replay user quotes. + The Quote plugin provides the ability to save and replay user quotes. These are not currently automatically replayed, such as when a user joins, but can rather be actively queried by use of the `quote` verb. It was historically part of [kameloso.plugins.chatbot.ChatbotPlugin|ChatbotPlugin]. +/ -final class QuotesPlugin : IRCPlugin +final class QuotePlugin : IRCPlugin { private: import lu.json : JSONStorage; /++ - All Quotes plugin settings gathered. + All Quote plugin settings gathered. +/ - QuotesSettings quotesSettings; + QuoteSettings quoteSettings; /++ The in-memory JSON storage of all user quotes. diff --git a/source/kameloso/plugins/seen.d b/source/kameloso/plugins/seen.d index 48410d6ddb..a67fc9b24c 100644 --- a/source/kameloso/plugins/seen.d +++ b/source/kameloso/plugins/seen.d @@ -10,7 +10,7 @@ minutes. We will rely on the - [kameloso.plugins.services.chanqueries.ChanQueriesService|ChanQueriesService] to query + [kameloso.plugins.services.chanquery.ChanQueryService|ChanQueryService] to query channels for full lists of users upon joining new ones, including the ones we join upon connecting. Elsewise, a completely silent user will never be recorded as having been seen, as they would never be triggering any of @@ -682,7 +682,7 @@ void onNick(SeenPlugin plugin, const ref IRCEvent event) A WHO request enumerates all members in a channel. It returns several replies, one event per each user in the channel. The - [kameloso.plugins.services.chanqueries.ChanQueriesService|ChanQueriesService] services + [kameloso.plugins.services.chanquery.ChanQueryService|ChanQueryService] services instigates this shortly after having joined one, as a service to other plugins. +/ @(IRCEventHandler() diff --git a/source/kameloso/plugins/services/chanqueries.d b/source/kameloso/plugins/services/chanquery.d similarity index 93% rename from source/kameloso/plugins/services/chanqueries.d rename to source/kameloso/plugins/services/chanquery.d index ba081dc119..59c41bd472 100644 --- a/source/kameloso/plugins/services/chanqueries.d +++ b/source/kameloso/plugins/services/chanquery.d @@ -1,5 +1,5 @@ /++ - The Channel Queries service queries channels for information about them (in + The Channel Query service queries channels for information about them (in terms of topic and modes) as well as their lists of participants. It does this shortly after having joined a channel, as a service to all other plugins, so they don't each have to independently do it themselves. @@ -19,9 +19,9 @@ Authors: [JR](https://github.com/zorael) +/ -module kameloso.plugins.services.chanqueries; +module kameloso.plugins.services.chanquery; -version(WithChanQueriesService): +version(WithChanQueryService): private: @@ -76,7 +76,7 @@ enum ChannelState : ubyte .onEvent(IRCEvent.Type.PING) .fiber(true) ) -void startChannelQueries(ChanQueriesService service) +void startChannelQueries(ChanQueryService service) { import kameloso.thread : CarryingFiber, ThreadMessage, boxed; import kameloso.messaging : Message, mode, raw; @@ -114,7 +114,7 @@ void startChannelQueries(ChanQueriesService service) service.querying = false; // "Unlock" } - static immutable secondsBetween = ChanQueriesService.secondsBetween.seconds; + static immutable secondsBetween = ChanQueryService.secondsBetween.seconds; chanloop: foreach (immutable i, immutable channelName; querylist) @@ -370,14 +370,14 @@ void startChannelQueries(ChanQueriesService service) // onSelfjoin /++ - Adds a channel we join to the internal [ChanQueriesService.channels] list of + Adds a channel we join to the internal [ChanQueryService.channels] list of channel states. +/ @(IRCEventHandler() .onEvent(IRCEvent.Type.SELFJOIN) .channelPolicy(omniscientChannelPolicy) ) -void onSelfjoin(ChanQueriesService service, const ref IRCEvent event) +void onSelfjoin(ChanQueryService service, const ref IRCEvent event) { service.channelStates[event.channel] = ChannelState.unset; } @@ -385,7 +385,7 @@ void onSelfjoin(ChanQueriesService service, const ref IRCEvent event) // onSelfpart /++ - Removes a channel we part from the internal [ChanQueriesService.channels] + Removes a channel we part from the internal [ChanQueryService.channels] list of channel states. +/ @(IRCEventHandler() @@ -393,7 +393,7 @@ void onSelfjoin(ChanQueriesService service, const ref IRCEvent event) .onEvent(IRCEvent.Type.SELFKICK) .channelPolicy(omniscientChannelPolicy) ) -void onSelfpart(ChanQueriesService service, const ref IRCEvent event) +void onSelfpart(ChanQueryService service, const ref IRCEvent event) { service.channelStates.remove(event.channel); } @@ -409,7 +409,7 @@ void onSelfpart(ChanQueriesService service, const ref IRCEvent event) .onEvent(IRCEvent.Type.RPL_TOPIC) .channelPolicy(omniscientChannelPolicy) ) -void onTopic(ChanQueriesService service, const ref IRCEvent event) +void onTopic(ChanQueryService service, const ref IRCEvent event) { service.channelStates[event.channel] |= ChannelState.topicKnown; } @@ -426,7 +426,7 @@ void onTopic(ChanQueriesService service, const ref IRCEvent event) .channelPolicy(omniscientChannelPolicy) .fiber(true) ) -void onEndOfNames(ChanQueriesService service) +void onEndOfNames(ChanQueryService service) { if (!service.querying && service.queriedAtLeastOnce) { @@ -443,7 +443,7 @@ void onEndOfNames(ChanQueriesService service) .onEvent(IRCEvent.Type.RPL_MYINFO) .fiber(true) ) -void onMyInfo(ChanQueriesService service) +void onMyInfo(ChanQueryService service) { delay(service, service.timeBeforeInitialQueries, Yes.yield); startChannelQueries(service); @@ -453,13 +453,13 @@ void onMyInfo(ChanQueriesService service) // onNoSuchChannel /++ If we get an error that a channel doesn't exist, remove it from - [ChanQueriesService.channelStates|channelStates]. This stops it from being + [ChanQueryService.channelStates|channelStates]. This stops it from being queried in [startChannelQueries]. +/ @(IRCEventHandler() .onEvent(IRCEvent.Type.ERR_NOSUCHCHANNEL) ) -void onNoSuchChannel(ChanQueriesService service, const ref IRCEvent event) +void onNoSuchChannel(ChanQueryService service, const ref IRCEvent event) { service.channelStates.remove(event.channel); } @@ -477,17 +477,17 @@ else mixin UserAwareness!channelPolicy; mixin ChannelAwareness!channelPolicy; -mixin PluginRegistration!(ChanQueriesService, -10.priority); +mixin PluginRegistration!(ChanQueryService, -10.priority); public: -// ChanQueriesService +// ChanQueryService /++ - The Channel Queries service queries channels for information about them (in + The Channel Query service queries channels for information about them (in terms of topic and modes) as well as its list of participants. +/ -final class ChanQueriesService : IRCPlugin +final class ChanQueryService : IRCPlugin { private: import core.time : seconds; diff --git a/source/kameloso/plugins/services/package.d b/source/kameloso/plugins/services/package.d index 45e1cf4e9f..b81c2b0509 100644 --- a/source/kameloso/plugins/services/package.d +++ b/source/kameloso/plugins/services/package.d @@ -4,7 +4,7 @@ Removing or disabling any of these may yield adverse results. See_Also: - [kameloso.plugins.services.chanqueries] + [kameloso.plugins.services.chanquery] [kameloso.plugins.services.connect] [kameloso.plugins.services.ctcp] [kameloso.plugins.services.persistence] diff --git a/source/kameloso/plugins/webtitles.d b/source/kameloso/plugins/webtitle.d similarity index 96% rename from source/kameloso/plugins/webtitles.d rename to source/kameloso/plugins/webtitle.d index 8f8d84aa01..a8bf2f5687 100644 --- a/source/kameloso/plugins/webtitles.d +++ b/source/kameloso/plugins/webtitle.d @@ -1,12 +1,12 @@ /++ - The Webtitles plugin catches URLs pasted in a channel, follows them and + The Webtitle plugin catches URLs pasted in a channel, follows them and reports back the title of the web page that was linked to. It has no bot commands; everything is done by automatically scanning channel and private query messages for things that look like links. See_Also: - https://github.com/zorael/kameloso/wiki/Current-plugins#webtitles, + https://github.com/zorael/kameloso/wiki/Current-plugins#webtitle, [kameloso.plugins.common.core], [kameloso.plugins.common.misc] @@ -16,9 +16,9 @@ Authors: [JR](https://github.com/zorael) +/ -module kameloso.plugins.webtitles; +module kameloso.plugins.webtitle; -version(WithWebtitlesPlugin): +version(WithWebtitlePlugin): private: @@ -44,11 +44,11 @@ static immutable descriptionExemptions = ]; -// WebtitlesSettings +// WebtitleSettings /++ All Webtitles settings, gathered in a struct. +/ -@Settings struct WebtitlesSettings +@Settings struct WebtitleSettings { /++ Toggles whether or not the plugin should react to events at all. @@ -147,7 +147,7 @@ struct TitleLookupRequest .permissionsRequired(Permissions.ignore) .channelPolicy(ChannelPolicy.home) ) -void onMessage(WebtitlesPlugin plugin, const ref IRCEvent event) +void onMessage(WebtitlePlugin plugin, const ref IRCEvent event) { import kameloso.common : findURLs; import lu.string : beginsWith, strippedLeft; @@ -182,11 +182,11 @@ void onMessage(WebtitlesPlugin plugin, const ref IRCEvent event) It accesses the cache of already looked up addresses to speed things up. Params: - plugin = The current [WebtitlesPlugin]. + plugin = The current [WebtitlePlugin]. event = The [dialect.defs.IRCEvent|IRCEvent] that instigated the lookup. urls = `string[]` of URLs to look up. +/ -void lookupURLs(WebtitlesPlugin plugin, const /*ref*/ IRCEvent event, string[] urls) +void lookupURLs(WebtitlePlugin plugin, const /*ref*/ IRCEvent event, string[] urls) { import kameloso.common : logger; import kameloso.thread : ThreadMessage; @@ -249,7 +249,7 @@ void lookupURLs(WebtitlesPlugin plugin, const /*ref*/ IRCEvent event, string[] u cast(void)spawn(&worker, cast(shared)request, plugin.cache, (i * plugin.delayMsecs), - cast(Flag!"descriptions")plugin.webtitlesSettings.descriptions, + cast(Flag!"descriptions")plugin.webtitleSettings.descriptions, plugin.state.connSettings.caBundleFile); } @@ -290,7 +290,7 @@ void worker( version(Posix) { import kameloso.thread : setThreadName; - setThreadName("webtitles"); + setThreadName("webtitle"); } // Set the global settings so messaging functions don't segfault us @@ -918,13 +918,13 @@ void prune(shared TitleLookupResults[string] cache, const uint expireSeconds) Versioned out until we need it, such as for selective Twitch link blocks. Params: - plugin = The current [WebtitlesPlugin]. + plugin = The current [WebtitlePlugin]. header = String header describing the passed content payload. content = The boxed content of the message. +/ version(none) void onBusMessage( - WebtitlesPlugin plugin, + WebtitlePlugin plugin, const string header, shared Sendable content) { @@ -932,7 +932,7 @@ void onBusMessage( // Don't return if disabled? // Do we want to be able to serve other plugins anyway? - if (header != "webtitles") return; + if (header != "webtitle") return; auto message = cast(Boxed!IRCEvent)content; assert(message, "Incorrectly cast message: " ~ typeof(message).stringof); @@ -947,7 +947,7 @@ void onBusMessage( Just assign an entry and remove it. +/ -void initialise(WebtitlesPlugin plugin) +void initialise(WebtitlePlugin plugin) { // No need to synchronise this; no worker threads are running plugin.cache[string.init] = TitleLookupResults.init; @@ -956,24 +956,24 @@ void initialise(WebtitlesPlugin plugin) mixin MinimalAuthentication; -mixin PluginRegistration!WebtitlesPlugin; +mixin PluginRegistration!WebtitlePlugin; public: -// WebtitlesPlugin +// WebtitlePlugin /++ - The Webtitles plugin catches HTTP URL links in messages, connects to + The Webtitle plugin catches HTTP URL links in messages, connects to their servers and and streams the web page itself, looking for the web page's title. This is then reported to the originating channel or personal query. +/ -final class WebtitlesPlugin : IRCPlugin +final class WebtitlePlugin : IRCPlugin { private: /++ All Webtitles options gathered. +/ - WebtitlesSettings webtitlesSettings; + WebtitleSettings webtitleSettings; /++ Cache of recently looked-up web titles.