messages.py 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. # https://tools.ietf.org/html/rfc2812#section-2.3.1
  2. p_chanstring= r"[^\x00\x07\r\n ,:]"
  3. p_channelid = "[a-z0-9]{5}"
  4. p_user = r"[^\x00\r\n @]+"
  5. p_key = r"[\z01-05\x07-08\x0C\x0E-F1\x21-7F]{1,23}"
  6. p_letter = "[a-zA-Z0-9]"
  7. p_digit = "[0-9]"
  8. p_hexdigit = "("+p_digit+")|[A-F]"
  9. p_special = r"[\x5B-60\x7B-7D]"
  10. p_nospcrlfcl= r"[^\x00\x007\r\n :]"
  11. p_wildone = r"\x3F"
  12. p_wildmany = r"\x2A"
  13. p_nowild = r"[\x01-29\x2B-3E\x40-FF]"
  14. p_noesc = r"[\x01-5B\5D-FF]"
  15. p_mask = "(("+p_nowild+")|("+p_noesc+p_wildone+")|("+p_noesc+p_wildmany+"))*"
  16. p_targetmask= "\$|#"+p_mask
  17. p_channel = "(#|+|(!"+p_channelid+")|&)+("+p_chanstring+")(:"+p_chanstring+")?"
  18. p_nickname = "("+p_letter+")|("+p_special+")(("+p_letter+")|("+p_digit+")|("+p_special+")){8}"
  19. p_shortname = "("+p_letter+")|("+p_digit+")(("+p_letter+")|("+p_digit+")|(-)*(("+p_letter+")|("+p_digit+"))*"
  20. p_hostname = "("+p_shortname+")(."+p_shortname+")" # dot
  21. p_servername= p_hostname
  22. p_ip4addr = "("+p_digit+"){1,3}."+"("+p_digit+"){1,3}."+"("+p_digit+"){1,3}."+"("+p_digit+"){1,3}"
  23. p_ip6addr = "(("+p_hexdigit+")+(:("+p_hexdigit+")+){7})"\
  24. + "|(0:0:0:0:0:(0|(FFFF):"+p_ip4addr+")"
  25. p_hostaddr = "("+p_ip4addr+")|("+p_ip6addr+")"
  26. p_host = "("+p_hostname+")|("+p_hostaddr+")"
  27. p_middle = p_nospcrlfcl+"(:|("+p_nospcrlfcl+"))*"
  28. p_trailing = "(:| |("+p_nospcrlfcl+"))*"
  29. p_params = "(( "+p_middle+"){0,13}( :"+p_trailing+")?)|(( "+p_middle+"){14}( :?"+p_trailing+")?)"
  30. p_command = "(\w+)|(\d{3})"
  31. p_prefix = "("+p_servername+")|("+p_nickname+"((!"+p_user+")?@"+p_host+")?"
  32. p_message = "(:"+p_prefix+" )?"+p_command+"("+p_params+")?"
  33. p_target = "("+p_nickname+")|("+p_servername+")" #p_server
  34. p_msgto = "("+p_channel+")"\
  35. +"|("+p_user+"(%"+p_host+")@"+p_servername+")"\
  36. +"|("+p_user+"%"+p_host+")"\
  37. +"|("+p_targetmask+")"\
  38. +"|("+p_nickname+")"\
  39. +"|("+p_nickname+"!"+p_user+"@"+p_host+")"
  40. p_msgtarget = p_msgto+"(,"+p_msgto+")*"