Skip to content

Fix Slack integration for logging

So basically, when I (SeanP) disabled Mike Kanning's account in Slack, it disabled all of the integrations that he set up. Most of which I was able to re-enable, but not the GHNP Bot, which is used to log batch load stats to the ghnp-logs channel.

So I set up a new Slack webhook, and this little blurb worked to send a message to the ghnp-logs channel:

import requests

def main():
  jsondata = "{'text': 'Hello, this message is from the production server'}"
  url = "https://hooks.slack.com/services/EXAMPLE324/EXAMPLE134FD/exAmple23423423"
  r = requests.post(url, data=jsondata)
  # for debugging:
  # print(r.text)

if __name__ == '__main__':
  main()

So I'm thinking that we can rewrite the code to use the above method rather than using the now-deprecated SlackClient package that is currently being used.

This would only need to be fixed in these two files:

https://gitlab.galileo.usg.edu/DLG/ghnp/-/blob/master/core/management/commands/load_batches.py https://gitlab.galileo.usg.edu/DLG/ghnp/-/blob/master/core/management/commands/load_dlg_batches.py

Edited by Josh Wier