/tools/nopaste.pl

http://github.com/PerlGameDev/SDL · Perl · 82 lines · 52 code · 21 blank · 9 comment · 4 complexity · 91d3541ef364c6b6ca18860b138bf15b MD5 · raw file

  1. #!perl
  2. # Copyright (C) 2008, Parrot Foundation.
  3. # $Id: nopaste.pl 38612 2009-05-08 18:30:25Z Infinoid $
  4. use 5.008;
  5. use strict;
  6. use warnings;
  7. use WWW::Mechanize;
  8. use Getopt::Std;
  9. use Pod::Usage;
  10. use Data::Dumper;
  11. my $server = 'scsys.co.uk';
  12. my $url = "http://$server:8001/paste";
  13. my $opt = {
  14. c => '#sdl', # channel
  15. n => getlogin || getpwuid($<) || 'someone', # name
  16. t => undef, # title
  17. };
  18. getopt( 'c:n:t:', $opt );
  19. pod2usage(2)
  20. unless defined $opt->{t};
  21. my $text;
  22. while (<>) { $text .= $_; }
  23. my $mech = WWW::Mechanize->new(
  24. cookie_jar => undef,
  25. autocheck => 1,
  26. );
  27. $mech->get($url);
  28. $mech->submit_form(
  29. form_name => 'pasteForm',
  30. fields => {
  31. channel => $opt->{c},
  32. nick => $opt->{n},
  33. summary => $opt->{t},
  34. paste => $text,
  35. },
  36. button => 'Paste it',
  37. );
  38. my @link = $mech->links;
  39. print "Your paste can be found at ", $link[0]->url, "\n";
  40. =head1 NAME
  41. tools/dev/nopaste.pl - paste the contents of a file via a pastebot server
  42. =head1 SYNOPSIS
  43. nopaste.pl -t "TITLE" [ -c CHANNEL ] [ -n NAME ] [ FILENAME ]
  44. TITLE the title of the paste
  45. CHANNEL the irc channel (defaults to #parrot)
  46. NAME the username (defaults to username or 'someone')
  47. FILENAME the name of the file to paste (defaults to STDIN)
  48. =head1 DESCRIPTION
  49. This program can be used to paste the contents of a file on a pastebot server
  50. -- specifically, B<nopaste.snit.ch> -- for immediate linkage on an IRC channel --
  51. by default, B<#sdl>.
  52. =head1 AUTHOR
  53. Originally written by particle, with subsequent contributions to functionality
  54. by LimbicRegion, paultcochrane and cotto.
  55. =cut
  56. # Local Variables:
  57. # mode: cperl
  58. # cperl-indent-level: 4
  59. # fill-column: 100
  60. # End:
  61. # vim: expandtab shiftwidth=4: