Wikipedia:Bots/Requests for approval/MetsBot 12
[[User:MetsBot|MetsBot]]
{{Newbot|MetsBot|12}}
Operator: Mets501
Automatic or Manually Assisted: Automatic but every edit will be checked
Programming Language(s): AWB with C# module
Function Summary: ame exact task as Wikipedia:Bots/Requests for approval/EBot Task2
Edit period(s) (e.g. Continuous, daily, one time run): one time run
Edit rate requested: 10 edits per minute
Already has a bot flag (Y/N): Y
Function Details: User:E withdrew his request to run this task, so I'm taking it over.
= Discussion =
Actually, if I could just get approval for any of this sort of template parameter-updating that would be great. —METS501 (talk) 03:27, 24 August 2007 (UTC)
:The prior withdrawal was that AWB would not be able to accomplish this task, has that been resolved? — xaosflux Talk 04:31, 24 August 2007 (UTC)
::I'm actually not really using AWB for the article processing, just for the list-making and article-saving. I'm using C# regexes for the processing. I'll have some sample diffs in a second. —METS501 (talk) 04:44, 24 August 2007 (UTC)
I went ahead and did a little trial: check it out [http://en.wikipedia.org/w/index.php?title=Special:Contributions&offset=20070824052343&limit=17&target=MetsBot here]. —METS501 (talk) 05:26, 24 August 2007 (UTC)
:{{BotTrial|edits=50}} Give it 50 more edits, report back and I can approve. Thanks for taking this over, didn't really have much time on my hands. — E talkbots 06:22, 24 August 2007 (UTC)
::OK, [http://en.wikipedia.org/w/index.php?title=Special:Contributions&dir=prev&offset=20070824052343&target=MetsBot trial done]. Here's the article-text-processing source code, if anyone's curious:
{{hide|Code|
char[] trimchars = { '|', ' ', '_' };
Match m1 = Regex.Match(ArticleText, @"band_name *= ?(.*?)\r\n");
string strName = m1.Groups[1].Value.Trim(trimchars);
Match m2 = Regex.Match(ArticleText, @"image *= ?\[\[ ?[Ii]mage:(.*?)( ?\| ?([0-9]*) ?px ?)?\|?\]\](\r\n| ?\|)");
string strImg = m2.Groups[1].Value.Trim(trimchars);
string strImg_size = m2.Groups[3].Value.Trim(trimchars);
if (strImg == "")
{
Match m2a = Regex.Match(ArticleText, @"(image|Img) *= ?(.*?)\r\n");
strImg = m2a.Groups[2].Value.Trim(trimchars);
}
if (strImg_size == "")
{
Match m2b = Regex.Match(ArticleText, @"image_size *= ?(.*?)(px)?\r\n");
strImg_size = m2b.Groups[1].Value.Trim(trimchars);
}
Match m3 = Regex.Match(ArticleText, @"caption *= ?(.*?)\r\n");
string strImg_capt = m3.Groups[1].Value.Trim(trimchars);
if (strImg.Contains("|"))
{
Match m2c = Regex.Match(strImg, @"(.*?) ?\| ?([0-9]*) ?px ?\|([^\|]*)");
strImg = m2c.Groups[1].Value.Trim(trimchars);
strImg_size = m2c.Groups[2].Value.Trim(trimchars);
if (strImg_capt == "")
strImg_capt = m2c.Groups[3].Value.Trim(trimchars);
}
Match m4 = Regex.Match(ArticleText, @"origin *= ?(.*?)\r\n");
string strOrigin = m4.Groups[1].Value.Trim(trimchars);
Match m5 = Regex.Match(ArticleText, @"years_active *= ?(.*?)\r\n");
string strYears_active = m5.Groups[1].Value.Trim(trimchars);
Match m6 = Regex.Match(ArticleText, @"music_genre *= ?(.*?)\r\n");
string strGenre = m6.Groups[1].Value.Trim(trimchars);
Match m7 = Regex.Match(ArticleText, @"record_label *= ?(.*?)\r\n");
string strLabel = m7.Groups[1].Value.Trim(trimchars);
Match m8 = Regex.Match(ArticleText, @"current_members *= ?(.*?)\r\n");
string strCurrent_members = m8.Groups[1].Value.Trim(trimchars);
Match m9 = Regex.Match(ArticleText, @"past_members *= ?(.*?)\r\n");
string strPast_members = m9.Groups[1].Value.Trim(trimchars);
Match m10 = Regex.Match(ArticleText, @"website *= ?(.*?)\r\n");
string strURL = m10.Groups[1].Value.Trim(trimchars);
if (strOrigin == "")
{
Match m11 = Regex.Match(ArticleText, @"country *= ?(.*?)\r\n");
strOrigin = m11.Groups[1].Value.Trim(trimchars);
}
string OldArticleText = ArticleText;
Match Testing = Regex.Match(ArticleText, @"{{[Ii]nfobox[_ ][Bb]and[^{]*?}}");
if (!Testing.Success)
ArticleText = Regex.Replace(ArticleText, @"{{[Ii]nfobox[_ ][Bb]and.*?(music_genre|record_label|current_members).*?}}", "{{Infobox musical artist \r\n| Name = " + strName + "\r\n| Img = " + strImg + "\r\n| Img_capt = " + strImg_capt + "\r\n| Img_size = " + strImg_size + "\r\n| Landscape = \r\n| Background = group_or_band\r\n| Alias = \r\n| Origin = " + strOrigin + "\r\n| Genre = " + strGenre + "\r\n| Years_active = " + strYears_active + "\r\n| Label = " + strLabel + "\r\n| Associated_acts = \r\n| URL = " + strURL + "\r\n| Current_members = " + strCurrent_members + "\r\n| Past_members = " + strPast_members + "\r\n| Notable_instruments = \r\n}}", RegexOptions.Singleline);
else
ArticleText = Regex.Replace(ArticleText, @"{{[Ii]nfobox[_ ][Bb]and.*?}}", "{{Infobox musical artist \r\n| Name = " + strName + "\r\n| Img = " + strImg + "\r\n| Img_capt = " + strImg_capt + "\r\n| Img_size = " + strImg_size + "\r\n| Landscape = \r\n| Background = group_or_band\r\n| Alias = \r\n| Origin = " + strOrigin + "\r\n| Genre = " + strGenre + "\r\n| Years_active = " + strYears_active + "\r\n| Label = " + strLabel + "\r\n| Associated_acts = \r\n| URL = " + strURL + "\r\n| Current_members = " + strCurrent_members + "\r\n| Past_members = " + strPast_members + "\r\n| Notable_instruments = \r\n}}", RegexOptions.Singleline);
if (ArticleText == OldArticleText)
Skip = true;
return ArticleText;
}}
::I'm searching for a good way of matching an entire template with a regex reliably (even if there is a template inside one of the template parameters. Anyone? —METS501 (talk) 13:29, 24 August 2007 (UTC)
:::{{BotApproved}} - As per usual ;) Reedy Boy 20:08, 24 August 2007 (UTC)
:The above discussion is preserved as an archive of the debate. Please do not modify it. Subsequent comments should be made in a new section.