-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathregistro.py
30 lines (22 loc) · 910 Bytes
/
registro.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
import os
import gspread
import requests
from flask import Flask, request
from oauth2client.service_account import ServiceAccountCredentials
from tchan import ChannelScraper
from datetime import datetime
GOOGLE_SHEETS_CREDENTIALS = os.environ["GOOGLE_SHEETS_CREDENTIALS"]
TELEGRAM_API_KEY = os.environ["TELEGRAM_API_KEY"]
TELEGRAM_ADMIN_ID = os.environ["TELEGRAM_ADMIN_ID"]
def registronaplanilha():
with open("credenciais.json", mode="w") as arquivo:
arquivo.write(GOOGLE_SHEETS_CREDENTIALS)
conta = ServiceAccountCredentials.from_json_keyfile_name("credenciais.json")
api = gspread.authorize(conta)
planilha = api.open_by_key("1NuMnkxDYzf4CtKPzV1jbKDmwWbM5W7Bld3EqgM9IoHs")
sheet = planilha.worksheet("Página1")
# Atualiza planilha do sheets com último update processado
sheet.append_rows(mensagens)
#sheet.update("A1", username)
sheet.update("A1", update_id)
return "Ok"