-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpost.py
61 lines (49 loc) · 1.81 KB
/
post.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
import sys
import time
from daily import *
from showroom import *
from typing import Dict
from PTTLibrary import PTT
import datetime
from config import *
if __name__ == '__main__':
# 發送showroom文
st = datetime.datetime.fromtimestamp(time.time()).strftime('%y%m%d')
showroom_title = '[LIVE] ' + st + ' Showroom & 浪直播 實況閒聊文'
showroom_contents = Showroom.get_content()
print(showroom_contents)
### 發文相關資訊填寫
ID = PTT_ACCOUNT
Password = PTT_PASSWORD
board = 'AKB48'
KickOtherLogin = False
###
PTTBot = PTT.Library(kickOtherLogin=KickOtherLogin)
ErrCode = PTTBot.login(ID, Password)
if ErrCode != PTT.ErrorCode.Success:
PTTBot.Log('登入失敗')
sys.exit()
ErrorCode = PTTBot.post(board, showroom_title, showroom_contents, 0, 0)
if ErrorCode == PTT.ErrorCode.Success:
PTTBot.Log('在' + board + '板發SHOWROOM文成功')
elif ErrorCode == PTT.ErrorCode.NoPermission:
PTTBot.Log('發文權限不足')
else:
PTTBot.Log('在 Test 板發文失敗')
# 發送每日文
st = datetime.datetime.fromtimestamp(time.time()).strftime('%y%m%d')
daily_title = '[閒聊] 本日行程與閒聊 ' + st
daily_contents = Daily().get_content()
print(daily_contents)
for i in range(3):
ErrorCode = PTTBot.post(board, daily_title, daily_contents, 0, 0)
if ErrorCode == PTT.ErrorCode.Success:
PTTBot.Log('在' + board + '板今日閒聊文發文成功')
if board == 'AKB48':
PTTBot.throwWaterBall('emperor', '今日閒聊文已發文')
break
elif ErrorCode == PTT.ErrorCode.NoPermission:
PTTBot.Log('發文權限不足')
else:
PTTBot.Log('在 Test 板發文失敗')
PTTBot.logout()