Difference between revisions of "User:DC64/Sandbox"
(Added Header) |
|||
(3 intermediate revisions by the same user not shown) | |||
Line 4: | Line 4: | ||
This is my Sandbox. Suggestions that are made to improve the pages are welcome. | This is my Sandbox. Suggestions that are made to improve the pages are welcome. | ||
− | == | + | ==Script== |
+ | Learning HTML/CSS, and starting Python. Baby steps. | ||
− | * | + | ====SignaBot==== |
+ | I have an idea for a bot, if it were accepted here. Its task would be to add signatures that users have forgotten in talk or discussion pages. Origionally from [https://fr.wiktionary.org/wiki/Utilisateur:JackBot JackBot of Wiktionary]. Read source to see code. | ||
+ | <!-- | ||
+ | <pre> | ||
+ | #!/usr/bin/env python | ||
+ | # This script signs the comments pages of discussions. | ||
+ | |||
+ | # Important modules | ||
+ | import catlib, pagegenerators, os, codecs, urllib, re | ||
+ | from wikipedia import * | ||
+ | |||
+ | # Déclaration | ||
+ | language = "en" | ||
+ | family = "wikibooks" | ||
+ | mynick = "JackBot" | ||
+ | site = getSite(language,family) | ||
+ | |||
+ | # Lecture du fichier articles_list.txt (same format as replace.py) | ||
+ | def lecture(source): | ||
+ | PagesHS = open(source, 'r') | ||
+ | while 1: | ||
+ | PageHS = PagesHS.readline() | ||
+ | fin = PageHS.find("\t") | ||
+ | PageHS = PageHS[0:fin] | ||
+ | if PageHS == '': break | ||
+ | modification(PageHS) | ||
+ | PagesHS.close() | ||
+ | |||
+ | # Changing the wiki | ||
+ | def modification(PageHS): | ||
+ | page = Page(site,PageHS) | ||
+ | if page.exists(): | ||
+ | if page.title() != u'Utilisateur:JackBot/test' and page.title()!= u'Wikibooks:Requests for permissions' and page.namespace()!= 1 and page.namespace()!= 3 and page.namespace()!= 5 and page.namespace()!= 7 and page.namespace()!= 9 and page.namespace()!= 11 and page.namespace()!= 13 and page.namespace()!= 15 and page.namespace()!= 103 and page.namespace()!= 109 and page.namespace()!= 111 and page.namespace()!= 113: | ||
+ | return | ||
+ | else: | ||
+ | url = u'http://' + language + u'.' + family + u'.org/w/api.php?action=query&prop=info|revisions&titles=%s&format=xml' % PageHS | ||
+ | PageTemp = urllib.urlopen(url) | ||
+ | try: | ||
+ | infos = PageTemp.read() | ||
+ | reviseur = re.findall(' user="(.*?)" ',infos) | ||
+ | PageTemp.close() | ||
+ | PageEnd = page.get() | ||
+ | if PageEnd.find(u'{{delete') != -1 or PageEnd.find(u'{{nobots') != -1 or PageEnd.find(u'{{bots|deny=all') != -1: return | ||
+ | except wikipedia.NoPage: | ||
+ | print "NoPage" | ||
+ | return | ||
+ | except wikipedia.IsRedirectPage: | ||
+ | print "Redirect page" | ||
+ | return | ||
+ | except wikipedia.LockedPage: | ||
+ | print "Locked/protected page" | ||
+ | return | ||
+ | if not reviseur: return | ||
+ | if PageEnd[len(PageEnd)-8:len(PageEnd)].rfind(u'(UTC)') != -1: return | ||
+ | |||
+ | #for chacun in reviseur: | ||
+ | reviseur = str(reviseur) | ||
+ | reviseur = reviseur[reviseur.find("'")+1:reviseur.rfind("'")] | ||
+ | summary = u'Autosignature for ' + u'[[User:' + reviseur + u'|' + reviseur + u']]' | ||
+ | |||
+ | date = re.findall(' timestamp="(.*?)" ',infos) | ||
+ | date = str(date) | ||
+ | date = date[date.find("'")+1:date.rfind("'")] | ||
+ | date = date[0:date.find("T")] + u' ' + date[date.find("T")+1:date.find("Z")] | ||
+ | |||
+ | PageEnd = PageEnd + u' {{unsigned|' + reviseur + u'|' + date + u'}}' | ||
+ | #print (PageEnd.encode(config.console_encoding, 'replace')) | ||
+ | #raw_input("fin") | ||
+ | page.put(PageEnd, summary) | ||
+ | |||
+ | # Classes | ||
+ | def crawlerCat(category): | ||
+ | cat = catlib.Category(site, category) | ||
+ | pages = cat.articlesList(False) | ||
+ | for Page in pagegenerators.PreloadingGenerator(pages,100): | ||
+ | if Page.namespace() == 0: modification(u'Discussion:' + Page.title()) | ||
+ | subcat = cat.subcategories(recurse = True) | ||
+ | for subcategory in subcat: | ||
+ | pages = subcategory.articlesList(False) | ||
+ | for Page in pagegenerators.PreloadingGenerator(pages,100): | ||
+ | if Page.namespace() == 0: modification(u'Discussion:' + Page.title()) | ||
+ | |||
+ | # Linked pages | ||
+ | def crawlerLink(pagename): | ||
+ | #pagename = unicode(arg[len('-links:'):], 'utf-8') | ||
+ | page = wikipedia.Page(site, pagename) | ||
+ | gen = pagegenerators.ReferringPageGenerator(page) | ||
+ | #gen = pagegenerators.NamespaceFilterPageGenerator(gen, namespaces) | ||
+ | for Page in pagegenerators.PreloadingGenerator(gen,100): | ||
+ | if Page.namespace() == 1: modification(Page.title()) | ||
+ | elif Page.namespace() == 0: modification(u'Discussion:' + Page.title()) | ||
+ | |||
+ | # Recent Changes | ||
+ | def crawlerRC(): | ||
+ | RC = pagegenerators.RecentchangesPageGenerator() | ||
+ | for Page in pagegenerators.PreloadingGenerator(RC,100): | ||
+ | if Page.namespace() == 1: modification(Page.title()) | ||
+ | |||
+ | # Launch | ||
+ | TraitementFile = lecture('articles_list.txt') | ||
+ | #TraitementLink = crawlerLink(u'') | ||
+ | #TraitementCategory = crawlerCat(u'') | ||
+ | raw_input("Signabot") | ||
+ | </pre> | ||
+ | --> | ||
==UserBoxes== | ==UserBoxes== |
Latest revision as of 18:03, 31 March 2018
User page | Talk | Sandbox | Contributions | Wiki-Fi stats | Steam | Backpack | Stats |
This is my Sandbox. Suggestions that are made to improve the pages are welcome.
Contents
Script
Learning HTML/CSS, and starting Python. Baby steps.
SignaBot
I have an idea for a bot, if it were accepted here. Its task would be to add signatures that users have forgotten in talk or discussion pages. Origionally from JackBot of Wiktionary. Read source to see code.
UserBoxes
These are userboxes that I've created.
Patches
Community Events
|
|
| ||||||||||||
|
|
|
Personal
|
Achievements
|
|
| ||||||
|
|
| ||||||
|
|
Loadout
I'll decide sometime where I want to put this.
Infobox
The old one. I still like it.
DC64 | |
---|---|
Basic information | |
Native language: | English |
Team Fortress 2 | |
Favourite classes: | · |
Favourite weapons: | Backburner |
Favourite hats: | |
Contact information | |
Steam page: | DC64 |
IRC nickname: | DC64 |