PageRenderTime 49ms CodeModel.GetById 37ms app.highlight 9ms RepoModel.GetById 2ms app.codeStats 0ms

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