wechat 0.17.4 → 0.17.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c7d465a4950bcf9d672e465f6df611380a6ea2f8a7a97609a198db0fc6780078
4
- data.tar.gz: 168f9ac6817424838d68f9fceb240e3509da81bad2927c603ebfb840541a6d3c
3
+ metadata.gz: 2abb37f01abc3bcc8f7c9f0500f5a4f73c6877c36152b0e74ddb92fa630227e7
4
+ data.tar.gz: d08f8b4c5ddc18d3733ad331268733a5dc55ee41b684cdc810905583f32923fe
5
5
  SHA512:
6
- metadata.gz: 17dbc1a4799625793717db99df15e1572342a73cc30d189436c1ab146b632ae86a356a4d943b67811844e6969abd55af2b14562915cf18998d23a2ed0e5c767a
7
- data.tar.gz: bb86b6f6871166000718d217bd4e134072e6c4933dc76e579ffde8004f2f17d9661438b4a50bda76a21e432285329446d4b43705c7c97b9419d9a060da482e6c
6
+ metadata.gz: 8ee8b7886ef537b146b3f4a5fbcf035a67effd8876f85ca167c10c6528102c653a076dc2b32a28897db378e0ea0422cbb37d988d520a321e62109e6306297d88
7
+ data.tar.gz: 77d3c1abb49ec7c7e4fa3597a676c02618db0aa2f6ed35f954de10dea11549802e5085fbb175b2861972db341fc657d1884048c6b5c1034c9c5ab781baacf7cf
checksums.yaml.gz.sig CHANGED
Binary file
data/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # Changelog
2
2
 
3
+ ## v0.17.5 (released at 2024-10-25)
4
+
5
+ * Remove `serialize :hash_store` in template as it's cause too many issue in different rails version.
6
+
3
7
  ## v0.17.4 (released at 2024-08-13)
4
8
 
5
9
  * Fix private API ActiveSupport::Deprecation.warn called in Rails 7.2
data/README-CN.md CHANGED
@@ -859,6 +859,27 @@ end
859
859
 
860
860
  注意设置了[多客服消息转发](http://dkf.qq.com/)后,不能再添加默认文字信息 `responder`,否则文字消息将得不到转发。
861
861
 
862
+
863
+ ### 无法处理给一个默认回答,一周内不要重复
864
+
865
+ ```ruby
866
+ class WechatsController < ActionController::Base
867
+ on :fallback do |message|
868
+ Rails.logger.debug "YouApp_ToUserName: #{message.message_hash["FromUserName"]}"
869
+ session = WechatSession.find_by openid: message.message_hash["FromUserName"]
870
+ return message.reply.success if session.present? && session.greating_time.present? && session.greating_time >= 1.week.ago
871
+
872
+ images_path = Rails.root.join("public", "images", "default_help.jpg")
873
+ media_id = Wechat.api.media_create("image", images_path)["media_id"]
874
+ if session.present? && session.reload
875
+ # generate migration: add_column :wechat_sessions, :greating_time, :datetime
876
+ session.update(greating_time: Time.current)
877
+ end
878
+ message.reply.image(media_id)
879
+ end
880
+ end
881
+ ```
882
+
862
883
  ### 通知
863
884
 
864
885
  现支持以下通知:
data/README.md CHANGED
@@ -894,6 +894,26 @@ end
894
894
 
895
895
  Caution: do not set default text responder if you want to use [multiply human customer service](http://dkf.qq.com/), other will lead text message can not transfer.
896
896
 
897
+ ### Give a default answer, do not repeat within a week
898
+
899
+ ```ruby
900
+ class WechatsController < ActionController::Base
901
+ on :fallback do |message|
902
+ Rails.logger.debug "YouApp_ToUserName: #{message.message_hash["FromUserName"]}"
903
+ session = WechatSession.find_by openid: message.message_hash["FromUserName"]
904
+ return message.reply.success if session.present? && session.greating_time.present? && session.greating_time >= 1.week.ago
905
+
906
+ images_path = Rails.root.join("public", "images", "default_help.jpg")
907
+ media_id = Wechat.api.media_create("image", images_path)["media_id"]
908
+ if session.present? && session.reload
909
+ # generate migration: add_column :wechat_sessions, :greating_time, :datetime
910
+ session.update(greating_time: Time.current)
911
+ end
912
+ message.reply.image(media_id)
913
+ end
914
+ end
915
+ ```
916
+
897
917
  ### Notifications
898
918
 
899
919
  * `wechat.responder.after_create` data includes request <Wechat::Message> and response <Wechat::Message>.
@@ -4,7 +4,8 @@
4
4
  # Feel free to inherit from other class like ActiveModel::Model
5
5
  class WechatSession < ActiveRecord::Base
6
6
  validates :openid, presence: true, uniqueness: true
7
- serialize :hash_store, type: Hash
7
+ # don't using serialize if possible, see README `on :fallback`
8
+ serialize :hash_store, type: Hash, coder: YAML, yaml: { permitted_classes: [String] }
8
9
 
9
10
  # called by wechat gems when user request session
10
11
  def self.find_or_initialize_session(request_message)
data.tar.gz.sig CHANGED
Binary file
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: wechat
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.17.4
4
+ version: 0.17.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Skinnyworm
@@ -36,7 +36,7 @@ cert_chain:
36
36
  uxhUIIN2A+qeUxOIoO9VfGAX5Q+cQ4J+EpKkDovIHaG0tJdNoA9EABD8yMMHgWgw
37
37
  q9fk/nu08SjME28EsSxW0oLUQq1vHNKWUyZuHtihd0yBYGRJH7xdZivkUOs=
38
38
  -----END CERTIFICATE-----
39
- date: 2024-08-13 00:00:00.000000000 Z
39
+ date: 2024-10-25 00:00:00.000000000 Z
40
40
  dependencies:
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: activesupport
@@ -140,14 +140,14 @@ dependencies:
140
140
  requirements:
141
141
  - - "~>"
142
142
  - !ruby/object:Gem::Version
143
- version: 1.64.1
143
+ version: 1.66.1
144
144
  type: :development
145
145
  prerelease: false
146
146
  version_requirements: !ruby/object:Gem::Requirement
147
147
  requirements:
148
148
  - - "~>"
149
149
  - !ruby/object:Gem::Version
150
- version: 1.64.1
150
+ version: 1.66.1
151
151
  - !ruby/object:Gem::Dependency
152
152
  name: rails
153
153
  requirement: !ruby/object:Gem::Requirement
@@ -263,8 +263,8 @@ licenses:
263
263
  metadata:
264
264
  bug_tracker_uri: https://github.com/Eric-Guo/wechat/issues
265
265
  changelog_uri: https://github.com/Eric-Guo/wechat/releases
266
- documentation_uri: https://github.com/Eric-Guo/wechat/tree/v0.17.4#readme
267
- source_code_uri: https://github.com/Eric-Guo/wechat/tree/v0.17.4
266
+ documentation_uri: https://github.com/Eric-Guo/wechat/tree/v0.17.5#readme
267
+ source_code_uri: https://github.com/Eric-Guo/wechat/tree/v0.17.5
268
268
  rubygems_mfa_required: 'true'
269
269
  post_install_message:
270
270
  rdoc_options: []
@@ -281,7 +281,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
281
281
  - !ruby/object:Gem::Version
282
282
  version: 3.1.6
283
283
  requirements: []
284
- rubygems_version: 3.5.17
284
+ rubygems_version: 3.5.22
285
285
  signing_key:
286
286
  specification_version: 4
287
287
  summary: DSL for wechat message handling and API
metadata.gz.sig CHANGED
Binary file