مساعدة:بوت الترحيب
من ويكيبيديا، الموسوعة الحرة
كيفية تشغيل بوت الترحيب.
- يحب تشكيل نص كالنص في الأسفل لكل مستخدم.
- النص في الأسفل يبدأ بـ {{-start-}} و هذه يستعملها البوت لتحديد بداية الصفحة لكل مستخدم.
- اسم الصفحة التي سيوضع بها النص في الحالة في الأسفل هو نقاش المستخدم:Aahloa يتم وضعه كملاحظة.
- بعد ذلك يوجد قالبين الأول قالب ترحيب و الثاني قالب ترحيب1 مع دمج.
- في النهاية ضع اسمك. الإسم الموجود الآن في الأسفل هو Menasim. يمكن تعديله
- ثم مؤشر {{-stop-}} لإنهاء النص.
- يتم تكرار النص لجميع المستخدمين الجدد. بحيث يصبح عندك ملف واحد ضخم يحتوي نصوص كلها. ملف تيكست و لكن عند التخزين يجب أن يكون نوع النص ضمن تشفير يو تي إف 8
- لعمل هذا الملف بصورة مباشرة. إنسخ القائمة كاملة من سجل انشاء الحسابات الجديدة إلى ملف تيكست عادي.
- ثم استبدل التاريخ برمز ( هذا سيجعل اسم المستخدم محاطا برمز ( من الطرفين.
- الآن افتح الملف بواسطة الإكسل و أطلب منه فصل الأعمدة بواسطة موقع الرمز (
- سيتم فرز الأسماء لوحدها ضمن عامود
- انسخه إلى ملف إكسل أخر و خزنه
- ضع النص في الأسفل ضمن ملف ورد، ثم إعمل دمج بريد مع ملف الإكسل بحيث يكون اسم المستعمل في مكانه الصحيح بدلا من الإسم الموجود في الأسفل ( بدلا من Aahloa ) في هذه الحالة.
- اطلب تضمين نتائج دمج البريد جميعها في صفحة ملف واحد. ثم خزنه بواسطة تشفير يو تي إف 8
- تأكد من أنك تتذكر اسم الملف لوضعه في برنامج البوت. يفضل تسميته user.txt كما هو في البوت
- إنتبه إلى ان <nowiki> في الأسفل ليس قسما من النص.
[تحرير] النص الذي سيكرر
{{-start-}}<!--نقاش المستخدم:Aahloa--> {{ترحيب|}} {{subst:ترحيب1|-- [[مستخدم:Menasim|Menasim]]}} (<sup>[http://ar.wikipedia.org/w/index.php?title=%D9%86%D9%82%D8%A7%D8%B4_%D8%A7%D9%84%D9%85%D8%B3%D8%AA%D8%AE%D8%AF%D9%85:Menasim&action=edit§ion=new راسلني]</sup>) ~~~~~ {{-stop-}}
[تحرير] برنامج البوت
- coding: iso-8859-1
""" This bot takes its input from a file that contains a number of pages to be put on the wiki. The pages should all have the same begin and end text (which may not overlap).
By default the text should have the intended title of the page as the first text in bold (that is, between and ), you can modify this behavior with command line options.
The default is not to include the begin and end text in the page, if you want to include that text, use the -include option.
Specific arguments: -start:xxx Specify the text that is the beginning of a page -end:xxx Specify the text that is the end of a page -file:xxx Give the filename we are getting our material from -include The beginning and end text should be included
in the page.
-titlestart:xxx Use xxx in place of for identifying the
beginning of page title
-titleend:xxx Use xxx in place of for identifying the
end of page title
-summary:xxx Use xxx as the summary for the upload
If the page to be uploaded already exists: -safe do nothing (default) -appendtop add the text to the top of it -appendbottom add the text to the bottom of it -force overwrite the existing page """
- (C) Andre Engels, 2004
- Distributed under the terms of the MIT license.
__version__='$Id: Exp $'
import wikipedia, config import re, sys, codecs
msg={
'ar': u'welcome to Ar.wiki', 'de': u'Automatischer Import von Artikeln', 'en': u'Automated import of articles', 'ia': u'Importation automatic de articulos', 'it': u'Caricamento automatico', 'nl': u'Geautomatiseerde import', 'pt': u'Importação automática de artigos' }
- The following messages are added to topic when the page already exists
msg_top={
'en': u'append on top', 'it': u'aggiungo in cima' }
msg_bottom={
'en': u'append on bottom', 'it': u'aggiungo in fondo' }
msg_force={
'en': u'existing text overwritten', 'it': u'sovrascritto il testo esistente' }
- Adapt these to the file you are using. 'starttext' and 'endtext' are
- the beginning and end of each entry. Take text that should be included
- and does not occur elsewhere in the text.
- TODO: Why not use the entire file contents?
starttext = "قالب:-start-" endtext = "قالب:-stop-" filename = "user.txt" include = False
- exclude = False
titlestart = u"" search_string = u"" force = False append = "False"
def findpage(t):
search_string = titlestart + "(.*?)" + titleend
try:
location = re.search(starttext+"([^\Z]*?)"+endtext,t)
if include:
contents = location.group()
else:
contents = location.group(1)
except AttributeError:
print 'Start or end marker not found.'
return
try:
title = re.search(search_string, contents).group(1)
except AttributeError:
wikipedia.output(u"No title found - skipping a page.")
return
else:
page = wikipedia.Page(mysite, title)
wikipedia.output(page.title())
if page.exists():
if append == "Top":
old_text = page.get()
contents = contents + old_text
commenttext_top = commenttext + " - " + wikipedia.translate(mysite,msg_top)
wikipedia.output(u"Page %s already exists, appending on top!"%title)
page.put(contents, comment = commenttext_top, minorEdit = False)
elif append == "Bottom":
old_text = page.get()
contents = old_text + contents
commenttext_bottom = commenttext + " - " + wikipedia.translate(mysite,msg_bottom)
wikipedia.output(u"Page %s already exists, appending on bottom!"%title)
page.put(contents, comment = commenttext_bottom, minorEdit = False)
elif force:
commenttext_force = commenttext + " *** " + wikipedia.translate(mysite,msg_force) + " ***"
wikipedia.output(u"Page %s already exists, ***overwriting!"%title)
page.put(contents, comment = commenttext_force, minorEdit = False)
else:
wikipedia.output(u"Page %s already exists, not adding!"%title)
else:
page.put(contents, comment = commenttext, minorEdit = False)
findpage(t[location.end()+1:])
return
def main():
text = [] f = codecs.open(filename,'r', encoding = config.textfile_encoding) text = f.read() findpage(text)
mysite = wikipedia.getSite() commenttext = wikipedia.translate(mysite,msg) for arg in sys.argv[1:]:
arg = wikipedia.argHandler(arg, 'pagefromfile')
if arg:
if arg.startswith("-start:"):
starttext=arg[7:]
elif arg.startswith("-end:"):
endtext=arg[5:]
elif arg.startswith("-file:"):
filename=arg[6:]
elif arg=="-include":
include = True
#elif arg=="-exclude":
#exclude = True
elif arg=="-appendtop":
append = "Top"
elif arg=="-appendbottom":
append = "Bottom"
elif arg=="-force":
force=True
elif arg=="-safe":
force=False
append="False"
elif arg.startswith("-titlestart:"):
titlestart=arg[12:]
elif arg.startswith("-titleend:"):
titleend=arg[10:]
elif arg.startswith("-summary:"):
commenttext=arg[9:]
else:
wikipedia.output(u"Disregarding unknown argument %s."%arg)
try:
main()
except:
wikipedia.stopme() raise
else:
wikipedia.stopme()

