Esempio n. 1
0
 def __init__(self, output_filename, *args, **kwargs):
     super().__init__(*args, **kwargs)
     self.output_filename = output_filename
     self.result = []
     self.chat = rocketchat.RocketChat(os.environ["ROCKETCHAT_BASE_URL"])
     self.chat.user_id = os.environ["ROCKETCHAT_USER_ID"]
     self.chat.auth_token = os.environ["ROCKETCHAT_AUTH_TOKEN"]
Esempio n. 2
0
 def __init__(self, output_filename, *args, **kwargs):
     super().__init__(*args, **kwargs)
     self.output_filename = output_filename
     self.result = []
     self.chat = rocketchat.RocketChat(os.environ["ROCKETCHAT_BASE_URL"])
     self.chat.login(os.environ["ROCKETCHAT_USERNAME"],
                     os.environ["ROCKETCHAT_PASSWORD"])
Esempio n. 3
0
import getpass
import io
from collections import defaultdict
from urllib.request import urlopen

import rows
from tqdm import tqdm

import rocketchat

your_username = "******"
your_password = getpass.getpass()
spreadsheet_id = "1S77CvorwQripFZjlWTOZeBhK42rh3u57aRL1XZGhSdI"

chat = rocketchat.RocketChat("https://chat.brasil.io/")
chat.login(your_username, your_password)

url = f"https://docs.google.com/spreadsheets/d/{spreadsheet_id}/export?format=csv#gid=0"
csv_data = urlopen(url).read()
table = rows.import_from_csv(io.BytesIO(csv_data), encoding="utf-8")
username_correto = {}
voluntarios = defaultdict(list)
voluntarios_uf = defaultdict(list)
for row in table:
    uf = row.uf.upper().strip()
    for voluntario in row.voluntarios.split(","):
        voluntario = voluntario.strip()
        username_correto[voluntario.lower()] = voluntario
        voluntarios_uf[uf].append(voluntario.lower())
    for voluntario in voluntarios_uf[uf]:
        voluntarios[voluntario].append(uf)