jugyo / earthquake

Twitter terminal client with streaming API support.
MIT License
661 stars 94 forks source link

suppress $id expansion #113

Open no6v opened 12 years ago

no6v commented 12 years ago

How can I tweet $id, instead of for instance 187363363188248580?

⚡ :update $id
update '187363363188248580' [Yn] n
⚡ :update \$id
update '\187363363188248580' [Yn] n

I investigated it and got the idea to suppress this. Currently, below sequence is resulted to "Command not found".

⚡ : :update $id
Command not found

The patch below makes ⚡ : (start with colon + space) as a signal not to expand the typable id.

⚡ : :update $id
update '$id' [Yn] n

However, with this patch, we cannot use :reply, (quoted) :retweet, and more perhaps. Those require the $id to determine the target tweet. One more thing, some commands are using input() internally, then the input_filter will be applied twice. Any idea?

Also available: https://gist.github.com/2237938

diff --git a/lib/earthquake/input.rb b/lib/earthquake/input.rb
index 870cefc..9469c25 100644
--- a/lib/earthquake/input.rb
+++ b/lib/earthquake/input.rb
@@ -141,6 +141,7 @@ module Earthquake
     end

     input_filter do |text|
+      next text if text.sub!(/\A: /, "")
       if text =~ %r|^(:\w+)|
         if target = command_aliases[$1]
           text = text.sub(%r|^:\w+|, target)

I don't want to introduce any escape sequences, though ;-).

ohac commented 12 years ago

How about this patch?

https://gist.github.com/2310338

⚡ test $ab $$ab $ab $$ab
update 'test 187870166942613506 $ab 187870166942613506 $ab' [Yn] n
no6v commented 12 years ago

Can you tweet '$$ab' with this patch? This is exactly escape sequance, I guess. But this may be enough solution as usual tweet life :).