I think he means if the user has +nf chattr, and the victim was the bot, do not proceed to reop the bot, else if the user does not have +nf flags then proceed to reop the bot.
Ahh, I guess I know what he means. But looking at the handle:deop I wonder if this the place where reop conditions are checked. I am pretty sure that my bots do not reop uppon deop of myself. Looking at the code I understand, that only deops of chanserv are explicitly made undone (due to deops of net rejoins). Any other reop is triggered by the event "need op" of the bot itself.
So I wonder why my script would reop on deop of an friend or owner, testing with my own bots shows me that no reop is done.
That's caused by your flag l which tells the bot to have halfop on the channel, therefore it tries to gain halfop using the halfop command. Removing the o flag from chanserv tells the bot to never request op by itself. Therefore it would only get op, when chanserv feels like doing so.
I cannot exactly tell you why your bot does that, I can only remark that it is not neccessarily caused by the script, since I cannot reproduce what you describe.