rwikibot 1.0.8 → 1.0.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/CHANGELOG +3 -0
- data/lib/rwikibot.rb +107 -106
- metadata +4 -3
data/CHANGELOG
CHANGED
data/lib/rwikibot.rb
CHANGED
@@ -32,11 +32,11 @@ class RWikiBot
|
|
32
32
|
@config = Hash.new
|
33
33
|
|
34
34
|
#We log. Log4r in the house.
|
35
|
-
|
35
|
+
##@wikibotlogger = Logger.new('rwikibot.log')
|
36
36
|
|
37
37
|
#INFO level is nice. I like it as production default because I like log files. Feel free to change. It will change once config loaded
|
38
|
-
|
39
|
-
|
38
|
+
##@wikibotlogger.level = Logger::DEBUG
|
39
|
+
###@wikibotlogger.info "New RWikiBot created. My name is #{@botname}"
|
40
40
|
|
41
41
|
# This had to come back since I was having config loading issues when being called from MediaWiki
|
42
42
|
@config['username'] = username
|
@@ -50,7 +50,7 @@ class RWikiBot
|
|
50
50
|
|
51
51
|
##change - make an HTTP object here for use later, now that we have config
|
52
52
|
@http = Net::HTTP.new(@config.fetch('uri').host, @config.fetch('uri').port)
|
53
|
-
|
53
|
+
###@wikibotlogger.debug("INIT - Created HTTP object. Result is: #{@http}}")
|
54
54
|
|
55
55
|
@config['cookie'] = nil
|
56
56
|
end
|
@@ -62,31 +62,31 @@ class RWikiBot
|
|
62
62
|
# No variables are accepted and the username/password are stored in config.yaml.
|
63
63
|
def login
|
64
64
|
|
65
|
-
|
65
|
+
###@wikibotlogger.debug("LOGIN - Preparing login information...")
|
66
66
|
post_me = {'lgname'=>@config.fetch('username'),'lgpassword'=>@config.fetch('password')}
|
67
67
|
if @config.has_key?('domain') && (@config.fetch('domain') != nil)
|
68
68
|
post_me['lgdomain'] = @config.fetch('domain')
|
69
69
|
end
|
70
70
|
|
71
|
-
|
71
|
+
###@wikibotlogger.debug("LOGIN - Asking make_request to perform login...")
|
72
72
|
login_result = make_request('login', post_me)
|
73
|
-
|
73
|
+
##@wikibotlogger.debug("LOGIN - We should have a result of type login now.")
|
74
74
|
|
75
|
-
|
75
|
+
##@wikibotlogger.debug("LOGIN - login_result received. Result is: #{login_result.fetch('result')}")
|
76
76
|
|
77
77
|
# Now we need to changed some @config stuff, specifically that we're logged in and the variables of that
|
78
78
|
# This will also change the make_request, but I'll comment there
|
79
79
|
if login_result.fetch('result') == "Success"
|
80
80
|
# All lg variables are directly from API and stored in config that way
|
81
|
-
|
81
|
+
##@wikibotlogger.info("LOGIN - Login successful. Wiki user is: #{login_result.fetch('lgusername')}")
|
82
82
|
@config['logged_in'] = TRUE
|
83
83
|
@config['lgusername'] = login_result.fetch('lgusername')
|
84
84
|
@config['lguserid'] = login_result.fetch('lguserid')
|
85
85
|
@config['lgtoken'] = login_result.fetch('lgtoken')
|
86
|
-
|
86
|
+
##@wikibotlogger.debug("LOGIN - MediwWiki API variables stored in @config")
|
87
87
|
return TRUE
|
88
88
|
else
|
89
|
-
|
89
|
+
##@wikibotlogger.error("LOGIN - Login Error. Wiki API said: #{login_result.fetch('result')}")
|
90
90
|
return FALSE
|
91
91
|
end
|
92
92
|
|
@@ -101,7 +101,7 @@ class RWikiBot
|
|
101
101
|
# OUTPUT:: Returns an array of hashes.
|
102
102
|
def watchlist (options=nil)
|
103
103
|
# Get the bot's watchlist
|
104
|
-
|
104
|
+
##@wikibotlogger.debug("WATCHLIST - Preparing request information...")
|
105
105
|
post_me = {'list'=>'watchlist'}
|
106
106
|
|
107
107
|
if options != nil
|
@@ -111,12 +111,12 @@ class RWikiBot
|
|
111
111
|
end
|
112
112
|
|
113
113
|
# Make the request
|
114
|
-
|
114
|
+
##@wikibotlogger.debug "WATCHLIST - Asking make_request to get watchlist..."
|
115
115
|
watchlist_result = make_request('query', post_me)
|
116
|
-
|
116
|
+
##@wikibotlogger.debug "WATCHLIST - We should have a result of type query now."
|
117
117
|
|
118
118
|
#Process into a Hash for return
|
119
|
-
|
119
|
+
##@wikibotlogger.debug "WATCHLIST - Processing result..."
|
120
120
|
return watchlist_result.fetch('watchlist')
|
121
121
|
|
122
122
|
end
|
@@ -133,7 +133,7 @@ class RWikiBot
|
|
133
133
|
# This will allow any given bot to get recent changes. Then act on it. But that's another method
|
134
134
|
# TODO - Persistent timestamp storage
|
135
135
|
|
136
|
-
|
136
|
+
##@wikibotlogger.debug("RECENT CHANGES - Preparing request information...")
|
137
137
|
post_me = {"list" => "recentchanges", 'rclimit' => '5000'}
|
138
138
|
if options != nil
|
139
139
|
options.each do |key, value|
|
@@ -142,12 +142,12 @@ class RWikiBot
|
|
142
142
|
end
|
143
143
|
|
144
144
|
# Make the request
|
145
|
-
|
145
|
+
##@wikibotlogger.debug "RECENT CHANGES - Asking make_request to get recentchanges..."
|
146
146
|
recentchanges_result = make_request('query' , post_me)
|
147
|
-
|
147
|
+
##@wikibotlogger.debug "RECENT CHANGES - We should have a result of type query now."
|
148
148
|
|
149
149
|
# Figure out what to do now. Process, I'd think
|
150
|
-
|
150
|
+
##@wikibotlogger.debug "RECENT CHANGES - Processing result..."
|
151
151
|
|
152
152
|
return recentchanges_result.fetch('recentchanges')
|
153
153
|
|
@@ -162,27 +162,27 @@ class RWikiBot
|
|
162
162
|
# OUTPUT:: An array of hashes containing log events.
|
163
163
|
def log_events (options = nil)
|
164
164
|
|
165
|
-
|
165
|
+
##@wikibotlogger.debug "LOG EVENTS - Preparing request information..."
|
166
166
|
|
167
167
|
# Make the request
|
168
168
|
post_me = {"list" => "logevents"}
|
169
169
|
|
170
170
|
if options != nil
|
171
|
-
|
171
|
+
##@wikibotlogger.debug("LOG EVENTS - Additional options added by requestor. Adding to post_me...")
|
172
172
|
options.each_pair do |key, value|
|
173
173
|
post_me[key] = value
|
174
|
-
|
174
|
+
##@wikibotlogger.debug "LOG EVENTS - Added #{post_me[key]}"
|
175
175
|
end
|
176
|
-
|
176
|
+
##@wikibotlogger.debug("LOG EVENTS - No more additional options. Moving on...")
|
177
177
|
end
|
178
178
|
|
179
179
|
#Make the request!
|
180
|
-
|
180
|
+
##@wikibotlogger.debug "LOG EVENTS = Asking make_request to get logevents"
|
181
181
|
logevents_result = make_request('query', post_me)
|
182
|
-
|
182
|
+
##@wikibotlogger.debug "LOG EVENTS - We should have a result of type logevents now."
|
183
183
|
|
184
184
|
# Process results
|
185
|
-
|
185
|
+
##@wikibotlogger.debug "LOG EVENTS - Processing result..."
|
186
186
|
|
187
187
|
|
188
188
|
return logevents_result.fetch('logevents')
|
@@ -198,24 +198,24 @@ class RWikiBot
|
|
198
198
|
def redirects (title, options = nil)
|
199
199
|
|
200
200
|
# Prepare the request
|
201
|
-
|
201
|
+
##@wikibotlogger.debug "REDIRECTS - Preparing request information..."
|
202
202
|
post_me = {'titles' => title, 'redirects'=>'', 'prop' => 'info'}
|
203
203
|
|
204
204
|
if options != nil
|
205
|
-
|
205
|
+
##@wikibotlogger.debug("REDIRECTS - Additional options added by requestor. Adding to post_me...")
|
206
206
|
options.each_pair do |key, value|
|
207
207
|
post_me[key] = value
|
208
|
-
|
208
|
+
##@wikibotlogger.debug "REDIRECTS - Added #{post_me[key]}"
|
209
209
|
end
|
210
|
-
|
210
|
+
##@wikibotlogger.debug("REDIRECTS - No more additional options. Moving on...")
|
211
211
|
end
|
212
212
|
|
213
213
|
#Make the request
|
214
|
-
|
214
|
+
##@wikibotlogger.debug "REDIRECTS - Asking make_request find redirects..."
|
215
215
|
redirects_result = make_request('query', post_me)
|
216
|
-
|
216
|
+
##@wikibotlogger.debug "REDIRECTS - We should have a result now..."
|
217
217
|
|
218
|
-
|
218
|
+
##@wikibotlogger.debug "REDIRECTS - Processing result..."
|
219
219
|
|
220
220
|
|
221
221
|
return redirects_result.fetch('pages')
|
@@ -232,16 +232,16 @@ class RWikiBot
|
|
232
232
|
def redirect? (title)
|
233
233
|
|
234
234
|
# Prepare the request
|
235
|
-
|
235
|
+
##@wikibotlogger.debug "REDIRECT? - Preparing request information..."
|
236
236
|
post_me = {'titles' => title, 'redirects'=>'', 'prop' => 'info'}
|
237
237
|
|
238
238
|
|
239
239
|
#Make the request
|
240
|
-
|
240
|
+
##@wikibotlogger.debug "REDIRECT? - Asking make_request find redirects..."
|
241
241
|
redirects_result = make_request('query', post_me)
|
242
|
-
|
242
|
+
##@wikibotlogger.debug "REDIRECT? - We should have a result now..."
|
243
243
|
|
244
|
-
|
244
|
+
##@wikibotlogger.debug "REDIRECT? - Processing result..."
|
245
245
|
|
246
246
|
|
247
247
|
return redirects_result.has_key?('redirects')
|
@@ -258,15 +258,15 @@ class RWikiBot
|
|
258
258
|
def normalize (title)
|
259
259
|
|
260
260
|
# Prepare the request
|
261
|
-
|
261
|
+
##@wikibotlogger.debug "NORMALIZE - Preparing request information..."
|
262
262
|
post_me = {'titles' => title}
|
263
263
|
|
264
264
|
#Make the request
|
265
|
-
|
265
|
+
##@wikibotlogger.debug "NORMALIZE - Asking make_request to normalize titles..."
|
266
266
|
normalized_result = make_request('query', post_me)
|
267
|
-
|
267
|
+
##@wikibotlogger.debug "NORMALIZE - We should have a result now..."
|
268
268
|
|
269
|
-
|
269
|
+
##@wikibotlogger.debug "NORMALIZE - Processing result..."
|
270
270
|
|
271
271
|
|
272
272
|
return normalized_result.fetch('pages')
|
@@ -285,23 +285,23 @@ class RWikiBot
|
|
285
285
|
def all_pages (options = nil)
|
286
286
|
|
287
287
|
# This will get all pages. Limits vary based on user rights of the Bot. Set to bot.
|
288
|
-
|
288
|
+
##@wikibotlogger.debug "ALL PAGES - Preparing request information..."
|
289
289
|
post_me = {'list' => 'allpages', 'apnamespace' => '0', 'aplimit' => '5000'}
|
290
290
|
|
291
291
|
|
292
292
|
if options != nil
|
293
|
-
|
293
|
+
##@wikibotlogger.debug("ALL PAGES - Additional options added by requestor. Adding to post_me...")
|
294
294
|
options.each_pair do |key, value|
|
295
295
|
post_me[key] = value
|
296
|
-
|
296
|
+
##@wikibotlogger.debug "ALL PAGES - Added #{post_me[key]}"
|
297
297
|
end
|
298
|
-
|
298
|
+
##@wikibotlogger.debug("ALL PAGES - No more additional options. Moving on...")
|
299
299
|
end
|
300
300
|
|
301
301
|
#make the request
|
302
|
-
|
302
|
+
##@wikibotlogger.debug "ALL PAGES - Asking make_request to get all pages..."
|
303
303
|
allpages_result = make_request('query', post_me)
|
304
|
-
|
304
|
+
##@wikibotlogger.debug "ALL PAGES - We should have a result now..."
|
305
305
|
|
306
306
|
return allpages_result.fetch('allpages')
|
307
307
|
|
@@ -317,23 +317,23 @@ class RWikiBot
|
|
317
317
|
def backlinks (titles, options = nil)
|
318
318
|
|
319
319
|
# This will get all pages. Limits vary based on user rights of the Bot. Set to bot.
|
320
|
-
|
320
|
+
##@wikibotlogger.debug "BACKLINKS - Preparing request information..."
|
321
321
|
post_me = {'list' => 'backlinks', 'titles' => "#{title}" }
|
322
322
|
|
323
323
|
|
324
324
|
if options != nil
|
325
|
-
|
325
|
+
##@wikibotlogger.debug("BACKLINKS - Additional options added by requestor. Adding to post_me...")
|
326
326
|
options.each_pair do |key, value|
|
327
327
|
post_me[key] = value
|
328
|
-
|
328
|
+
##@wikibotlogger.debug "BACKLINKS - Added #{post_me[key]}"
|
329
329
|
end
|
330
|
-
|
330
|
+
##@wikibotlogger.debug("BACKLINKS - No more additional options. Moving on...")
|
331
331
|
end
|
332
332
|
|
333
333
|
#make the request
|
334
|
-
|
334
|
+
##@wikibotlogger.debug "BACKLINKS - Asking make_request to get backlinks..."
|
335
335
|
backlinks_result = make_request('query', post_me)
|
336
|
-
|
336
|
+
##@wikibotlogger.debug "BACKLINKS - We should have a result now..."
|
337
337
|
return backlinks_result.fetch('backlinks')
|
338
338
|
|
339
339
|
end
|
@@ -348,23 +348,23 @@ class RWikiBot
|
|
348
348
|
def embedded_in (title, options = nil)
|
349
349
|
|
350
350
|
# This will get all pages. Limits vary based on user rights of the Bot. Set to bot.
|
351
|
-
|
351
|
+
##@wikibotlogger.debug "EMBEDDED IN - Preparing request information..."
|
352
352
|
post_me = {'list' => 'embeddedin', 'titles' => "#{title}" }
|
353
353
|
|
354
354
|
|
355
355
|
if options != nil
|
356
|
-
|
356
|
+
##@wikibotlogger.debug("EMBEDDED IN - Additional options added by requestor. Adding to post_me...")
|
357
357
|
options.each_pair do |key, value|
|
358
358
|
post_me[key] = value
|
359
|
-
|
359
|
+
##@wikibotlogger.debug "EMBEDDED IN - Added #{post_me[key]}"
|
360
360
|
end
|
361
|
-
|
361
|
+
##@wikibotlogger.debug("EMBEDDED IN - No more additional options. Moving on...")
|
362
362
|
end
|
363
363
|
|
364
364
|
#make the request
|
365
|
-
|
365
|
+
##@wikibotlogger.debug "EMBEDDED IN - Asking make_request to get backlinks..."
|
366
366
|
embeddedin_result = make_request('query', post_me)
|
367
|
-
|
367
|
+
##@wikibotlogger.debug "EMBEDDED IN - We should have a result now..."
|
368
368
|
return embeddedin_result.fetch('embeddedin')
|
369
369
|
|
370
370
|
end
|
@@ -379,23 +379,23 @@ class RWikiBot
|
|
379
379
|
# def image_embedded_in (title, options = nil) :nodoc:
|
380
380
|
#
|
381
381
|
# # This will get all pages. Limits vary based on user rights of the Bot. Set to bot.
|
382
|
-
#
|
382
|
+
# ##@wikibotlogger.debug "IMAGE EMBEDDED IN - Preparing request information..."
|
383
383
|
# post_me = {'list' => 'embeddedin', 'titles' => "#{title}" }
|
384
384
|
#
|
385
385
|
#
|
386
386
|
# if options != nil
|
387
|
-
#
|
387
|
+
# ##@wikibotlogger.debug("IMAGE EMBEDDED IN - Additional options added by requestor. Adding to post_me...")
|
388
388
|
# options.each_pair do |key, value|
|
389
389
|
# post_me[key] = value
|
390
|
-
#
|
390
|
+
# ##@wikibotlogger.debug "IMAGE EMBEDDED IN - Added #{post_me[key]}"
|
391
391
|
# end
|
392
|
-
#
|
392
|
+
# ##@wikibotlogger.debug("IMAGE EMBEDDED IN - No more additional options. Moving on...")
|
393
393
|
# end
|
394
394
|
#
|
395
395
|
# #make the request
|
396
|
-
#
|
396
|
+
# ##@wikibotlogger.debug "IMAGE EMBEDDED IN - Asking make_request to get backlinks..."
|
397
397
|
# imageembeddedin_result = make_request('query', post_me)
|
398
|
-
#
|
398
|
+
# ##@wikibotlogger.debug "IMAGE EMBEDDED IN - We should have a result now..."
|
399
399
|
# return imageembeddedin_result.fetch('embeddedin')
|
400
400
|
#
|
401
401
|
# end
|
@@ -411,16 +411,16 @@ class RWikiBot
|
|
411
411
|
def info (titles)
|
412
412
|
|
413
413
|
# Basic quqery info
|
414
|
-
|
414
|
+
##@wikibotlogger.debug "INFO - Preparing the query..."
|
415
415
|
post_me = {"prop" => "info", 'titles' => titles}
|
416
416
|
|
417
417
|
# Make the request
|
418
|
-
|
418
|
+
##@wikibotlogger.debug "INFO - Asking make_request to get info"
|
419
419
|
info_result = make_request('query', post_me)
|
420
|
-
|
420
|
+
##@wikibotlogger.debug "INFO - We should have a result set now..."
|
421
421
|
|
422
422
|
# Result processing
|
423
|
-
|
423
|
+
##@wikibotlogger.debug "INFO - Preparing results..."
|
424
424
|
|
425
425
|
return info_result.fetch('pages')
|
426
426
|
|
@@ -439,26 +439,26 @@ class RWikiBot
|
|
439
439
|
def revisions(titles, options = nil)
|
440
440
|
|
441
441
|
# Prepare the request! Notify the logger!
|
442
|
-
|
442
|
+
##@wikibotlogger.debug "REVISIONS - Preparing the requeset..."
|
443
443
|
post_me = {'prop' => 'revisions', 'titles' => titles}
|
444
444
|
|
445
445
|
# Handle any additional options
|
446
446
|
if options != nil
|
447
|
-
|
447
|
+
##@wikibotlogger.debug("REVISIONS - Additional options added by requestor. Adding to post_me...")
|
448
448
|
options.each_pair do |key, value|
|
449
449
|
post_me[key] = value
|
450
|
-
|
450
|
+
##@wikibotlogger.debug "REVISIONS - Added #{post_me[key]}"
|
451
451
|
end
|
452
|
-
|
452
|
+
##@wikibotlogger.debug("REVISIONS - No more additional options. Moving on...")
|
453
453
|
end
|
454
454
|
|
455
455
|
# Make the request. Becuase we care.
|
456
|
-
|
456
|
+
##@wikibotlogger.debug "REVISIONS - Asking make_request to get revision for articles(s) #{titles}"
|
457
457
|
revisions_result = make_request('query', post_me )
|
458
|
-
|
458
|
+
##@wikibotlogger.debug "REVISIONS - We should have a result now..."
|
459
459
|
|
460
460
|
#Process the results
|
461
|
-
|
461
|
+
##@wikibotlogger.debug "REVISIONS - Preparing results..."
|
462
462
|
|
463
463
|
return revisions_result.fetch('pages')
|
464
464
|
|
@@ -474,19 +474,19 @@ class RWikiBot
|
|
474
474
|
# OUTPUT:: A hash of values about site information.
|
475
475
|
def site_info (siprop = 'general')
|
476
476
|
|
477
|
-
|
477
|
+
##@wikibotlogger.debug "SITE INFO - Preparing request information..."
|
478
478
|
|
479
479
|
# Make the request
|
480
480
|
post_me = {"meta" => "siteinfo" , "siprop" => siprop}
|
481
481
|
|
482
482
|
|
483
483
|
#Make the request!
|
484
|
-
|
484
|
+
##@wikibotlogger.debug "SITE INFO - Asking make_request to get site info"
|
485
485
|
siteinfo_result = make_request('query', post_me)
|
486
|
-
|
486
|
+
##@wikibotlogger.debug "SITE INFO - We should have a result of type site info now."
|
487
487
|
|
488
488
|
# Process results
|
489
|
-
|
489
|
+
##@wikibotlogger.debug "SITE INFO - Processing result..."
|
490
490
|
|
491
491
|
if siprop == 'general'
|
492
492
|
return siteinfo_result.fetch('general')
|
@@ -537,22 +537,22 @@ class RWikiBot
|
|
537
537
|
def page_exists? (title)
|
538
538
|
|
539
539
|
# Prepare the request
|
540
|
-
|
540
|
+
##@wikibotlogger.debug "PAGE EXISTS? - Preparing request information..."
|
541
541
|
post_me = {'titles' => title}
|
542
542
|
|
543
543
|
#Make the request
|
544
|
-
|
544
|
+
##@wikibotlogger.debug "PAGE EXISTS? - Asking make_request to verify page existence..."
|
545
545
|
page_exists_result = make_request('query', post_me)
|
546
|
-
|
546
|
+
##@wikibotlogger.debug "PAGE EXISTS? - We should have a result now..."
|
547
547
|
|
548
|
-
|
548
|
+
##@wikibotlogger.debug "PAGE EXISTS? - Processing result..."
|
549
549
|
|
550
550
|
|
551
551
|
if page_exists_result.fetch('pages')[0].has_key?('missing')
|
552
|
-
|
552
|
+
##@wikibotlogger.debug "PAGE EXISTS? - The page #{title} does NOT exist. Sorry."
|
553
553
|
return false
|
554
554
|
else
|
555
|
-
|
555
|
+
##@wikibotlogger.debug "PAGE EXISTS? - The page #{title} DOES exist. You lucky, lucky bot."
|
556
556
|
return true
|
557
557
|
end
|
558
558
|
|
@@ -575,16 +575,16 @@ class RWikiBot
|
|
575
575
|
def pageid_to_title(id)
|
576
576
|
|
577
577
|
# Prepare the request! Notify the logger!
|
578
|
-
|
578
|
+
##@wikibotlogger.debug "PAGEID TO TITLE - Preparing the requeset..."
|
579
579
|
post_me = {'prop' => 'info', 'pageids' => id}
|
580
580
|
|
581
581
|
# Make the request. Becuase we care.
|
582
|
-
|
582
|
+
##@wikibotlogger.debug "PAGEID TO TITLE - Asking make_request to get revision for pageid #{id}"
|
583
583
|
id_result = make_request('query', post_me )
|
584
|
-
|
584
|
+
##@wikibotlogger.debug "PAGEID TO TITLE - We should have a result now..."
|
585
585
|
|
586
586
|
#Process the results
|
587
|
-
|
587
|
+
##@wikibotlogger.debug "PAGEID TO TITLE - Preparing results..."
|
588
588
|
|
589
589
|
return id_result.fetch('pages')[0].fetch('title')
|
590
590
|
|
@@ -613,36 +613,37 @@ class RWikiBot
|
|
613
613
|
post_this.each_pair do |key, value|
|
614
614
|
post_string << "#{key}=#{value}&"
|
615
615
|
end
|
616
|
-
|
617
|
-
|
616
|
+
##@wikibotlogger.info("MAKE REQUEST - Post String is: #{post_string}")
|
617
|
+
##@wikibotlogger.debug "MAKE REQUEST - Sending request to: #{@config.fetch('uri')}"
|
618
618
|
|
619
619
|
#Send the actual request
|
620
|
-
|
620
|
+
##@wikibotlogger.debug "MAKE REQUEST - Sending request..."
|
621
621
|
#'User-agent' => 'RWikiBot/0.1'
|
622
|
-
resp = @http.post( @config.fetch('uri').path , post_string , {'User-agent'=>'RWikiBot/1.0', 'Cookie' => bake(@config.fetch('cookie')) } ) #
|
623
|
-
@
|
624
|
-
|
625
|
-
|
622
|
+
# resp = @http.post( @config.fetch('uri').path , post_string , {'User-agent'=>'RWikiBot/1.0', 'Cookie' => bake(@config.fetch('cookie')) } ) #
|
623
|
+
resp = @http.get( "/wiki/api.php?#{post_string}" , {'User-agent'=>'RWikiBot/1.0', 'Cookie' => bake(@config.fetch('cookie')) } ) #
|
624
|
+
##@wikibotlogger.debug "MAKE REQUEST - Response: "
|
625
|
+
##@wikibotlogger.debug resp.body
|
626
|
+
##@wikibotlogger.debug "MAKE REQUEST - End Response "
|
626
627
|
result = YAML.load(resp.body)
|
627
628
|
|
628
629
|
#Process response
|
629
|
-
|
630
|
+
##@wikibotlogger.debug "MAKE REQUEST - Response received. Processing..."
|
630
631
|
return_result = result.fetch(action)
|
631
632
|
|
632
633
|
# A small check to make sure we don't need to save cookie data. Because usually, we don't
|
633
634
|
if @config.fetch('logged_in') == FALSE
|
634
635
|
@config['cookie'] = resp.header['set-cookie'] if @config.fetch('cookie').nil?
|
635
|
-
|
636
|
+
##@wikibotlogger.debug "MAKE REQUEST - Received login cookie. Cookie is: #{resp.header['set-cookie']}"
|
636
637
|
end
|
637
638
|
|
638
639
|
#Return the response
|
639
|
-
|
640
|
+
##@wikibotlogger.debug "MAKE REQUEST - Response cleaned. Returning result."
|
640
641
|
return return_result
|
641
642
|
|
642
643
|
# The short form is that the API's error message causes an ArgumentError, so we gotta handle that. I notified MediaWiki
|
643
644
|
rescue ArgumentError
|
644
|
-
|
645
|
-
|
645
|
+
##@wikibotlogger.error "MAKE REQUEST - The request has failed."
|
646
|
+
##@wikibotlogger.error "MAKE REQUEST - Error is: #{$!}"
|
646
647
|
|
647
648
|
raise ArgumentError, "Problem processing returned YAML result"
|
648
649
|
end
|
@@ -657,12 +658,12 @@ class RWikiBot
|
|
657
658
|
# Take the dough and get my three elements out
|
658
659
|
|
659
660
|
if @config.fetch('logged_in') == TRUE
|
660
|
-
|
661
|
-
return "#{dough.fetch(@config.fetch('wikicookieprefix')+'UserID')}; #{dough.fetch(@config.fetch('wikicookieprefix')+'UserName')}; #{dough.fetch(@config.fetch('wikicookieprefix')+'Token')}"
|
662
|
-
|
661
|
+
##@wikibotlogger.debug "BAKE - Baking a cookie... Smells like wiki."
|
662
|
+
# return "#{dough.fetch(@config.fetch('wikicookieprefix')+'UserID')}; #{dough.fetch(@config.fetch('wikicookieprefix')+'UserName')}; #{dough.fetch(@config.fetch('wikicookieprefix')+'Token')}"
|
663
|
+
return "#{dough.fetch('wikidb_UserID')}; #{dough.fetch('wikidb_UserName')}; #{dough.fetch('wikidb_Token')}"
|
663
664
|
|
664
665
|
else
|
665
|
-
|
666
|
+
##@wikibotlogger.debug "BAKE - No cookies to bake this time."
|
666
667
|
return ""
|
667
668
|
end
|
668
669
|
|
metadata
CHANGED
@@ -1,10 +1,10 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
|
-
rubygems_version: 0.
|
2
|
+
rubygems_version: 0.9.2
|
3
3
|
specification_version: 1
|
4
4
|
name: rwikibot
|
5
5
|
version: !ruby/object:Gem::Version
|
6
|
-
version: 1.0.
|
7
|
-
date: 2007-03-
|
6
|
+
version: 1.0.9
|
7
|
+
date: 2007-03-21 00:00:00 -05:00
|
8
8
|
summary: A library for creating MediaWiki bots.
|
9
9
|
require_paths:
|
10
10
|
- lib
|
@@ -25,6 +25,7 @@ required_ruby_version: !ruby/object:Gem::Version::Requirement
|
|
25
25
|
platform: ruby
|
26
26
|
signing_key:
|
27
27
|
cert_chain:
|
28
|
+
post_install_message:
|
28
29
|
authors:
|
29
30
|
- Eddie Roger
|
30
31
|
files:
|