SHARE
TWEET

Untitled

a guest Oct 21st, 2019 88 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. """
  2.     Nickless
  3.         by Luke Moll
  4.         For use with an IRC bridging bot (like slack-irc) - will prevent you from getting highlighted
  5.         by messages you sent from the bridged channel (ie Slack).
  6.  
  7.         Yes, I know it's a niche usecase.
  8.  
  9. """
  10. import re
  11. import znc
  12.  
  13. class nickless(znc.Module):
  14.     module_types = [znc.CModInfo.NetworkModule]
  15.     description = "Strips nick from proxied messages"
  16.  
  17.     regex = None
  18.  
  19.     def OnLoad(self, sArgsi, sMessage): # let's hope this is the same as CModule::OnLoad
  20.         nick = self.GetNetwork().GetIRCNick().GetNick()
  21.         self.PutModule("Stripping nick from messages starting with <{}>".format(nick))
  22.         self.regex = re.compile(r"^<.{,2}" + nick + r".{,2}>")
  23.         return True
  24.  
  25.     def OnChanTextMessage(self, Message):
  26.         if self.regex is not None:
  27.             txt = re.sub(self.regex, "[me]", Message.GetText())
  28.             Message.SetText(txt)
  29.         else:
  30.             self.PutModule("`self.regex` was not set -- was OnChanTextMessage called before OnLoad???")
  31.         return znc.CONTINUE
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top