This repository has been archived by the owner on Jun 23, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
spread_sheet.py
executable file
·86 lines (60 loc) · 1.89 KB
/
spread_sheet.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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
#!/usr/bin/env python3
import gspread
from oauth2client.service_account import ServiceAccountCredentials
import secret
from setting import *
scope = ['https://spreadsheets.google.com/feeds']
json = ServiceAccountCredentials.from_json_keyfile_name(secret.JSON_FILE_NAME, scope)
gc = gspread.authorize(json)
sheet = gc.open_by_key(secret.SPREAD_SHEET_KEY).sheet1
def lock_sheet():
sheet.update_cell(BOT_STATUS_ROW, BOT_STATUS_COL, BOT_STATUS_LOCK)
def unlock_sheet():
sheet.update_cell(BOT_STATUS_ROW, BOT_STATUS_COL, BOT_STATUS_DEFAULT)
def init_status():
i=1
while get_timestamp(i) != "":
if(get_status(i) == ""):
set_status(i,STATUS_PREPARE)
i+=1
def init():
lock_sheet()
init_status()
def end():
unlock_sheet()
def get_val(num, col):
return sheet.cell(BASE_ROW+num, BASE_COL+col).value
def set_val(num, col, val):
sheet.update_cell(BASE_ROW+num, BASE_COL+col, val)
def get_status(num):
return get_val(num, STATUS_COL)
def set_status(num, val):
set_val(num, STATUS_COL, val)
def get_timestamp(num):
return get_val(num, TIMESTAMP_COL)
def set_timestamp(num, val):
set_val(num, TIMESTAMP_COL, val)
def get_mailaddr(num):
return get_val(num, MAILADDR_COL)
def set_mailaddr(num):
set_val(num, MAILADDR_COL, val)
def get_tweet_num_times(num):
return get_val(num, TWEET_NUM_TIMES_COL)
def set_tweet_num_times(num, val):
set_val(num, TWEET_NUM_TIMES_COL, val)
def get_tweet_day(num):
return get_val(num, TWEET_DAY_COL)
def set_tweet_day(num, val):
set_val(num, TWEET_DAY_COL, val)
def get_tweet_frequency(num):
return get_val(num, TWEET_FREQUENCY_COL)
def set_tweet_frequency(num, val):
set_val(num, TWEET_FREQUENCY_COL, val)
def get_tweet_time(num):
return get_val(num, TWEET_TIME_COL)
def set_tweet_time(num, val):
set_val(num, TWEET_TIME_COL, val)
def get_tweet_content(num):
return get_val(num, TWEET_CONTENT_COL)
def set_tweet_content(num, val):
set_val(num, TWEET_CONTENT_COL, val)