rwikibot 1.0.6 → 1.0.7
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +4 -0
- data/lib/rwikibot.rb +24 -1
- metadata +1 -1
data/CHANGELOG
CHANGED
data/lib/rwikibot.rb
CHANGED
@@ -26,7 +26,7 @@ class RWikiBot
|
|
26
26
|
# New bots hope for three attributes, but require none. The first is simply the name of the bot for logging purposes. The second is the debug level constant, and third is the logfile.
|
27
27
|
#
|
28
28
|
# Example: bot = RWikiBot.new("My Neat Bot", Logger::DEBUG, "./rwikibot.log")
|
29
|
-
def initialize (name = "Unnamed Bot", config = 'default', debuglevel = Logger::
|
29
|
+
def initialize (name = "Unnamed Bot", config = 'default', debuglevel = Logger::INFO, log_location = "./rwikibot.log" )
|
30
30
|
|
31
31
|
@botname = name
|
32
32
|
|
@@ -573,6 +573,29 @@ class RWikiBot
|
|
573
573
|
return site_info.fetch('generator').split(' ')[1]
|
574
574
|
end
|
575
575
|
|
576
|
+
# This method turns a pageid into a title. Why? Because I've written the rest of the methods title-centric, and I want to keep it that way. But, sometiumes you get a list of ids and not titles, and we have to do something about that.
|
577
|
+
#
|
578
|
+
# INPUT:: PageID - just one!
|
579
|
+
# OUTPUT:: A title in string form.
|
580
|
+
def pageid_to_title(id)
|
581
|
+
|
582
|
+
# Prepare the request! Notify the logger!
|
583
|
+
@wikibotlogger.debug "PAGEID TO TITLE - Preparing the requeset..."
|
584
|
+
post_me = {'prop' => 'info', 'pageids' => id}
|
585
|
+
|
586
|
+
# Make the request. Becuase we care.
|
587
|
+
@wikibotlogger.debug "PAGEID TO TITLE - Asking make_request to get revision for pageid #{id}"
|
588
|
+
id_result = make_request('query', post_me )
|
589
|
+
@wikibotlogger.debug "PAGEID TO TITLE - We should have a result now..."
|
590
|
+
|
591
|
+
#Process the results
|
592
|
+
@wikibotlogger.debug "PAGEID TO TITLE - Preparing results..."
|
593
|
+
|
594
|
+
return id_result.fetch('pages')[0].fetch('title')
|
595
|
+
|
596
|
+
end
|
597
|
+
|
598
|
+
|
576
599
|
private
|
577
600
|
|
578
601
|
# Make Request is a method that actually handles making the request to the API. Since the API is somewhat standardized, this method is able to accept the action and a hash of variables, and it handles all the fun things MediaWiki likes to be weird over, like cookies and limits and actions. Its very solid, but I didn't want it public because it also does some post processing, and that's not very OO.
|