Skip to content

Commit

Permalink
notes -> note, quotes -> quote, webtitles -> webtitle
Browse files Browse the repository at this point in the history
...and chanqueries -> chanquery. Use the singular form everywhere.

Configuration files should not break.
  • Loading branch information
zorael committed Jul 17, 2023
1 parent 56e483f commit 50b41b4
Show file tree
Hide file tree
Showing 9 changed files with 143 additions and 121 deletions.
8 changes: 4 additions & 4 deletions dub.sdl
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -55,7 +55,7 @@ versions \
*/
versions \
"WithCTCPService" \
"WithChanQueriesService" \
"WithChanQueryService" \
"WithConnectService" \
"WithPersistenceService"

Expand Down
22 changes: 22 additions & 0 deletions source/kameloso/configreader.d
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down
72 changes: 36 additions & 36 deletions source/kameloso/plugins/notes.d → source/kameloso/plugins/note.d
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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]
Expand All @@ -22,9 +22,9 @@
Authors:
[JR](https://github.com/zorael)
+/
module kameloso.plugins.notes;
module kameloso.plugins.note;

version(WithNotesPlugin):
version(WithNotePlugin):

private:

Expand All @@ -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.
Expand Down Expand Up @@ -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)
{
Expand All @@ -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)
Expand All @@ -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);
Expand Down Expand Up @@ -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);
Expand All @@ -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.
Expand All @@ -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);
Expand All @@ -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)
{
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -452,22 +452,22 @@ 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);
}


// 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;
Expand Down Expand Up @@ -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;

Expand Down Expand Up @@ -531,7 +531,7 @@ void loadNotes(NotesPlugin plugin)
/++
Reloads notes from disk.
+/
void reload(NotesPlugin plugin)
void reload(NotePlugin plugin)
{
loadNotes(plugin);
}
Expand All @@ -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;
Expand Down Expand Up @@ -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
/++
Expand Down
2 changes: 1 addition & 1 deletion source/kameloso/plugins/printer/base.d
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
Loading

0 comments on commit 50b41b4

Please sign in to comment.