A Python robot that edits Wikipedia and interacts with people over IRC https://en.wikipedia.org/wiki/User:EarwigBot
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

33 lines
764 B

  1. # -*- coding: utf-8 -*-
  2. class User(object):
  3. """
  4. EarwigBot's Wiki Toolset: User Class
  5. """
  6. def __init__(self, site, username):
  7. """
  8. Docstring needed
  9. """
  10. self.site = site
  11. self.username = username
  12. def exists(self):
  13. """
  14. Docstring needed
  15. """
  16. pass
  17. def get_rights(self):
  18. """
  19. Docstring needed
  20. """
  21. params = {"action": "query", "list": "users", "usprop": "groups",
  22. "ususers": self.username}
  23. result = self.site.api_query(params)
  24. try:
  25. rights = res['query']['users'][0]['groups']
  26. except KeyError: # 'groups' not found, meaning the user does not exist
  27. return None
  28. return rights