-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 4fd12e3
Showing
39 changed files
with
3,598 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
application: justin-wong | ||
version: 1 | ||
runtime: python | ||
api_version: 1 | ||
|
||
# default_expiration: "3650d" | ||
|
||
handlers: | ||
- url: /favicon.ico | ||
static_files: static/images/favicon.ico | ||
upload: static/images/favicon.ico | ||
mime_type: image/x-icon | ||
|
||
- url: /robots.txt | ||
static_files: static/robots.txt | ||
upload: static/robots.txt | ||
|
||
|
||
- url: /cat | ||
static_files: static/files/cat_s_daily.html | ||
upload: static/files/cat_s_daily.html | ||
|
||
# All URLs beginning with /stylesheets are treated as paths to static files in | ||
# the stylesheets/ directory. Note that static_dir handlers do not use a | ||
# regular expression for the URL pattern, only a prefix. | ||
#- url: /stylesheets | ||
# static_dir: stylesheets | ||
|
||
# All URLs ending in .gif .png or .jpg are treated as paths to static files in | ||
# the static/ directory. The URL pattern is a regexp, with a grouping that is | ||
# inserted into the path to the file. | ||
- url: /(.*\.(gif|png|jpg)) | ||
static_files: static/images/\1 | ||
upload: static/images/(.*\.(gif|png|jpg)) | ||
secure: optional | ||
|
||
# Handle request | ||
- url: /.* | ||
script: index.py |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
# zwbot configure | ||
# -*- coding: utf-8 -*- | ||
|
||
## | ||
## 部署到GAE前,请参照 DeploymentGuide 修改下列配置,并且自定义你的bot | ||
## http://code.google.com/p/zwbot/wiki/DeploymentGuide | ||
## | ||
|
||
## OAuth认证需要的 Consumer Key 和 Access Token | ||
## August 31, 2010, Basic Auth has been deprecated. All applications must now use OAuth | ||
CONSUMER_KEY = 'NxRNiatciHHyyIjOajlo6g' | ||
CONSUMER_SECRET = 'U9mQR5s1TixeWkjQxNunGIK72ynLb0bllKjWVFQXU2w' | ||
ACCESS_TOKEN = '246485694-XHWHlIAWSpIJWSm1y1HVfU5EeKnQA4Xn9Jcrm39S' | ||
ACCESS_SECRET = 'hJ0aGfaZAlolBOYbjh9j5DcjaMOZsFOrPnsYDg32t4' | ||
|
||
|
||
## 词库配置 | ||
DICT_NAME = 'static/sample_dict.xls' # 词库名,注意是绝对路径 | ||
DICT_LINES = 24 # 词库中记录条数 (达到此条数会自动从头开始播放) | ||
|
||
|
||
## 访问路径 | ||
URL_CURWORD = '/t' # 当前单词页面 | ||
URL_MENTIONS = '/backdoor2checkmentions' # 提及页面 | ||
KEY_FOBACK_ALL = '/AutoFollowBack' # 回Fo动作的触发名 (注意要和Cron.yaml中的保持同步) | ||
# 请修改此 CronJob Key 为其他人无法猜到的字符串,以防被人利用 (注意要和Cron.yaml中的保持同步) | ||
KEY_CRONJOB = '/InputYourCronJobKeyHere' | ||
URL_SENDTWEET = '/backdoor2tweet' # 手动发Tweet到Twitter (例如请求: /tweet2bot?msg='Hello World!') | ||
|
||
|
||
## 个性化提示语设置 | ||
BOT_HASHTAG = ' #zwbot' # 特殊推中的HashTag,用于复习索引 (不需要请留空) | ||
MSG_GET_UP = '现在是bot的起床时间' # 早上 07:00 的起床提醒 (例如:主人,该起床背单词了哦) | ||
MSG_SLEEP = '现在是bot的休息时间' # 晚上 23:55 的睡觉提醒 (例如:主人,该上床睡觉啦) | ||
|
||
# 复习推前后的提示语,构成 {MSG_REVIEW_1 + 三个单词 + MSG_REVIEW_2} 的格式 | ||
MSG_REVIEW_1 = '复习时间 ' | ||
MSG_REVIEW_2 = ' 还记得这三个单词的意思吗?' | ||
# 深夜访问GAE的 /t 页面显示的提示 | ||
GAE_PAGE_TIPS = '现在是bot的休息时间' | ||
|
||
## 其他参数设置 | ||
MENTIONS_COUNT = 15 # 提及页面的显示条数 | ||
|
||
# 单词的连接符和分隔符 | ||
TW_WORD_LINK = ' - ' # 单元格A和单元格B之间的连接符 | ||
TW_WORD_SP = '; ' # 单元格B和单元格C之间的分隔符 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
cron: | ||
|
||
- description: (Cron Job) to execute program | ||
url: /InputYourCronJobKeyHere | ||
schedule: every 5 mins | ||
timezone: Asia/Shanghai | ||
|
||
- description: Auto follow back | ||
url: /AutoFollowBack | ||
schedule: every 23 hours | ||
timezone: Asia/Shanghai |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,115 @@ | ||
# DB function for zwbot | ||
# -*- coding: utf-8 -*- | ||
|
||
from google.appengine.ext import db | ||
|
||
# DB计数器操作 | ||
class Counter(db.Model): | ||
count = db.IntegerProperty() | ||
is_title = db.IntegerProperty() | ||
current_title = db.StringProperty(multiline=False) | ||
current_word = db.StringProperty(multiline=False) | ||
rol_word1 = db.StringProperty(multiline=False) | ||
rol_word2 = db.StringProperty(multiline=False) | ||
rol_word3 = db.StringProperty(multiline=False) | ||
fatal_min = db.IntegerProperty() | ||
|
||
class DB_Utility(): | ||
def __init__(self): | ||
query = db.GqlQuery("select * from Counter") | ||
counter = query.get() | ||
|
||
if (not counter): | ||
counter = Counter() | ||
counter.count = 0 | ||
counter.is_title = 0 | ||
counter.current_title = '' | ||
counter.current_word = '' | ||
counter.rol_word1 = '' | ||
counter.rol_word2 = '' | ||
counter.rol_word3 = '' | ||
counter.fatal_min = -1 | ||
counter.put() | ||
|
||
# max 是xls文件的最大行数,达到后从头开始 | ||
def GetIncCounter(self, max): | ||
query = db.GqlQuery("select * from Counter") | ||
counter = query.get() | ||
|
||
result = counter.count # 取得当前的计数(从0开始) | ||
counter.count += 1 | ||
counter.count = counter.count % max; # 从 (0) - (max-1) | ||
|
||
counter.put() | ||
return(result) | ||
|
||
def GetCounter(self): | ||
q = db.GqlQuery("select * from Counter") | ||
counter = q.get() | ||
return(counter.count) | ||
|
||
def DecCounter(self): | ||
q = db.GqlQuery("select * from Counter") | ||
counter = q.get() | ||
if (counter.count > 0): | ||
counter.count -= 1 | ||
counter.put() | ||
|
||
|
||
def GetTitleFlag(self): | ||
q = db.GqlQuery("select * from Counter") | ||
counter = q.get() | ||
return(counter.is_title) | ||
|
||
def SetTitleFlag(self, title, title_str): | ||
q = db.GqlQuery("select * from Counter") | ||
counter = q.get() | ||
counter.is_title = title | ||
if (title == 1): | ||
counter.current_title = title_str | ||
counter.put() | ||
|
||
def GetTitleString(self): | ||
q = db.GqlQuery("select * from Counter") | ||
counter = q.get() | ||
return(counter.current_title.encode('utf-8')) | ||
|
||
|
||
def GetCurrentWord(self): | ||
q = db.GqlQuery("select * from Counter") | ||
counter = q.get() | ||
return(counter.current_word.encode('utf-8')) | ||
|
||
def SetCurrentWord(self, str_word): | ||
q = db.GqlQuery("select * from Counter") | ||
counter = q.get() | ||
counter.current_word = str_word | ||
counter.put() | ||
|
||
def GetRollingWords(self): | ||
q = db.GqlQuery("select * from Counter") | ||
counter = q.get() | ||
str_word = '%s %s %s' % (counter.rol_word3, counter.rol_word2, counter.rol_word1) | ||
return(str_word.encode('utf-8')) | ||
|
||
def SetRollingWords(self, str_word): | ||
q = db.GqlQuery("select * from Counter") | ||
counter = q.get() | ||
counter.rol_word3 = counter.rol_word2 | ||
counter.rol_word2 = counter.rol_word1 | ||
counter.rol_word1 = str_word | ||
counter.put() | ||
|
||
|
||
# 读写推送失败的周期数 | ||
def GetFatalMin(self): | ||
q = db.GqlQuery("select * from Counter") | ||
counter = q.get() | ||
return(counter.fatal_min) | ||
|
||
def SetFatalMin(self, iMin): | ||
q = db.GqlQuery("select * from Counter") | ||
counter = q.get() | ||
if (counter.fatal_min != iMin): | ||
counter.fatal_min = iMin | ||
counter.put() |
Oops, something went wrong.