No pastes for you but will not send to #sdl
[sdlgit/SDL_perl.git] / tools / nopaste.pl
CommitLineData
d2b786f8 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;
13
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
28
29my $text; while(<>) { $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 (defined $opt->{c} ?
41 (channel => $opt->{c}) :
42 (channel => '#sdl' )
43 ),
44 nick => $opt->{n},
45 summary => $opt->{t},
46 paste => $text,
47 },
48 button => 'Paste it',
49);
50
51my @link = $mech->links;
52print "Your paste can be found at ", $link[0]->url, "\n";
53
54
55=head1 NAME
56
57tools/dev/nopaste.pl - paste the contents of a file via a pastebot server
58
59=head1 SYNOPSIS
60
61 nopaste.pl -t "TITLE" [ -c CHANNEL ] [ -n NAME ] [ FILENAME ]
62
63 TITLE the title of the paste
64 CHANNEL the irc channel (defaults to #parrot)
65 NAME the username (defaults to username or 'someone')
66 FILENAME the name of the file to paste (defaults to STDIN)
67
68=head1 DESCRIPTION
69
70This program can be used to paste the contents of a file on a pastebot server
71-- specifically, B<nopaste.snit.ch> -- for immediate linkage on an IRC channel --
72by default, B<#sdl>.
73
74=head1 AUTHOR
75
76Originally written by particle, with subsequent contributions to functionality
77by LimbicRegion, paultcochrane and cotto.
78
79=cut
80
81# Local Variables:
82# mode: cperl
83# cperl-indent-level: 4
84# fill-column: 100
85# End:
86# vim: expandtab shiftwidth=4: