termtter 1.1.1 → 1.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/Rakefile CHANGED
@@ -16,7 +16,7 @@ Gem::Specification.new do |s|
16
16
  s.version = '#{Termtter::VERSION}'
17
17
  s.summary = "Terminal based Twitter client"
18
18
  s.description = "Termtter is a terminal based Twitter client"
19
- s.files = %w( #{Dir['lib/**/*.rb'].join(' ')}
19
+ s.files = %w( #{Dir['lib/**/*.rb', 'lib/**/*.erb'].join(' ')}
20
20
  #{Dir['spec/**/*.rb'].join(' ')}
21
21
  #{Dir['test/**/*.rb', 'test/**/*.json'].join(' ')}
22
22
  README.rdoc
@@ -33,10 +33,6 @@ class TermtterIrcGateway < Net::IRC::Server::Session
33
33
  def initialize(*args)
34
34
  super
35
35
  @@listners << self
36
- Thread.start do
37
- sleep 1
38
- self.call(@@last_statuses || [], :update_friends_timeline)
39
- end
40
36
  end
41
37
 
42
38
  def call(statuses, event)
@@ -49,25 +45,23 @@ class TermtterIrcGateway < Net::IRC::Server::Session
49
45
  end
50
46
 
51
47
  statuses.each do |s|
52
- post s.user.screen_name, msg_type, main_channel, s.text
48
+ post s.user.screen_name, msg_type, main_channel, [s.text, s.id].join(' ')
53
49
  end
54
50
  end
55
51
 
56
52
  def on_message(m)
57
- begin
58
- termtter_command = m.command.downcase + ' ' + m.params.join(' ')
59
- unless Termtter::Client.find_commands(termtter_command).empty?
60
- post '#termtter', NOTICE, main_channel, '> ' + termtter_command
61
- Termtter::Client.call_commands(termtter_command)
62
- end
63
- rescue Termtter::CommandNotFound => e
64
- super
53
+ termtter_command = m.command.downcase + ' ' + m.params.join(' ')
54
+ unless Termtter::Client.find_commands(termtter_command).empty?
55
+ post '#termtter', NOTICE, main_channel, '> ' + termtter_command
56
+ Termtter::Client.call_commands(termtter_command)
65
57
  end
66
58
  end
67
59
 
68
60
  def on_user(m)
69
61
  super
70
62
  post @prefix, JOIN, main_channel
63
+ post server_name, MODE, main_channel, "+o", @prefix.nick
64
+ self.call(@@last_statuses || [], :update_friends_timeline)
71
65
  end
72
66
 
73
67
  def on_privmsg(m)
@@ -0,0 +1,11 @@
1
+ # -*- coding: utf-8 -*-
2
+
3
+ config.plugins.mark.set_default(
4
+ :text, '<on_green>' + (' ' * 30) + '#mark' + (' ' * 30) + '</on_green>')
5
+
6
+ Termtter::Client.register_command(
7
+ :name => :mark, :alias => :m,
8
+ :exec => lambda {|arg|
9
+ puts TermColor.parse(config.plugins.mark.text)
10
+ }
11
+ )
@@ -38,7 +38,7 @@ module Termtter::Client
38
38
  :exec_proc => lambda {|arg|
39
39
  unless arg.empty?
40
40
  result = Termtter::API.twitter.update(arg)
41
- puts "updated => ##{result.id} #{result.text}"
41
+ puts TermColor.parse("updated => #{result.text} <90>#{result.id}</90>")
42
42
  end
43
43
  },
44
44
  :completion_proc => lambda {|cmd, args|
@@ -61,7 +61,7 @@ module Termtter::Client
61
61
  end
62
62
  if id
63
63
  result = Termtter::API.twitter.remove_status(id)
64
- puts "deleted => ##{result.id} #{result.text}"
64
+ puts TermColor.parse("deleted => #{result.text} <90>#{result.id}</90>")
65
65
  end
66
66
  },
67
67
  :help => ['delete,del [STATUS ID]', 'Delete a status']
@@ -451,9 +451,10 @@ module Termtter::Client
451
451
  update_with_user_and_id(text, user.screen_name, id) if user
452
452
  public_storage.delete :log4re
453
453
  when /^\s*(\d+)\s+(.+)$/
454
- id, text = $1, $2
455
- user = public_storage[:log].select {|l| l.id == id.to_i }.first.user
456
- update_with_user_and_id(text, user.screen_name, id) if user
454
+ s = Termtter::API.twitter.show($1) rescue nil
455
+ if s
456
+ update_with_user_and_id($2, s.user.screen_name, id)
457
+ end
457
458
  when /^\s*@(\w+)/
458
459
  in_reply_to_status_id = Termtter::API.twitter.user($1).status.id rescue nil
459
460
  params = in_reply_to_status_id ? {:in_reply_to_status_id => in_reply_to_status_id} : {}
@@ -497,10 +498,9 @@ module Termtter::Client
497
498
  )
498
499
 
499
500
  def self.update_with_user_and_id(text, username, id)
500
- text = ERB.new("@#{username} #{text}").result(binding).gsub(/\n/, ' ')
501
+ text = "@#{username} #{text}"
501
502
  result = Termtter::API.twitter.update(text, {'in_reply_to_status_id' => id})
502
- puts "=> #{text}"
503
- result
503
+ puts TermColor.parse("replied => #{result.text} <90>#{result.id}</90>")
504
504
  end
505
505
 
506
506
  =begin
@@ -4,14 +4,12 @@ require 'termcolor'
4
4
  require 'erb'
5
5
  require 'tempfile'
6
6
 
7
- config.plugins.stdout.set_default(
8
- :colors,
9
- [:none, :red, :green, :yellow, :blue, :magenta, :cyan])
7
+ config.plugins.stdout.set_default(:colors, (31..36).to_a + (91..96).to_a)
10
8
  config.plugins.stdout.set_default(
11
9
  :timeline_format,
12
- '<90><%=time%></90> <<%=status_color%>><%=status%></<%=status_color%>> <90><%=id%></90>')
13
- config.plugins.stdout.set_default(:search_highlight_format, '<on_magenta><white>\1</white></on_magenta>')
14
-
10
+ '<90><%=time%></90> <<%=color%>><%=s.user.screen_name%>: <%=text%></<%=color%>> ' +
11
+ '<90><%=reply_to ? reply_to + " " : ""%><%=s.id%> <%=source%></90>'
12
+ )
15
13
  config.plugins.stdout.set_default(:enable_pager, true)
16
14
  config.plugins.stdout.set_default(:pager, 'less -R -f +G')
17
15
  config.plugins.stdout.set_default(:window_height, 50)
@@ -43,15 +41,10 @@ module Termtter
43
41
 
44
42
  output_text = ''
45
43
  statuses.each do |s|
46
- text = s.text
47
- status_color = config.plugins.stdout.colors[s.user.id.hash % config.plugins.stdout.colors.size]
48
- status = "#{s.user.screen_name}: #{TermColor.escape(text)}"
49
- if s.in_reply_to_status_id
50
- status += " (reply to #{s.in_reply_to_status_id})"
51
- end
52
-
44
+ text = TermColor.escape(s.text)
45
+ color = config.plugins.stdout.colors[s.user.id.to_i % config.plugins.stdout.colors.size]
46
+ reply_to = s.in_reply_to_status_id ? "(reply to #{s.in_reply_to_status_id})" : nil
53
47
  time = "(#{Time.parse(s.created_at).strftime(time_format)})"
54
- id = s.id
55
48
  source =
56
49
  case s.source
57
50
  when />(.*?)</ then $1
@@ -0,0 +1,18 @@
1
+ # -*- coding: utf-8 -*-
2
+
3
+ config.user_name = '<%= user_name %>'
4
+ config.password = '<%= password %>'
5
+ #config.update_interval = 120
6
+ #config.proxy.host = 'proxy host'
7
+ #config.proxy.port = '8080'
8
+ #config.proxy.user_name = 'proxy user'
9
+ #config.proxy.password = 'proxy password'
10
+
11
+ Termtter::Client.init do |t|
12
+ <%- standard_plugins.each do |plugin| -%>
13
+ t.plug '<%= plugin %>'
14
+ <%- end -%>
15
+ <%- (plugins - standard_plugins).each do |plugin| -%>
16
+ # t.plug '<%= plugin %>'
17
+ <%- end -%>
18
+ end
@@ -1,4 +1,4 @@
1
1
  # -*- coding: utf-8 -*-
2
2
  module Termtter
3
- VERSION = '1.1.1'
3
+ VERSION = '1.1.3'
4
4
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: termtter
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.1
4
+ version: 1.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - jugyo
@@ -98,6 +98,7 @@ files:
98
98
  - lib/plugins/l2.rb
99
99
  - lib/plugins/list_with_opts.rb
100
100
  - lib/plugins/log.rb
101
+ - lib/plugins/mark.rb
101
102
  - lib/plugins/me.rb
102
103
  - lib/plugins/modify_arg_hook_sample.rb
103
104
  - lib/plugins/msagent.rb
@@ -160,6 +161,7 @@ files:
160
161
  - lib/termtter/task_manager.rb
161
162
  - lib/termtter/version.rb
162
163
  - lib/termtter.rb
164
+ - lib/termtter/config_template.erb
163
165
  - spec/plugins/cool_spec.rb
164
166
  - spec/plugins/english_spec.rb
165
167
  - spec/plugins/fib_spec.rb