Class: WeChat::Bot::Configuration

Inherits:
OpenStruct
  • Object
show all
Defined in:
lib/wechat/bot/configuration.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(defaults = nil) ⇒ Configuration

Returns a new instance of Configuration.



60
61
62
63
# File 'lib/wechat/bot/configuration.rb', line 60

def initialize(defaults = nil)
  defaults ||= self.class.default_config
  super(defaults)
end

Class Method Details

.default_configHash

默认配置

Returns:

  • (Hash)


8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# File 'lib/wechat/bot/configuration.rb', line 8

def self.default_config
  {
    # Bot Configurations
    verbose: false,
    fireman: 'filehelper',

    # WeChat Configurations
    app_id: 'wx782c26e4c19acffb',
    auth_url: 'https://login.weixin.qq.com',
    servers: [
      {
        index: 'wx.qq.com',
        file: 'file.wx.qq.com',
        push: 'webpush.wx.qq.com',
      },
      {
        index: 'wx2.qq.com',
        file: 'file.wx2.qq.com',
        push: 'webpush.wx2.qq.com',
      },
      {
        index: 'wx8.qq.com',
        file: 'file.wx8.qq.com',
        push: 'webpush.wx8.qq.com',
      },
      {
        index: 'wechat.com',
        file: 'file.web.wechat.com',
        push: 'webpush.web.wechat.com',
      },
      {
        index: 'web2.wechat.com',
        file: 'file.web2.wechat.com',
        push: 'webpush.web2.wechat.com',
      },
    ],
    cookies: 'wechat-bot-cookies.txt',
    special_users: [
      'newsapp', 'filehelper', 'weibo', 'qqmail',
      'fmessage', 'tmessage', 'qmessage', 'qqsync',
      'floatbottle', 'lbsapp', 'shakeapp', 'medianote',
      'qqfriend', 'readerapp', 'blogapp', 'facebookapp',
      'masssendapp', 'meishiapp', 'feedsapp', 'voip',
      'blogappweixin', 'brandsessionholder', 'weixin',
      'weixinreminder', 'officialaccounts', 'wxitil',
      'notification_messages', 'wxid_novlwrv3lqwv11',
      'gh_22b87fa7cb3c', 'userexperience_alarm',
    ],
    user_agent: 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/59.0.3071.86 Safari/537.36',
  }
end

Instance Method Details

#to_hHash

Returns:

  • (Hash)


66
67
68
# File 'lib/wechat/bot/configuration.rb', line 66

def to_h
  @table.clone
end