forked from gwtak/TieBaSign
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmeow.py
More file actions
20 lines (18 loc) · 712 Bytes
/
meow.py
File metadata and controls
20 lines (18 loc) · 712 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
import os
from urllib.parse import urlencode, quote
from urllib.request import Request, urlopen
from urllib.error import URLError, HTTPError
meow_name = os.environ['MEOW_NAME']
API_BASE_URL = f'http://api.chuckfang.com/{meow_name}/'
def meow_send(title='', message=''):
encoded_title = quote(title)
encoded_message = quote(message)
url = f'{API_BASE_URL}{encoded_title}/{encoded_message}'
req = Request(url, method='GET')
try:
with urlopen(req) as response:
result = response.read().decode('utf-8')
except (URLError, HTTPError) as e:
result = f'Error occurred: {e}'
return result
meow_send(title='Github|TieBaSign', message='所有用户签到结束')