diff --git a/app/controllers/addresses_controller.rb b/app/controllers/addresses_controller.rb
index 8704eb015..e49d29a39 100644
--- a/app/controllers/addresses_controller.rb
+++ b/app/controllers/addresses_controller.rb
@@ -12,5 +12,6 @@ def index
def show
@address = Address.find_by_address_hash(params[:id])
@transactions = @address.ckb_transactions.order('id desc').page(params[:page]).per(10)
+ @qr = RQRCode::QRCode.new("https://t.me/ckb_watch_bot?start=#{@address&.id}", :size => 7, :level => :l )
end
end
diff --git a/app/views/addresses/show.html.erb b/app/views/addresses/show.html.erb
index a7260f220..5e5bc4354 100644
--- a/app/views/addresses/show.html.erb
+++ b/app/views/addresses/show.html.erb
@@ -10,7 +10,13 @@
<%= t 'address' %>:
<%= render partial: 'shared/copy_to_clipboard', locals: {content: @address.address_hash,tip: t('copy_address_to_clipboard')} %>
+
+
+
+
+
+
<%= @address.address_hash.to_s.gsub(/(.{16}).*(.{16})/, '\1...\2') %>
@@ -56,6 +62,7 @@
Tx:<%= link_to transaction.tx_hash, transaction_path(transaction.tx_hash), class: 'font-medium text-blue-600 dark:text-blue-500 hover:underline' %>
<%= t 'block' %>:<%= link_to transaction.block_number, block_path(transaction.block_number), class: 'font-medium text-blue-600 dark:text-blue-500 hover:underline' %>
+ <%= t('block_timestamp') %>: <%= Time.at((transaction.block_timestamp / 1000).to_i).strftime("%Y-%m-%d %H:%M:%S") %>
@@ -110,4 +117,82 @@
<%= render 'shared/disqus' %>
-
\ No newline at end of file
+
+
+
+
+
+
+
+
+
+
+
+ <%= t('watch_address') %>
+
+
+
+
+
+ Close modal
+
+
+
+
+ <%= raw @qr.as_html %>
+
+
+
+
+ <%= link_to t('click_here'), "https://t.me/ckb_watch_bot?start=#{@address.id}", target: '_blank', class: 'font-medium text-blue-600 dark:text-blue-500 hover:underline' %><%= t('tg_tip') %>
+
+
+ <%= t('tg_tip2') %>
+
+
+
+ <%= t('tg_tip3') %>
+
+
+
+ <%#= t('tg_tip2') %>
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/views/shared/_copy_to_clipboard.html.erb b/app/views/shared/_copy_to_clipboard.html.erb
index 11241aedd..577ff94d5 100644
--- a/app/views/shared/_copy_to_clipboard.html.erb
+++ b/app/views/shared/_copy_to_clipboard.html.erb
@@ -3,7 +3,7 @@
-
+
diff --git a/app/workers/telegram_bot.rb b/app/workers/telegram_bot.rb
index c431918d4..09217524a 100644
--- a/app/workers/telegram_bot.rb
+++ b/app/workers/telegram_bot.rb
@@ -7,7 +7,7 @@ def perform(address_id, change_balance)
bot = Telegram::Bot::Client.new(Settings.tg_bot_token)
address.tg_bots.active.each do |tg_bot|
bot.api.send_message(chat_id: tg_bot.chat_id, text: "Address: #{tg_bot.address_hash}
-Change Amount: #{change_balance.to_f/10**8}", parse_mode: 'HTML')
+Change Amount: #{change_balance.to_f/10**8}CKB", parse_mode: 'HTML')
end
end
diff --git a/config/locales/en.yml b/config/locales/en.yml
index a14e4280e..e65614451 100644
--- a/config/locales/en.yml
+++ b/config/locales/en.yml
@@ -62,7 +62,7 @@ en:
input: "Input"
output: "Output"
transaction_overview: "Transaction Overview"
- block_timestamp: 'DateTime'
+ block_timestamp: 'Timestamp'
transaction_fee: 'Transaction Fee'
transaction_cycles: 'Transaction Cycles'
transaction_detail: 'Transaction Detail'
@@ -79,6 +79,11 @@ en:
copy_address_to_clipboard: 'Copied Address to clipboard!'
copy_tx_to_clipboard: 'Copied Tx to clipboard!'
support_us: 'Support Us'
+ watch_address: 'Watch This Address'
+ click_here: 'Click here'
+ tg_tip: ',if you have Telegram installed on this device'
+ tg_tip2: 'If Telegram is not installed, please install it yourself first and then click to jump.'
+ tg_tip3: 'Or use mobile scan the QR code.'
views:
pagination:
diff --git a/config/locales/zh.yml b/config/locales/zh.yml
index 2aa2b36bf..421415be9 100644
--- a/config/locales/zh.yml
+++ b/config/locales/zh.yml
@@ -48,6 +48,11 @@ zh:
copy_address_to_clipboard: '复制地址到粘贴板'
copy_tx_to_clipboard: '复制Tx到粘贴板'
support_us: '支持我们'
+ watch_address: '监控地址'
+ click_here: '点击此处'
+ tg_tip: ',如果当前设备你已经安装了Telegram.'
+ tg_tip2: '如果没有安装Telegram,请先自行安装,然后点击跳转。'
+ tg_tip3: '或者使用手机扫描二维码。'
views:
pagination:
diff --git a/lib/telegram_bot.rb b/lib/telegram_bot.rb
index c581ac68a..d0f953f75 100644
--- a/lib/telegram_bot.rb
+++ b/lib/telegram_bot.rb
@@ -24,8 +24,8 @@
bot.api.send_message(chat_id: message.chat.id, text: "You have not watching any addresses.
To start any watch, reply: /start address",parse_mode: 'HTML')
end
-
else
+ bot.api.send_message(chat_id: message.chat.id, text: "#{message.text}")
if message.text.start_with?('/start ')
hash = message.text.gsub('/start ', '').strip
if QueryKeyUtils.valid_address?(hash)
@@ -33,6 +33,11 @@
tg_bot = TgBot.find_or_initialize_by(chat_id: message.chat.id, address_hash: hash)
tg_bot.is_use = true
tg_bot.save if tg_bot.changed?
+ elsif (hash.match?(/\A\d+\z/)) && address = Address.find_by(id: hash)
+ bot.api.send_message(chat_id: message.chat.id, text: "You've started watching address #{address.address_hash}")
+ tg_bot = TgBot.find_or_initialize_by(chat_id: message.chat.id, address_hash: address.address_hash)
+ tg_bot.is_use = true
+ tg_bot.save if tg_bot.changed?
else
bot.api.send_message(chat_id: message.chat.id, text: "Sorry. Address format is incorrect. Please try again.")
end