PASTEBIN
| #1 paste tool since 2002
create new paste
tools
api
archive
real-time
faq
PASTEBIN
create new paste
trending pastes
sign up
login
my settings
my profile
Public Pastes
How can I update i...
0 sec ago
Untitled
C# | 1 sec ago
Untitled
Java | 3 sec ago
UITableView fixed ...
6 sec ago
How to avoid scrol...
12 sec ago
f
25 sec ago
Untitled
16 sec ago
Page.User.Identity...
19 sec ago
New Paste
#!/usr/bin/perl # # This program is designed to implement twittering. Isn't # that awesome? It's intended for monitoring purposes, # and similar activities. # # This program doesn't require XML parsers cuz I am cheating # and not using one. I know what to look for, so I'm # simply parsing out the response. # # Written by Gabriel Cain, <gabriel@dreamingcrow.com> # Licensed under the GNU GPL v2. use strict; use lib '/usr/lib/mon/alert.d'; use Data::Dumper; use Getopt::Std; use Twitter; # optionally support curses #eval { use Term::ANSIColor qw(:constants); $Term::ANSIColor::AUTORESET = 1; }; #my $colorEnabled = ($@ ) ? 0 : 1; #if( $colorEnabled ) { # print BLUE, "\t\t\t *** ANSI COLOR ENABLED ***\n", RESET; #} # Set our options # -f = alternate config file # -d = Remove last twitter # -D <name> = d <Name> message # -F <name> = follow <Name> # -r = get recent stuff # -x = no color # Process command-line args my %o; #getopts('xhrdD:F:f:', \%o); getopts ("S:s:g:HurD:f:F:", \%o); my $summary=<STDIN>; chomp $summary; $summary = $o{S} if (defined $o{S}); my $ALERT = $o{u} ? "UPALERT" : "ALERT"; my $message = "$ALERT $o{g}/$o{s}: $summary"; #my $DEBUG=1; #print "DBG: $message\n" if ($DEBUG>0); #exit; #if( $o{x} ) { # $colorEnabled = 0; #} # Read our configuration from $HOME/.twitterrc # first line = username, 2nd line = password my $tw_rc = $o{f} || "$ENV{HOME}/.twitterrc"; if( ! -f $tw_rc ) { doCreateTwitterRC(); } die("$tw_rc: $!") unless -f $tw_rc; open(T,"<$tw_rc") or die("Failed to open $tw_rc: $!"); my $tw_user = <T>; my $tw_pass = <T>; close(T); # Eat useless newlines. chomp( $tw_user, $tw_pass ); # Test for -d (delete twit) if( $o{d}) { print "Sorry, delete isn't implemented yet.\n"; exit 0; } # Direct & empty is contraindicated if( length $o{D} == 0 && defined $o{D} ) { print "Empty direct recipient not ok.\n"; exit; } # fail if we're not fetching & no message supplied #if( ($#ARGV < 0 && ! $o{r}) || $o{h} ) { if( $o{H} ) { print << "END"; -=-=-=-=-=-=< Twitter Command Line Client >-=-=-=-=-=-=- Written by Gabriel Cain, <gabriel\@dreamingcrow.com> Hacked for MON alerts by Sotiris Tsimbonis, Apr 2009. Usage: twitter.pl <message> twitter.pl -r twitter.pl [options] Options: -f Read alternate config file, default is \$HOME/.twitterrc -D <name> Send a direct message to a user -F <name> Follow a user -r Get friends timeline (twenty most recent) -S <summary> MON alert summary -s <servicename> MON service -g <groupname> MON group -u MON Upalert This program is licensed under the GNU GPL v2. Enjoy it. END exit; } # Build twitter message. my $twit; $twit = "d $o{D} " if $o{D}; # direct message if -D <name> #$twit .= join ' ', @ARGV; $twit .= $message; # Log messages make the baby twitter cry if( length $twit > 140 ) { #warn("Warning: Message longer than 140 characters\n"); } # Follow if( defined $o{F} && length $o{F} > 1 ) { $twit = "follow $o{F}" } my $res; my $T = new Twitter( $tw_user, $tw_pass ); die("Object couldn't be made\n") unless $T; if( $o{r}) { $res = $T->whatsup(); } else { $res = $T->say( $twit ); } # Check response, and if we failed, complain about it. if( ! $res->is_success ) { print "Request failed: ".$res->status_line."\n"; exit; } # If we're reading our "friends" page, then we need to spit # back a list of what our friends say. if( $o{r}) { # Parse content for the items and dates. my @items; my @content = split /<item>/, $res->content; foreach my $c (@content) { # examine each <item> .. </item> block for what we # need. my $i = {}; $c =~ /<description>(.*)<\/description>/mi; $i->{status} = $1; $c =~ /<pubDate>(.*)<\/pubDate>/mi; $i->{date} = $1; next if $i->{date} =~ /Twitter updates from/; push @items, $i; } # Spit them out in reverse order -- newest at bottom foreach ( reverse @items ) { my $a = sprintf "%s", $_->{date}; my ($u,$s) = split /:/, $_->{status}, 2; #if( $colorEnabled ) { # print GREEN, $a, RESET, ":", RED, $u, # RESET, ":", CYAN, $s, "\n", RESET; #} #else { print $a, ":", $u, ":", $s, "\n"; #} } } sub doCreateTwitterRC { # create $HOME/.twitterrc my ($l,$p); open( R, ">$ENV{HOME}/.twitterrc") or die("Couldn't create .twitterrc.\n"); $| = 1; print "What's your twitter login? "; chomp( $l = <> ); print "What's your twitter password? "; chomp( $p = <> ); # should have login/passwd print R "$l\n$p\n"; close(R); }
Optional Paste Settings
Syntax Highlighting:
None
Bash
C
C#
C++
CSS
HTML
HTML 5
Java
JavaScript
Lua
None
Perl
PHP
Python
Rails
-------------
4CS
6502 ACME Cross Assembler
6502 Kick Assembler
6502 TASM/64TASS
ABAP
ActionScript
ActionScript 3
Ada
ALGOL 68
Apache Log
AppleScript
APT Sources
ASM (NASM)
ASP
autoconf
Autohotkey
AutoIt
Avisynth
Awk
BASCOM AVR
Bash
Basic4GL
BibTeX
Blitz Basic
BNF
BOO
BrainFuck
C
C for Macs
C Intermediate Language
C#
C++
C++ (with QT extensions)
C: Loadrunner
CAD DCL
CAD Lisp
CFDG
ChaiScript
Clojure
Clone C
Clone C++
CMake
COBOL
CoffeeScript
ColdFusion
CSS
Cuesheet
D
DCS
Delphi
Delphi Prism (Oxygene)
Diff
DIV
DOS
DOT
E
ECMAScript
Eiffel
Email
EPC
Erlang
F#
Falcon
FO Language
Formula One
Fortran
FreeBasic
FreeSWITCH
GAMBAS
Game Maker
GDB
Genero
Genie
GetText
Go
Groovy
GwBasic
Haskell
HicEst
HQ9 Plus
HTML
HTML 5
Icon
IDL
INI file
Inno Script
INTERCAL
IO
J
Java
Java 5
JavaScript
jQuery
KiXtart
Latex
Liberty BASIC
Linden Scripting
Lisp
LLVM
Loco Basic
Logtalk
LOL Code
Lotus Formulas
Lotus Script
LScript
Lua
M68000 Assembler
MagikSF
Make
MapBasic
MatLab
mIRC
MIX Assembler
Modula 2
Modula 3
Motorola 68000 HiSoft Dev
MPASM
MXML
MySQL
newLISP
None
NullSoft Installer
Oberon 2
Objeck Programming Langua
Objective C
OCalm Brief
OCaml
OpenBSD PACKET FILTER
OpenGL Shading
Openoffice BASIC
Oracle 11
Oracle 8
Oz
Pascal
PAWN
PCRE
Per
Perl
Perl 6
PHP
PHP Brief
Pic 16
Pike
Pixel Bender
PL/SQL
PostgreSQL
POV-Ray
Power Shell
PowerBuilder
ProFTPd
Progress
Prolog
Properties
ProvideX
PureBasic
PyCon
Python
q/kdb+
QBasic
R
Rails
REBOL
REG
Robots
RPM Spec
Ruby
Ruby Gnuplot
SAS
Scala
Scheme
Scilab
SdlBasic
Smalltalk
Smarty
SQL
SystemVerilog
T-SQL
TCL
Tera Term
thinBasic
TypoScript
Unicon
UnrealScript
Vala
VB.NET
VeriLog
VHDL
VIM
Visual Pro Log
VisualBasic
VisualFoxPro
WhiteSpace
WHOIS
Winbatch
XBasic
XML
Xorg Config
XPP
YAML
Z80 Assembler
ZXBasic
Paste Expiration:
Never
10 Minutes
1 Hour
1 Day
1 Month
Paste Exposure:
Public
Unlisted
Private (members only)
Paste Name / Title:
Hello
Guest
Sign Up
or
Login
You are currently not logged in, this means you can not edit or delete anything you paste.
Sign Up
or
Login