|
@@ -8,7 +8,14 @@ from pprint import pprint, pformat
|
|
|
|
|
|
|
|
|
|
|
|
|
def send_notification(maintainer, player, property, old_value, new_value):
|
|
def send_notification(maintainer, player, property, old_value, new_value):
|
|
|
- query = """SELECT value FROM player
|
|
|
|
|
|
|
+ name = _name(maintainer, player)
|
|
|
|
|
+ message = f"{name} [{player}] property '{property}' changed from {old_value} to {new_value}"
|
|
|
|
|
+ _send(maintainer, message)
|
|
|
|
|
+ conn.close()
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+def _name(maintainer, player):
|
|
|
|
|
+ query = """SELECT value FROM player
|
|
|
WHERE maintainer = ?
|
|
WHERE maintainer = ?
|
|
|
AND player = ?
|
|
AND player = ?
|
|
|
AND property = 'name';"""
|
|
AND property = 'name';"""
|
|
@@ -20,9 +27,8 @@ def send_notification(maintainer, player, property, old_value, new_value):
|
|
|
val = cur.fetchone()
|
|
val = cur.fetchone()
|
|
|
if val:
|
|
if val:
|
|
|
name = val['value']
|
|
name = val['value']
|
|
|
- message = f"{name} [{player}] property '{property}' changed from {old_value} to {new_value}"
|
|
|
|
|
- _send(maintainer, message)
|
|
|
|
|
conn.close()
|
|
conn.close()
|
|
|
|
|
+ return name
|
|
|
|
|
|
|
|
def _send(maintainer, message):
|
|
def _send(maintainer, message):
|
|
|
query = """SELECT discord FROM discord WHERE maintainer = ?;"""
|
|
query = """SELECT discord FROM discord WHERE maintainer = ?;"""
|
|
@@ -81,6 +87,7 @@ def cron():
|
|
|
# maintainers
|
|
# maintainers
|
|
|
cur.execute(query_first, (maintainer['maintainer'],))
|
|
cur.execute(query_first, (maintainer['maintainer'],))
|
|
|
players = cur.fetchall()
|
|
players = cur.fetchall()
|
|
|
|
|
+ messages = ''
|
|
|
for player in players:
|
|
for player in players:
|
|
|
# Rows for this maintainer
|
|
# Rows for this maintainer
|
|
|
print(f"{player['maintainer']} - {player['api']} - {player['player']} - {player['property']}")
|
|
print(f"{player['maintainer']} - {player['api']} - {player['player']} - {player['property']}")
|
|
@@ -128,7 +135,14 @@ def cron():
|
|
|
new_value = 0
|
|
new_value = 0
|
|
|
# print(f"p_row['value']: {p_row['value']} != new_value: '{new_value}'")
|
|
# print(f"p_row['value']: {p_row['value']} != new_value: '{new_value}'")
|
|
|
if str(p_row['value']) != str(new_value):
|
|
if str(p_row['value']) != str(new_value):
|
|
|
- send_notification(player['maintainer'], player['player'], property, p_row['value'], new_value)
|
|
|
|
|
|
|
+ if len(messages) >1750:
|
|
|
|
|
+ _send(player['maintainer'], messages)
|
|
|
|
|
+ messages = ''
|
|
|
|
|
+ if messages:
|
|
|
|
|
+ messages += '\n'
|
|
|
|
|
+ name = _name(player['maintainer'], player['player'])
|
|
|
|
|
+ messages += f"{name} [{player['player']}] property '{property}' changed from {p_row['value']} to {new_value}"
|
|
|
|
|
+ # send_notification(player['maintainer'], player['player'], property, p_row['value'], new_value)
|
|
|
update_value(player['maintainer'], player['player'], property, new_value)
|
|
update_value(player['maintainer'], player['player'], property, new_value)
|
|
|
new_properties = []
|
|
new_properties = []
|
|
|
# print(f"len(properties): {len(properties)}")
|
|
# print(f"len(properties): {len(properties)}")
|
|
@@ -152,6 +166,7 @@ def cron():
|
|
|
print(f"item: {item} -> value: {value}")
|
|
print(f"item: {item} -> value: {value}")
|
|
|
update_missing_value(player['maintainer'], player['player'], item, value)
|
|
update_missing_value(player['maintainer'], player['player'], item, value)
|
|
|
time.sleep(2)
|
|
time.sleep(2)
|
|
|
|
|
+ _send(maintainer, messages)
|
|
|
conn.close()
|
|
conn.close()
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
if __name__ == '__main__':
|