Skip to content

Commit

Permalink
G点
Browse files Browse the repository at this point in the history
  • Loading branch information
wong2 committed Jan 26, 2013
1 parent b49dda5 commit 2ce35a6
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions plugins/calc24.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ def __str__(self):

def test(data, bot):
message = data['message']
if not re.search('算[\d-]+点', message) \
if not re.search('算[G\d-]+点', message) \

This comment has been minimized.

Copy link
@Wizmann

Wizmann Jan 26, 2013

过于没节操。。。= =。。。

This comment has been minimized.

Copy link
@wong2

wong2 Jan 26, 2013

Author Owner

^_^

or not re.search('(?:.*\[)(.+)(?:\][.]*)', message):
return False
else:
Expand All @@ -86,13 +86,16 @@ def solve(ans, nums):
def handle(data, bot):
message = data['message']
query = re.findall('(?:.*\[)(.+)(?:\][.]*)', message)
ans = re.findall('算([\d-]+)点', message)
ans = re.findall('算([G\d-]+)点', message)
try:
if len(query) == 0 or len(ans) == 0:
raise Calc24Exception("表达式错误哦~")
else:
try:
ans = int(ans[0])
ans_str = ans[0]
if ans_str == 'G':
return '啊啊啊!不要碰那里!'
ans = int(ans_str)
except:
raise Calc24Exception("表达式错误哦~")
nums = map(lambda x: x.strip(), query[0].split(','))
Expand Down Expand Up @@ -161,5 +164,5 @@ def conv(ch):
'author_id': 'Wizmann'}, None)
print handle({'message': 'Hello World 算24点 [F,U,C,K]',
'author_id': 'Kuuy'}, None)

print handle({'message': 'Hello World 算24点 [1, 1, 12, 13]'}, None)
print handle({'message': '算G点 [1, 1, 12, 13]'}, None)

0 comments on commit 2ce35a6

Please sign in to comment.
-