OSDN Git Service

add Tweet class
authorISHIKAWA Mutsumi <ishikawa@hanzubon.jp>
Wed, 31 Oct 2012 16:54:05 +0000 (01:54 +0900)
committerISHIKAWA Mutsumi <ishikawa@hanzubon.jp>
Wed, 31 Oct 2012 16:54:05 +0000 (01:54 +0900)
lib/Mubot4FB/Tweet.pm [new file with mode: 0644]

diff --git a/lib/Mubot4FB/Tweet.pm b/lib/Mubot4FB/Tweet.pm
new file mode 100644 (file)
index 0000000..fd1666e
--- /dev/null
@@ -0,0 +1,38 @@
+#!/usr/bin/perl
+#
+# Copyright (c) 2012 ISHIKAWA Mutsumi <ishikawa@hanzubon.jp>
+# This program is covered by the GNU General Public License 2
+#
+package Mubot4FB::Tweet;
+
+use strict;
+use utf8;
+
+use Data::Dumper;
+
+use base 'Mubot4FB::Common';
+
+sub init {
+       my ($me) = @_;
+
+       $me->{twitter} = Net::Twitter::Lite->new(consumer_key => $me->{cfg}->{'twitter_consumer_key'},
+                                                consumer_secret => $cfg{'twitter_consumer_secret'},
+                                                legacy_list_api => 0);
+
+       $me->{twitter}->access_token($me->cfg{'twitter_access_token'});
+       $me->{twitter}->access_token_secret($me->cfg{'twitter_access_secret'});
+
+       return $me->{twitter};
+}
+
+sub publish {
+       my ($me, $text, $uri) = @_;
+
+       $text = substr($text, 0, 110) . '...' if (length($text) > 110);
+
+       eval {$tw->update($text . ' ' . $uri);};
+}
+
+sub remove {
+
+}