|
|
|
@ -101,7 +101,7 @@ class BotInstance:
|
|
|
|
|
rows = None
|
|
|
|
|
try:
|
|
|
|
|
|
|
|
|
|
print("Get DBconnection and cursor...")
|
|
|
|
|
# Get DBconnection and cursor...
|
|
|
|
|
conn, cursor = self.get_db_cursor()
|
|
|
|
|
|
|
|
|
|
sql = "select concat(that.username,'@',that.host ) as blocker, " \
|
|
|
|
@ -113,16 +113,16 @@ class BotInstance:
|
|
|
|
|
"where this.\"username\" like \'{0}\' " \
|
|
|
|
|
"and this.host is null;".format(self.mk_user)
|
|
|
|
|
|
|
|
|
|
print("Execute SQL statement...")
|
|
|
|
|
# Execute SQL statement...
|
|
|
|
|
cursor.execute(sql)
|
|
|
|
|
|
|
|
|
|
print("Fetch all!")
|
|
|
|
|
# Fetch all!
|
|
|
|
|
rows = cursor.fetchall()
|
|
|
|
|
|
|
|
|
|
print("Closing cursor...")
|
|
|
|
|
# Closing cursor...
|
|
|
|
|
cursor.close()
|
|
|
|
|
|
|
|
|
|
print("Closing DB connection...")
|
|
|
|
|
# Closing DB connection...
|
|
|
|
|
conn.close()
|
|
|
|
|
except Exception as e:
|
|
|
|
|
print("Error: ", e)
|
|
|
|
@ -133,7 +133,7 @@ class BotInstance:
|
|
|
|
|
rows = None
|
|
|
|
|
try:
|
|
|
|
|
|
|
|
|
|
print("Get DBconnection and cursor...")
|
|
|
|
|
# Get DBconnection and cursor...
|
|
|
|
|
conn, cursor = self.get_db_cursor()
|
|
|
|
|
|
|
|
|
|
sql = "select concat(that.username,'@',that.host ) as blocker, " \
|
|
|
|
@ -146,16 +146,16 @@ class BotInstance:
|
|
|
|
|
"and b.\"createdAt\" between current_date - interval '1 day' and current_date " \
|
|
|
|
|
"and this.host is null;".format(self.mk_user)
|
|
|
|
|
|
|
|
|
|
print("Execute SQL statement...")
|
|
|
|
|
# Execute SQL statement...
|
|
|
|
|
cursor.execute(sql)
|
|
|
|
|
|
|
|
|
|
print("Fetch all!")
|
|
|
|
|
# Fetch all!
|
|
|
|
|
rows = cursor.fetchall()
|
|
|
|
|
|
|
|
|
|
print("Closing cursor...")
|
|
|
|
|
# Closing cursor...
|
|
|
|
|
cursor.close()
|
|
|
|
|
|
|
|
|
|
print("Closing DB connection...")
|
|
|
|
|
# Closing DB connection...
|
|
|
|
|
conn.close()
|
|
|
|
|
except Exception as e:
|
|
|
|
|
print("Error: ", e)
|
|
|
|
@ -166,7 +166,7 @@ class BotInstance:
|
|
|
|
|
rows = None
|
|
|
|
|
try:
|
|
|
|
|
|
|
|
|
|
print("Get DBconnection and cursor...")
|
|
|
|
|
# Get DBconnection and cursor...
|
|
|
|
|
conn, cursor = self.get_db_cursor()
|
|
|
|
|
|
|
|
|
|
sql = "select concat(that.username,'@',that.host ) as blocker, " \
|
|
|
|
@ -179,16 +179,16 @@ class BotInstance:
|
|
|
|
|
"and b.\"createdAt\" between current_date - interval '7 day' and current_date " \
|
|
|
|
|
"and this.host is null;".format(self.mk_user)
|
|
|
|
|
|
|
|
|
|
print("Execute SQL statement...")
|
|
|
|
|
# Execute SQL statement...
|
|
|
|
|
cursor.execute(sql)
|
|
|
|
|
|
|
|
|
|
print("Fetch all!")
|
|
|
|
|
# Fetch all!
|
|
|
|
|
rows = cursor.fetchall()
|
|
|
|
|
|
|
|
|
|
print("Closing cursor...")
|
|
|
|
|
# Closing cursor...
|
|
|
|
|
cursor.close()
|
|
|
|
|
|
|
|
|
|
print("Closing DB connection...")
|
|
|
|
|
# Closing DB connection...
|
|
|
|
|
conn.close()
|
|
|
|
|
except Exception as e:
|
|
|
|
|
print("Error: ", e)
|
|
|
|
@ -199,7 +199,7 @@ class BotInstance:
|
|
|
|
|
rows = None
|
|
|
|
|
try:
|
|
|
|
|
|
|
|
|
|
print("Get DBconnection and cursor...")
|
|
|
|
|
# Get DBconnection and cursor...
|
|
|
|
|
conn, cursor = self.get_db_cursor()
|
|
|
|
|
|
|
|
|
|
sql = "select concat(that.username,'@',that.host ) as blocker, " \
|
|
|
|
@ -212,16 +212,16 @@ class BotInstance:
|
|
|
|
|
"and b.\"createdAt\" between current_date - interval '1 month' and current_date " \
|
|
|
|
|
"and this.host is null;".format(self.mk_user)
|
|
|
|
|
|
|
|
|
|
print("Execute SQL statement...")
|
|
|
|
|
# Execute SQL statement...
|
|
|
|
|
cursor.execute(sql)
|
|
|
|
|
|
|
|
|
|
print("Fetch all!")
|
|
|
|
|
# Fetch all!
|
|
|
|
|
rows = cursor.fetchall()
|
|
|
|
|
|
|
|
|
|
print("Closing cursor...")
|
|
|
|
|
# Closing cursor...
|
|
|
|
|
cursor.close()
|
|
|
|
|
|
|
|
|
|
print("Closing DB connection...")
|
|
|
|
|
# Closing DB connection...
|
|
|
|
|
conn.close()
|
|
|
|
|
except Exception as e:
|
|
|
|
|
print("Error: ", e)
|
|
|
|
@ -232,7 +232,7 @@ class BotInstance:
|
|
|
|
|
rows = None
|
|
|
|
|
try:
|
|
|
|
|
|
|
|
|
|
print("Get DBconnection and cursor...")
|
|
|
|
|
# Get DBconnection and cursor...
|
|
|
|
|
conn, cursor = self.get_db_cursor()
|
|
|
|
|
|
|
|
|
|
sql = "select concat(that.username,'@',that.host ) as blocker, " \
|
|
|
|
@ -246,16 +246,16 @@ class BotInstance:
|
|
|
|
|
"order by b.\"createdAt\" desc " \
|
|
|
|
|
"limit 1;".format(self.mk_user)
|
|
|
|
|
|
|
|
|
|
print("Execute SQL statement...")
|
|
|
|
|
# Execute SQL statement...
|
|
|
|
|
cursor.execute(sql)
|
|
|
|
|
|
|
|
|
|
print("Fetch all!")
|
|
|
|
|
# Fetch all!
|
|
|
|
|
rows = cursor.fetchall()
|
|
|
|
|
|
|
|
|
|
print("Closing cursor...")
|
|
|
|
|
# Closing cursor...
|
|
|
|
|
cursor.close()
|
|
|
|
|
|
|
|
|
|
print("Closing DB connection...")
|
|
|
|
|
# Closing DB connection...
|
|
|
|
|
conn.close()
|
|
|
|
|
except Exception as e:
|
|
|
|
|
print("Error: ", e)
|
|
|
|
@ -308,6 +308,7 @@ class BotInstance:
|
|
|
|
|
|
|
|
|
|
# Misskey Post
|
|
|
|
|
def post_note(self, content=""):
|
|
|
|
|
print("Posting note...")
|
|
|
|
|
# Do all the things to create the message
|
|
|
|
|
message = self.msg_text % self.mk_user
|
|
|
|
|
note_content = "%s\n%s" % (message, content)
|
|
|
|
@ -326,3 +327,5 @@ class BotInstance:
|
|
|
|
|
# Some validation here, gotta add a logfile later smh
|
|
|
|
|
if create_note_request.status_code != 200:
|
|
|
|
|
print("Error: " + create_note_request.json()["error"]["message"], file=None)
|
|
|
|
|
else:
|
|
|
|
|
print("Note sent!")
|
|
|
|
|