A Python robot that edits Wikipedia and interacts with people over IRC https://en.wikipedia.org/wiki/User:EarwigBot
Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

pirms 13 gadiem
pirms 13 gadiem
pirms 13 gadiem
1234567891011121314151617181920212223242526272829
  1. # -*- coding: utf-8 -*-
  2. from os.path import expanduser
  3. import oursql
  4. from classes import BaseCommand
  5. class Command(BaseCommand):
  6. """Return the replag for a specific database on the Toolserver."""
  7. name = "replag"
  8. def process(self, data):
  9. args = {}
  10. if not data.args:
  11. args["db"] = "enwiki_p"
  12. else:
  13. args["db"] = data.args[0]
  14. args["host"] = args["db"].replace("_", "-") + ".rrdb.toolserver.org"
  15. args["read_default_file"] = expanduser("~/.my.cnf")
  16. conn = oursql.connect(**args)
  17. with conn.cursor() as cursor:
  18. cursor.execute("SELECT NOW() - MAX(rev_timestamp) FROM revision")
  19. replag = int(cursor.fetchall()[0][0])
  20. conn.close()
  21. msg = "Replag on \x0302{0}\x0301 is \x02{1}\x0F seconds."
  22. self.connection.reply(data, msg.format(args["db"], replag))