我使用IRC freenode服务器的当前配置:
BOT_PREFIX = '@'
BOT_PREFIX_OPTIONAL_ON_CHAT = True
BOT_ALT_PREFIXES = ('Err', "bot", "mybot", "botka", "errbot")
BOT_ALT_PREFIX_SEPARATORS = (':', ',', ';')
BOT_ALT_PREFIX_CASEINSENSITIVE = True我对IRC服务使用身份验证。
但是,当机器人登录时,它会遇到一个问题:当它将自己标识为NickServ时,它会收到来自NickServ的消息(包括它的nick ),并将它们当作命令(因为有BOT_PREFIX_OPTIONAL_ON_CHAT和BOT_ALT_PREFIXES)。然后,错误机器人向NickServ发送关于“错误命令”的错误消息,NickServ回复说它不理解“错误命令”给机器人的私有,然后它再次启动……
那么,在这些机器人通过这个对话吃掉所有互联网流量之前,我如何才能从这个对话中排除NickServ,或者让errbot不回复“错误命令”或任何其他解决方案?
目前,我在我的插件中使用脏黑客来掩盖来自NickServ的“无效命令”:
@botcmd()
def Invalid(self, msg, args):
if args.startswith("Invalid command."):
return这阻止了错误机器人回复NickServ。还需要使用
HIDE_RESTRICTED_COMMANDS = True
HIDE_RESTRICTED_ACCESS = True但我在寻找更好的解决方案。提前感谢!
来自机器人对话的日志:
22:40:06 DEBUG irc.client FROM SERVER: :NickServ!NickServ@services. NOTICE botka :This nickname is registered. Please choose a different nickname, or identify via /msg NickServ identify <passw
ord>.
22:40:06 DEBUG irc.client _dispatcher: all_raw_messages
22:40:06 DEBUG irc.client command: privnotice, source: NickServ!NickServ@services., target: botka, arguments: ['This nickname is registered. Please choose a different nickname, or identify via
\x02/msg NickServ identify <password>\x02.'], tags: None
22:40:06 DEBUG irc.client _dispatcher: privnotice
22:40:06 DEBUG errbot.core *** frm = NickServ!NickServ@services.
22:40:06 DEBUG errbot.core *** username = NickServ
22:40:06 DEBUG errbot.core *** text = This nickname is registered. Please choose a different nickname, or identify via /msg NickServ identify <password>.
22:40:06 DEBUG errbot.core Assuming 'This nickname is registered. Please choose a different nickname, or identify via /msg NickServ identify <password>.' to be a command because BOT_PREFIX_OPTIO
NAL_ON_CHAT is True
22:40:06 DEBUG errbot.core Command not found
22:40:06 DEBUG errbot.utils Elapsed 0.005545 since last call
22:40:06 DEBUG errbot.utils Wait 0.994455 due to rate limiting...
22:40:07 DEBUG irc.client TO SERVER: PRIVMSG NickServ :Command "This" / "This nickname" not found.
22:40:07 DEBUG errbot.core Triggering callback_message on Flows
............................skipped
22:40:07 DEBUG irc.client FROM SERVER: :NickServ!NickServ@services. NOTICE botka :You are now identified for botka.
22:40:07 DEBUG irc.client _dispatcher: all_raw_messages
22:40:07 DEBUG irc.client command: privnotice, source: NickServ!NickServ@services., target: botka, arguments: ['You are now identified for \x02botka\x02.'], tags: None
22:40:07 DEBUG irc.client _dispatcher: privnotice
22:40:07 DEBUG errbot.core *** frm = NickServ!NickServ@services.
22:40:07 DEBUG errbot.core *** username = NickServ
22:40:07 DEBUG errbot.core *** text = You are now identified for botka.
22:40:07 DEBUG errbot.core Assuming 'You are now identified for botka.' to be a command because BOT_PREFIX_OPTIONAL_ON_CHAT is True
22:40:07 DEBUG errbot.core Command not found
22:40:07 DEBUG errbot.utils Elapsed 0.014732 since last call
22:40:07 DEBUG errbot.utils Wait 0.985268 due to rate limiting...
22:40:08 DEBUG irc.client TO SERVER: PRIVMSG NickServ :Command "You" / "You are" not found.
............afterwards
22:40:20 DEBUG irc.client FROM SERVER: :NickServ!NickServ@services. NOTICE botka :Invalid command. Use /msg NickServ help for a command listing.
22:40:20 DEBUG irc.client _dispatcher: all_raw_messages
22:40:20 DEBUG irc.client command: privnotice, source: NickServ!NickServ@services., target: botka, arguments: ['Invalid command. Use \x02/msg NickServ help\x02 for a command listing.'], tags: None
22:40:20 DEBUG irc.client _dispatcher: privnotice
22:40:20 DEBUG errbot.core *** frm = NickServ!NickServ@services.
22:40:20 DEBUG errbot.core *** username = NickServ
22:40:20 DEBUG errbot.core *** text = Invalid command. Use /msg NickServ help for a command listing.
22:40:20 DEBUG errbot.core Assuming 'Invalid command. Use /msg NickServ help for a command listing.' to be a command because BOT_PREFIX_OPTIONAL_ON_CHAT is True
22:40:20 DEBUG errbot.core Command not found
22:40:20 DEBUG errbot.utils Elapsed 0.015257 since last call
22:40:20 DEBUG errbot.utils Wait 0.984743 due to rate limiting...
22:40:21 DEBUG irc.client TO SERVER: PRIVMSG NickServ :Command "Invalid" / "Invalid command." not found.
22:40:21 DEBUG errbot.core Triggering callback_message on Flows
.............skpped
22:40:21 DEBUG irc.client FROM SERVER: :NickServ!NickServ@services. NOTICE botka :Invalid command. Use /msg NickServ help for a command listing.发布于 2018-12-01 00:50:23
我用一个过滤器插件做到了这一点;在配置中,我有一个要忽略的用户列表:
from errbot import BotPlugin, cmdfilter
IGNORE_COMMAND = (None, None, None)
class IgnoreUsers(BotPlugin):
"""Command filter that causes blocks any response to zombot."""
@cmdfilter
def ignore_users(self, msg, cmd, args, dry_run):
"""
Check command to see if it came from zombot, and if so block it
:param msg: The original chat message.
:param cmd: The command name itself.
:param args: Arguments passed to the command.
:param dry_run: True when this is a dry-run.
"""
for user in self.bot_config.IGNORE_USERS:
if msg.frm.person == user:
self.log.info("Ignored %s from %s." % (cmd, user))
return IGNORE_COMMAND # didn't hear a thing
return msg, cmd, args # ok, don't ignore it发布于 2018-08-15 18:46:04
我需要更仔细地阅读文档:SUPPRESS_CMD_NOT_FOUND = True可以做到这一点,尽管忽略特定用户/消息的问题仍然存在。
https://stackoverflow.com/questions/51855840
复制相似问题