wlmperu.py 884 B

12345678910111213141516171819202122232425262728293031
  1. #!/usr/bin/python
  2. # -*- coding: utf-8 -*-
  3. # Author: Omar Vega Ramos
  4. # E-mail: ovruni@riseup.net
  5. # License: GNU GPL - GNU General Public License v3.0 or later
  6. # http://www.gnu.org/licenses/gpl.html
  7. import sys, os.path
  8. import pywikibot
  9. if os.path.isfile("users.txt") == False :
  10. sys.exit("The file 'users.txt' does not exist")
  11. if os.path.isfile("message.txt") == False :
  12. sys.exit("The file 'message.txt' does not exist")
  13. users_file = open("users.txt", "r")
  14. message_file = open("message.txt", "r")
  15. message = message_file.read()
  16. site = pywikibot.Site()
  17. summary = input("Please add the edit summary: ")
  18. for user in users_file:
  19. username = user.strip()
  20. user_talk = "User talk:" + username
  21. user_page = pywikibot.Page(site, user_talk)
  22. current_text = user_page.text
  23. user_page.put(current_text + "\n\n" + message, summary)
  24. users_file.close()
  25. message_file.close()