Gotta return chan
now too
This commit is contained in:
parent
fc1aa11f8d
commit
d050de403e
2 changed files with 7 additions and 6 deletions
3
bot.py
3
bot.py
|
@ -211,11 +211,12 @@ class bot(bare.bot):
|
||||||
except IndexError:
|
except IndexError:
|
||||||
pass
|
pass
|
||||||
if action == "PRIVMSG":
|
if action == "PRIVMSG":
|
||||||
res = handlers.PRIVMSG(self, ircmsg)
|
res, chan = handlers.PRIVMSG(self, ircmsg)
|
||||||
if res == "reload":
|
if res == "reload":
|
||||||
reload(conf)
|
reload(conf)
|
||||||
reload(cmds)
|
reload(cmds)
|
||||||
reload(handlers)
|
reload(handlers)
|
||||||
|
self.msg("", chan) # type: ignore
|
||||||
elif action == "NICK":
|
elif action == "NICK":
|
||||||
name = ircmsg.split("!", 1)[0][1:]
|
name = ircmsg.split("!", 1)[0][1:]
|
||||||
if name == self.nick:
|
if name == self.nick:
|
||||||
|
|
10
handlers.py
10
handlers.py
|
@ -41,7 +41,7 @@ def CTCP(bot: bare.bot, msg: str) -> bool:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
||||||
def PRIVMSG(bot: bare.bot, msg: str) -> Union[None, str]:
|
def PRIVMSG(bot: bare.bot, msg: str) -> tuple[Union[None, str], Union[None, str]]:
|
||||||
# Format of ":[Nick]![ident]@[host|vhost] PRIVMSG [channel] :[message]”
|
# Format of ":[Nick]![ident]@[host|vhost] PRIVMSG [channel] :[message]”
|
||||||
name = msg.split("!", 1)[0][1:]
|
name = msg.split("!", 1)[0][1:]
|
||||||
if (name.startswith("saxjax") and bot.server == "efnet") or (
|
if (name.startswith("saxjax") and bot.server == "efnet") or (
|
||||||
|
@ -57,7 +57,7 @@ def PRIVMSG(bot: bare.bot, msg: str) -> Union[None, str]:
|
||||||
else:
|
else:
|
||||||
message = msg.split("PRIVMSG", 1)[1].split(":", 1)[1].strip()
|
message = msg.split("PRIVMSG", 1)[1].split(":", 1)[1].strip()
|
||||||
elif name == bot.nick:
|
elif name == bot.nick:
|
||||||
return # type: ignore
|
return None, None
|
||||||
else:
|
else:
|
||||||
message = msg.split("PRIVMSG", 1)[1].split(":", 1)[1].strip()
|
message = msg.split("PRIVMSG", 1)[1].split(":", 1)[1].strip()
|
||||||
chan = msg.split("PRIVMSG", 1)[1].split(":", 1)[0].strip()
|
chan = msg.split("PRIVMSG", 1)[1].split(":", 1)[0].strip()
|
||||||
|
@ -66,7 +66,7 @@ def PRIVMSG(bot: bare.bot, msg: str) -> Union[None, str]:
|
||||||
)
|
)
|
||||||
if len(name) > bot.nicklen:
|
if len(name) > bot.nicklen:
|
||||||
bot.log(f"Name too long ({len(name)} > {bot.nicklen})")
|
bot.log(f"Name too long ({len(name)} > {bot.nicklen})")
|
||||||
return # type: ignore
|
return None, None
|
||||||
elif chan not in bot.channels:
|
elif chan not in bot.channels:
|
||||||
bot.log(
|
bot.log(
|
||||||
f"Channel not in channels ({chan} not in {bot.channels})",
|
f"Channel not in channels ({chan} not in {bot.channels})",
|
||||||
|
@ -110,7 +110,7 @@ def PRIVMSG(bot: bare.bot, msg: str) -> Union[None, str]:
|
||||||
break
|
break
|
||||||
if not handled and conf.mfind(message, ["reload"]):
|
if not handled and conf.mfind(message, ["reload"]):
|
||||||
if name in bot.adminnames:
|
if name in bot.adminnames:
|
||||||
return "reload"
|
return "reload", chan
|
||||||
else:
|
else:
|
||||||
bot.msg(
|
bot.msg(
|
||||||
f"Sorry {name}, you don't have permission to use reload.",
|
f"Sorry {name}, you don't have permission to use reload.",
|
||||||
|
@ -137,7 +137,7 @@ def PRIVMSG(bot: bare.bot, msg: str) -> Union[None, str]:
|
||||||
)
|
)
|
||||||
bot.msg(f"[QUOTE] {sel}", chan)
|
bot.msg(f"[QUOTE] {sel}", chan)
|
||||||
mm.close()
|
mm.close()
|
||||||
return # type: ignore
|
return None, None
|
||||||
|
|
||||||
|
|
||||||
handles = {"PRIVMSG": PRIVMSG}
|
handles = {"PRIVMSG": PRIVMSG}
|
||||||
|
|
Loading…
Reference in a new issue