[前][次][番号順一覧][スレッド一覧]

sylpheed-jp:284

From: Kazuhiro NISHIYAMA <zn@xxxxxxxxxx>
Date: Mon, 22 Jan 2001 02:07:28 +0900
Subject: [sylpheed-jp:00284] Re: News posting is enabled

On Sat, 6 Jan 2001 16:58:44 +0900
Hiroyuki Yamamoto <hiro-y@xxxxxxxxxx> wrote:
> # スクリプトを組んで ~/.sylpheed/folderlist.xml を自動生成する
> # という手もありますが :)

0.4.50以降になってから結構経ってますが、作ってみました。


</folderlist>の直前に追加するものを出力するプログラムと
accountrcに追加するものを出力するプログラムです。

accountrcに追加する方は一度実行してみて大丈夫そうだったら
>> ~/.sylpheed/accountrc で追加すればいいと思います。


#!/usr/bin/ruby
# from newsfolder to folderlist.xml
#
# This program is free software; you can redistribute it and/or
# modify it under the same terms as Ruby itself.
 
folderlist = File.expand_path('~/.sylpheed/folderlist.xml')
newsfolder = File.expand_path('~/.sylpheed/newsfolder')
 
last_account_id = 0
 
if File.exist? folderlist
  File.foreach(folderlist) do |line|
    case line
    when /<folder .+ account_id="(\d+)">/
      last_account_id = $1.to_i
    end
  end
end
 
puts %Q{    <folder type="news" name="news" account_id="#{last_account_id+1}">}
 
newsgroup = nil
File.foreach(newsfolder) do |line|
  case line
  when /\//
    newsgroup = $'.chomp
  when /(\d+) (\d+) (\d+) (\d+)/
    if newsgroup
      puts %Q{        <folderitem type="normal" name="#{newsgroup}" path="#{newsgroup}" mtime="#$1" new="#$2" unread="#$3" total="#$4" />}
    end
  end
end
 
puts %Q{    </folder>}
 
__END__


#!/usr/bin/ruby
# from newsfolder to accountrc
#
# This program is free software; you can redistribute it and/or
# modify it under the same terms as Ruby itself.
 
accountrc = File.expand_path('~/.sylpheed/accountrc')
newsfolder = File.expand_path('~/.sylpheed/newsfolder')
 
default_account_id = 0
last_account_id = 0
accounts = []
 
File.foreach(accountrc) do |line|
  case line.chomp
  when /\[Account: (\d+)\]/
    last_account_id = $1.to_i
    accounts[last_account_id] = Hash.new
  when 'is_default=1'
    default_account_id = last_account_id
  when /=/
    accounts[last_account_id][$`] = $'
  end
end
 
nntp_server = nil
File.foreach(newsfolder) do |line|
  nntp_server = line.chomp
  break
end
 
puts "[Account: #{last_account_id+1}]
account_name=#{nntp_server}
name=#{accounts[default_account_id]['name']}
address=#{accounts[default_account_id]['address']}
protocol=4
nntp_server=#{nntp_server}
"
 
__END__


-- 
ZnZ(ゼット エヌ ゼット)
西山和広(Kazuhiro NISHIYAMA)


[前][次][番号順一覧][スレッド一覧]

       219 2001-01-06 02:23 [hiro-y@xxxxxxxxxx   ] News posting is enabled                 
       220 2001-01-06 02:28 ┗[hiro-y@xxxxxxxxxx   ]                                       
       221 2001-01-06 16:51  ┗[y-aki@xxxxxxxxxx    ]                                     
       222 2001-01-06 16:58   ┗[hiro-y@xxxxxxxxxx   ]                                   
       223 2001-01-07 00:47    ┣[y-aki@xxxxxxxxxx    ]                                 
->     284 2001-01-22 02:07    ┗[zn@xxxxxxxxxx       ]