Fixed some formatting issues.

This commit is contained in:
Storm Dragon 2025-03-31 20:51:39 -04:00
parent 75f6dd6f4c
commit e869bc4add

View File

@ -46,8 +46,7 @@ class Greet(callbacks.Plugin):
# Log event for debugging
if self.debugMode:
self._logDebug(irc, f"JOIN event detected: {nick} joined
{channel}")
self._logDebug(irc, f"JOIN event detected: {nick} joined {channel}")
# Don't greet ourselves
if nick == irc.nick:
@ -71,27 +70,22 @@ class Greet(callbacks.Plugin):
# Check if we've already greeted this user with this greeting
userKey = f"{nick.lower()}@{channel}"
if userKey in self.greetedUsers and channel in
self.greetedUsers[userKey]:
# If the greeting has changed since we last greeted this user, we
# should greet them again
if userKey in self.greetedUsers and channel in self.greetedUsers[userKey]:
# If the greeting has changed since we last greeted this user, we should greet them again
lastGreetingUsed = self.userGreetingVersion.get(userKey, "")
if greeting == lastGreetingUsed:
if self.debugMode:
self._logDebug(irc, f"User {nick} already greeted in this
session with current greeting")
self._logDebug(irc, f"User {nick} already greeted in this session with current greeting")
return
else:
if self.debugMode:
self._logDebug(irc, f"Greeting for {channel} has changed,
will greet {nick} again")
self._logDebug(irc, f"Greeting for {channel} has changed, will greet {nick} again")
# Get the timeout
timeout = self.registryValue('timeout', channel) or 3
if self.debugMode:
self._logDebug(irc, f"Will greet in {channel} after {timeout}s:
{greeting}")
self._logDebug(irc, f"Will greet in {channel} after {timeout}s: {greeting}")
# Mark this user as greeted in this channel
if userKey not in self.greetedUsers:
@ -104,8 +98,7 @@ will greet {nick} again")
# Use a closure to capture the current values
def sendGreeting(channelToGreet=channel, greetingMsg=greeting):
if self.debugMode:
self._logDebug(irc, f"Sending greeting in {channelToGreet}:
{greetingMsg}")
self._logDebug(irc, f"Sending greeting in {channelToGreet}: {greetingMsg}")
try:
# Make sure the channel is still valid when we send the message
if channelToGreet in irc.state.channels:
@ -122,15 +115,13 @@ will greet {nick} again")
try:
# Send to the owner via private message instead of to a channel
for owner in self.registryValue('owners') or []:
irc.queueMsg(ircmsgs.privmsg(owner, f"[GREET-DEBUG]
{message}"))
irc.queueMsg(ircmsgs.privmsg(owner, f"[GREET-DEBUG] {message}"))
return
# Fallback: send to the first available channel
for channel in list(irc.state.channels):
try:
irc.queueMsg(ircmsgs.privmsg(channel, f"[GREET-DEBUG]
{message}"))
irc.queueMsg(ircmsgs.privmsg(channel, f"[GREET-DEBUG] {message}"))
break
except:
continue
@ -215,11 +206,9 @@ greeted again
self.setRegistryValue('enabled', True, channel)
greeting = self.registryValue('message', channel)
if greeting:
irc.replySuccess(f"Greetings enabled for {channel}. Current
greeting: \"{greeting}\"")
irc.replySuccess(f"Greetings enabled for {channel}. Current greeting: \"{greeting}\"")
else:
irc.error(f"Greetings enabled for {channel}, but no greeting
message is set.")
irc.error(f"Greetings enabled for {channel}, but no greeting message is set.")
@wrap(['channel'])
def greetoff(self, irc, msg, args, channel):
@ -238,8 +227,7 @@ message is set.")
"""
self.setRegistryValue('message', '', channel)
self.setRegistryValue('enabled', False, channel)
irc.replySuccess(f"Greeting message cleared and disabled for
{channel}.")
irc.replySuccess(f"Greeting message cleared and disabled for {channel}.")
@wrap(['channel'])
def greetstatus(self, irc, msg, args, channel):
@ -256,15 +244,12 @@ message is set.")
self.greetedUsers[userKey])
if enabled and message:
irc.reply(f"Greetings are enabled for {channel}. Timeout: {timeout}
seconds. Message: \"{message}\"")
irc.reply(f"Greetings are enabled for {channel}. Timeout: {timeout} seconds. Message: \"{message}\"")
irc.reply(f"Users greeted in this session: {greetedCount}")
elif enabled and not message:
irc.reply(f"Greetings are enabled for {channel}, but no message is
set.")
irc.reply(f"Greetings are enabled for {channel}, but no message is set.")
else:
irc.reply(f"Greetings are disabled for {channel}. Message:
\"{message or 'None'}\"")
irc.reply(f"Greetings are disabled for {channel}. Message: \"{message or 'None'}\"")
@wrap(['channel', 'positiveInt'])
def greettimeout(self, irc, msg, args, channel, seconds):
@ -274,8 +259,7 @@ set.")
Default is 3 seconds.
"""
self.setRegistryValue('timeout', seconds, channel)
irc.replySuccess(f"Greeting timeout for {channel} set to {seconds}
seconds.")
irc.replySuccess(f"Greeting timeout for {channel} set to {seconds} seconds.")
@wrap(['channel', 'text'])
def greet(self, irc, msg, args, channel, text):
@ -321,11 +305,9 @@ again
if userKey in self.userGreetingVersion:
del self.userGreetingVersion[userKey]
irc.replySuccess(f"Greeting message for {channel} set to:
\"{text}\" (greeting history reset)")
irc.replySuccess(f"Greeting message for {channel} set to: \"{text}\" (greeting history reset)")
else:
irc.replySuccess(f"Greeting message for {channel} set to:
\"{text}\"")
irc.replySuccess(f"Greeting message for {channel} set to: \"{text}\"")
Class = Greet