I'll start with "I'm not familiar with Python". I'm trying to change the default ircbot script from twisted for my channel, but I cannot get re.match
or re.search
working.
For example, this works:
prompt = ("%s" % self.nickname)
prompt1 = ("%s:" % self.nickname)
prompt2 = ("%s," % self.nickname)
if msg == (prompt1 + " whoareyou?") or msg == (prompt2 + " who are you?") or msg == (prompt1 + " whoareyou") or msg == (prompt2 + " who are you"):
This one as well
if msg == (prompt1 + " help") or msg == (prompt2 + " help"):
However these two conditions do not work on the bot (but they work on a local script):
if re.search(r'%s[:,] help' % self.nickname, msg):
elif re.search(r'%s[:,] who ?are ?you?' % self.nickname, msg):
A previous version of the script that is not using re.search
can be found here
I have found what was causing the problem. Twisted included a logic to handle nickname collision for the bot. It adds a
^
at the end of the name:This was causing my bots nickname to end with
nickname^
, and because I used%s
to add the nickname variable as part of the Regex, it interpreted the^
as a modifier.To this: