comparison xsotter_mail.rb @ 7:ef8cc6249d53

delete 140 characters or less
author KAMURA Sota <c109047@e.koeki-u.ac.jp>
date Tue, 07 Feb 2012 21:09:09 +0900
parents 6c763cb4ea40
children 2ebeaae57e96
comparison
equal deleted inserted replaced
6:6c763cb4ea40 7:ef8cc6249d53
4 4
5 require '/home/irhome/c109/c109047/xsotter/xsotter_class' 5 require '/home/irhome/c109/c109047/xsotter/xsotter_class'
6 6
7 sender = ENV['SENDER'] 7 sender = ENV['SENDER']
8 rcpt = ENV['RECIPIENT'] 8 rcpt = ENV['RECIPIENT']
9 body = "" #Array.new 9 body = ""
10 if sender == nil || rcpt === nil 10 if sender == nil || rcpt === nil
11 exit 0 11 exit 0
12 elsif/.*@.*/ !~ sender 12 elsif/.*@.*/ !~ sender
13 exit 0 13 exit 0
14 end 14 end
15 15
16 while line = gets 16 while line = gets
17 f=1 if /^$/=~line 17 f=1 if /^$/=~line
18 if f ==1 18 if f ==1
19 body += line 19 body += line
20 else
21 subject = line if /Subject/ =~ line
20 end 22 end
21 end 23 end
24
22 body = NKF.nkf('-e', body) 25 body = NKF.nkf('-e', body)
23 com=["-T", body] 26 subject = NKF.nkf('-e', subject).split(/:/)[1]
27
28
29 count = 0
30 post=""
31 subject += body
32 subject.split(//).each{|str|
33 post += str
34 break if 139 == count += 1
35 }
36 puts post = NKF.nkf('-w', post)
37 com=["-T", post]
24 38
25 #com=["-T", "test"] 39 #com=["-T", "test"]
26 xsotter=Xsotter.new("/home/irhome/c109/c109047/xsotter/c109047_token") 40 xsotter=Xsotter.new("/home/irhome/c109/c109047/xsotter/c109047_token")
27 xsotter.comand(com) 41 xsotter.comand(com)

yatex.org