Skip to content

Commit 20e3d72

Browse files
committed
use smallseg and ignore tweets replied to others
1 parent 8d6f65c commit 20e3d72

File tree

6 files changed

+276195
-4
lines changed

6 files changed

+276195
-4
lines changed

config.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,10 @@
1010
#手动发Tweet的KEY
1111
TWEET_KEY = 'V8Q6DvexTyCE3se47rtBX8em'
1212
## 关键词
13-
RT_REGEX="""diumoo|xdtuxbot|linux|unix|android|meego|ubuntu|arch|gentoo|debian|firefox|chrome|chromium|python| geek |apache|nginx|sql|php|django|rails|ruby|GPL|vim|emacs|gnome|gnu |perl|freebsd|netbsd|openbsd|hack|html5| kde """
13+
RT_REGEX="""diumooxdtuxbot|linux|unix|android|meego|ubuntu|arch|gentoo|debian|firefox|chrome|chromium|python| geek |apache|nginx|sql|php|django|rails|ruby|GPL|vim|emacs|gnome|gnu |perl|freebsd|netbsd|openbsd|hack|html5| kde |fcitx"""
14+
15+
RT_LIST=['diumoo', '@xdtuxbot', 'linux', 'unix', 'android', 'meego', 'ubuntu', 'arch', 'gentoo', 'debian', 'firefox', 'chrome', 'chromium', 'python', 'geek', 'apache', 'nginx', 'sql', 'php', 'django', 'rails', 'ruby', 'GPL', 'vim', 'emacs', 'gnome', 'gnu ', 'perl', 'freebsd', 'netbsd', 'openbsd', 'hack', 'html5', 'kde', 'fcitx']
16+
1417

1518
MGC="gfw|翻墙|中共|土共|共产党|当局|政府|#notrt|#nort"
1619

index.py

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
from google.appengine.ext.webapp import template
1010

1111
from google.appengine.ext import db
12+
from smallseg import SEG
1213
import random
1314
import weather
1415
import config
@@ -258,18 +259,28 @@ def get(self):
258259
return
259260

260261
msg=None
262+
seg = SEG()
261263
for tweet in tweets:
262264
user = tweet.user.screen_name
263265
if user == 'xdtuxbot':
264266
continue
265267
text = tweet.text
266-
m = regx.search(text)
267-
if m == None:
268-
continue
269268
n = mgc.search(text)
270269
if n != None:
271270
continue
271+
272272
t = talk_to_me.search(text)
273+
if (not t) and text[0]=='@':
274+
continue
275+
276+
wlist = seg.cut(text.encode('utf-8'))
277+
logging.info( ' '.join(wlist) )
278+
for w in wlist:
279+
if w in config.RT_LIST:
280+
break
281+
else:
282+
continue
283+
273284
if t:
274285
bot = TalkBot()
275286
reply = bot.respond( talk_to_me.sub("",text) ).decode('UTF-8')

smallseg/__init__.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/usr/bin/env python2
2+
# -*- coding:utf8 -*-
3+
from smallseg import SEG
4+
# vim: ts=4 sw=4 sts=4 expandtab

0 commit comments

Comments
 (0)