SHARE
TWEET

Untitled

a guest Jul 18th, 2019 61 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import pygsheets
  2. import pandas as pd
  3. import gspread
  4. from oauth2client.service_account import ServiceAccountCredentials
  5. import time
  6.  
  7. scope = ['https://spreadsheets.google.com/feeds', 'https://www.googleapis.com/auth/drive']
  8. credentials = ServiceAccountCredentials.from_json_keyfile_name('here goes the path to the json', scope)
  9.  
  10. inputfile = open("here goes the path to the log")
  11. lines = []
  12. gc = gspread.authorize(credentials)
  13. wks = gc.open("Lies").sheet1
  14. i = 0
  15.  
  16.  
  17. def parseline(line):
  18.     time.sleep(1)
  19.     lines.append(line)
  20.     line = line.split(" ")
  21.  
  22.     if(line[3] == 'lies_bot'):
  23.         command = lines[len(lines)-2]
  24.         command = command.split(" ")
  25.         try:
  26.             if(command[3] == '!input'):
  27.                 global i
  28.                 i+=1
  29.                 wks.update_cell(sys.argv[1],1,command[4])
  30.         except Exception as e:
  31.             print(i)
  32.     if(len(lines)>1000):
  33.         reset_lines()
  34.  
  35.  
  36.  
  37. def reset_lines():
  38.     temp1 = lines[len(lines)-1]
  39.     temp2 = lines[len(lines)-2]
  40.     lines.clear()
  41.     lines.append(temp2)
  42.     lines.append(temp1)
  43.  
  44. while 1:
  45.     l = ''
  46.     while (l == ''):
  47.         time.sleep(.5)
  48.         l = inputfile.readline()
  49.     try:
  50.         parseline(l)
  51.     except Exception as e:
  52.         l = l.split(" ")
  53.         print(l)
  54.         print(e)
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top