+sub update_away {
+ my $data = shift;
+
+ if ( Irssi::settings_get_bool("tweet_to_away")
+ and $data !~ /\@\w/
+ and $data !~ /^[dD] / )
+ {
+ my $server =
+ Irssi::server_find_tag( Irssi::settings_get_str("bitlbee_server") );
+ if ($server) {
+ $server->send_raw("away :$data");
+ return 1;
+ } else {
+ ¬ice( "Can't find bitlbee server.",
+ "Update bitlbee_server or disable tweet_to_away" );
+ return 0;
+ }
+ }
+
+ return 0;
+}
+
+sub too_long {
+ my $data = shift;
+
+ if ( length $data > 140 ) {
+ ¬ice(
+ "Tweet too long (" . length($data) . " characters) - aborted" );
+ return 1;
+ }
+
+ return 0;
+}
+
+sub valid_username {
+ my $username = shift;
+
+ unless ( exists $twits{$username} ) {
+ ¬ice("Unknown username $username");
+ return 0;
+ }
+
+ return 1;
+}
+
+sub logged_in {
+ my $obj = shift;
+ unless ($obj) {
+ ¬ice("Not logged in! Use /twitter_login username pass!");
+ return 0;
+ }
+
+ return 1;
+}
+