-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsettings.py
More file actions
23 lines (16 loc) · 740 Bytes
/
settings.py
File metadata and controls
23 lines (16 loc) · 740 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import os
from telegram.ext import Updater
import gspread
from google.oauth2.service_account import Credentials
import config
MYBOT = Updater(token=config.TOKEN, use_context=True)
def give_access_to_worksheet():
current_dir = os.path.dirname(__file__)
credentials_file_name = 'credentials.json'
path_to_credentials = os.path.join(current_dir, credentials_file_name)
scope = ['https://spreadsheets.google.com/feeds', 'https://www.googleapis.com/auth/drive']
credentials = Credentials.from_service_account_file(path_to_credentials, scopes=scope)
gs = gspread.authorize(credentials)
worksheet = gs.open_by_key(config.SPREAD_SHEET_ID).sheet1
return worksheet
GOOGLE_WORKSHEET = give_access_to_worksheet()