From 1f4b33a59885f656a63a048d7f87c5c3f743b79c Mon Sep 17 00:00:00 2001 From: Matthew Barksdale Date: Wed, 2 Feb 2011 14:54:32 -0500 Subject: [PATCH] Make Bitly use its own block. Please note that you now need to change your config to block style with bitly:user and bitly:key to work --- modules/Bitly.pm | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/modules/Bitly.pm b/modules/Bitly.pm index b5d9002..9a55cec 100644 --- a/modules/Bitly.pm +++ b/modules/Bitly.pm @@ -12,7 +12,7 @@ use LWP::UserAgent; sub _init { # Check for required configuration values. - if (!(conf_get('bitly_user'))[0][0] or !(conf_get('bitly_key'))[0][0]) { + if (!(conf_get('bitly:user'))[0][0] or !(conf_get('bitly:key'))[0][0]) { err(2, "Please verify that you have bitly_user and bitly_key defined in your configuration file.", 0); return 0; } @@ -66,7 +66,7 @@ sub shorten notice($data{svr}, $data{nick}, trans("Not enough parameters")."."); return 0; } - my ($surl, $user, $key) = ($args[0], (conf_get('bitly_user'))[0][0], (conf_get('bitly_key'))[0][0]); + my ($surl, $user, $key) = ($args[0], (conf_get('bitly:user'))[0][0], (conf_get('bitly:key'))[0][0]); my $url = "http://api.bit.ly/v3/shorten?version=3.0.1&longUrl=".$surl."&apiKey=".$key."&login=".$user."&format=txt"; # Get the response via HTTP. my $response = $ua->get($url); @@ -102,7 +102,7 @@ sub reverse notice($data{svr}, $data{nick}, trans("Not enough parameters")."."); return 0; } - my ($surl, $user, $key) = ($args[0], (conf_get('bitly_user'))[0][0], (conf_get('bitly_key'))[0][0]); + my ($surl, $user, $key) = ($args[0], (conf_get('bitly:user'))[0][0], (conf_get('bitly:key'))[0][0]); my $url = "http://api.bit.ly/v3/expand?version=3.0.1&shortURL=".$surl."&apiKey=".$key."&login=".$user."&format=txt"; # Get the response via HTTP. my $response = $ua->get($url); @@ -145,8 +145,10 @@ URL using the bit.ly shortening service API. Add Bitly to module auto-load and the following to your configuration file: - bitly_user ""; - bitly_key ""; + bitly { + user ""; + key ""; + } =back @@ -154,8 +156,10 @@ Add Bitly to module auto-load and the following to your configuration file: =over - bitly_user "JohnSmith"; - bitly_key "A_a95929f19402a0s9301041f0f29581089"; + bitly { + user "JohnSmith"; + key "A_a95929f19402a0s9301041f0f29581089"; + } !shorten http://www.google.com URL: http://bit.ly/eFdSkG