Skip to content

Commit 40604f6

Browse files
committed
增加长时间离线消息忽略处理
1 parent ddf0dec commit 40604f6

File tree

4 files changed

+17
-7
lines changed

4 files changed

+17
-7
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
> 2014.05
2+
3+
* 升级群列表加密验证
4+
* 防掉线处理ing
5+
* 忽略长时间离线消息
6+
17
> 2014.03.21
28
39
* 增加讨论组支持

README.md

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,13 +61,11 @@ https://github.com/xhan/qqbot/blob/master/CHANGELOG.md
6161
资料
6262
----
6363
* WebQQ协议 https://github.com/xhan/qqbot/blob/master/protocol.md
64-
* WebQQ协议专题 http://www.10qf.com/forum-51-1.html
65-
* 开源的webqq协议的win客户端 https://code.google.com/p/mingqq/
66-
* http://webqq-core.googlecode.com/
67-
* https://github.com/im-qq/webqq-core
64+
* Java版的另一个 http://webqq-core.googlecode.com/
6865

6966
TODO
7067
---
68+
* 自动重新登录
7169
* 机器人响应前缀
7270
* 图片发送支持
7371
* 更多的插件

config.demo.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ port: 3100
88
host: localhost
99

1010

11+
# 消息处理,忽略20分钟外的离线消息
12+
# offline_msg_keeptime: 1200
13+
1114
# 插件列表
1215
plugins:
1316
- help

src/qqbot.coffee

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ class QQBot
212212
log.error "poll with error #{e}" if e
213213
code = if resp then resp.retcode else -1
214214
switch code
215-
when -1 then log.error "resp is null, error on parse ret"
215+
when -1 then log.error "resp is null, error on parse ret",resp
216216
when 0 then @_handle_poll_event(event) for event in resp.result
217217
when 102 then 'nothing happened, waiting for next loop'
218218
when 103
@@ -303,9 +303,12 @@ class QQBot
303303
# 更新
304304
@update_buddy_list unless msg.from_user
305305
try log.debug "[好友消息]","#{msg.from_user.nick}:#{msg.content} #{msg.time}"
306-
307306

308-
# 消息处理
307+
308+
# 消息和插件处理
309+
if @config.offline_msg_keeptime and new Date().getTime() - msg.time.getTime() > @config.offline_msg_keeptime * 1000
310+
return
311+
309312
replied = false
310313
reply = (content)=>
311314
@reply_message(msg,content) unless replied

0 commit comments

Comments
 (0)