networkservices.py 3.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. from . import log
  2. class NickServ():
  3. def recover_nick(connection, password):
  4. log.info('Recovering nickname.')
  5. connection.privmsg('NickServ', 'IDENTIFY %s %s' % (self.network.nickname, password)) # Identify with NickServ.
  6. connection.privmsg('NickServ', 'RECOVER %s %s' % (self.network.nickname, password)) # Recover control of nickname via NickServ.
  7. connection.privmsg('NickServ', 'GHOST %s %s' % (self.network.nickname, password)) # Recover control of nickname via NickServ, old style.
  8. connection.nick(connection.nickname) # Set original nickname. Should have happened during the nickServ recover, this fails when still connecting. So this creates a loop to successfully recover via NickServ.
  9. class ChanServ():
  10. def invite(connection, channel_name):
  11. log.info('Requesting ChanServ to invite me to %s' % channel_name)
  12. connection.privmsg("ChanServ", "INVITE " + channel_name)
  13. def getkey(connection, channel_name):
  14. log.info('Requesting ChanServ password for channel %s' % channel_name)
  15. connection.privmsg("ChanServ", "GETKEY " + channel_name)
  16. def ban(connection, channel_name, user_name, reason):
  17. log.info('Requesting ChanServ to ban %s from %s for %s' % (user_name, channel_name, reason))
  18. connection.privmsg("ChanServ", "BAN " + channel_name + " " + user_name + " " + reason)
  19. def tempban(connection, channel_name, user_name, duration, reason):
  20. log.info('Requesting ChanServ to ban %s for %s in %s %s for %s' % (user_name, reason, channel_name, duration))
  21. connection.privmsg("ChanServ", "BAN " + channel_name + " +" + duration + " " + user_name + " " + reason)
  22. def unban(connection, channel_name, user_name):
  23. log.info('Requesting ChanServ to ubnan %s from %s.' %(user_name, channel_name))
  24. connection.privmsg("ChanServ", "UNBAN " + channel_name + " " + user_name)
  25. def akick_add(connection, channel_name, user_name):
  26. log.info('Requesting ChanServ to add %s to the auto kick list of %s.' % (user_name, channel_name))
  27. connection.privmsg("ChanServ", "AKICK " + channel_name + " ADD " + user_name)
  28. def akick_del(connection, channel_name, user_name):
  29. log.info('Requesting ChanServ to remove %s to the auto kick list of %s.' % (user_name, channel_name))
  30. connection.privmsg("ChanServ", "AKICK " + channel_name + " DEL " + user_name)
  31. def kick(connection, channel_name, user_name, reason):
  32. log.info('Requesting ChanServ to kick %s from %s.' % (user_name, channel_name))
  33. connection.privmsg("ChanServ", "KICK " + channel_name + " " + user_name + " " + reason)
  34. def give_mode(connection, channel_name, user_name, mode):
  35. if mode[1] == "q":
  36. modename = "OWNER"
  37. if mode[1] == "a":
  38. modename = "PROTECT"
  39. if mode[1] == "o":
  40. modename = "OP"
  41. if mode[1] == "h":
  42. modename = "HALFOP"
  43. if mode[1] == "v":
  44. modename = "VOICE"
  45. log.info('Requesting ChanServ grant %s to %s on %s' % (modename, user_name, channel_name))
  46. connection.privmsg("ChanServ", modename + " " + channel_name + " " + user_name)
  47. def take_all_modes(connection, channel_name, user_name):
  48. log.info('Requesting ChanServ strip %s of all modes in %s.' % (user_name, channel_name))
  49. connection.privmsg("ChanServ", "DEVOICE " + channel_name + " " + user_name)
  50. connection.privmsg("ChanServ", "DEHALFOP " + channel_name + " " + user_name)
  51. connection.privmsg("ChanServ", "DEOP " + channel_name + " " + user_name)
  52. connection.privmsg("ChanServ", "DEPROTECT " + channel_name + " " + user_name)
  53. connection.privmsg("ChanServ", "DEOWNER " + channel_name + " " + user_name)