<commit_before>import os
import time
from slackclient import SlackClient


# curlybot's ID as an environment variable
BOT_ID = os.environ.get("BOT_ID")
AT_BOT = "<@" + BOT_ID + ">"


# instantiate Slack & Twilio clients
slack_client = SlackClient(os.environ.get('SLACK_BOT_TOKEN'))

def index_cmd(resource): 
  return "Here's a list of "+resource+" you wanted: \n- item 1\n item 2"

BOTCOMMANDS = {"list all the ": index_cmd, "give me all the ": index_cmd}
#IDEA: split at the first 'the' to find the object

def handle_command(command, channel):
  """
    Receives commands directed at the bot and determines if they
    are valid commands. If so, then acts on the commands. If not,
    returns back what it needs for clarification.
  """
  response = "Not sure what you mean. Use the *list all the " + \
         "* command with a resource, delimited by spaces."
<commit_msg>adds pcurl resquester fn<commit_after>import os
import time
import json
from slackclient import SlackClient
import pycurl
from io import BytesIO

# curlybot's ID as an environment variable
BOT_ID = os.environ.get("BOT_ID")
AT_BOT = "<@" + BOT_ID + ">"

# instantiate Slack & Twilio clients
slack_client = SlackClient(os.environ.get('SLACK_BOT_TOKEN'))

def index_cmd(resource):
  result = make_request(resource)
  if (result == None):
    return "Sorry! Couldn't return a list of " + resource + "."
  else:
    return "Here's a list of "+resource+" you wanted: \n```\n"+result+"\n```"

BOTCOMMANDS = {"list all the ": index_cmd, "give me all the ": index_cmd}
#IDEA: split at the first 'the' to find the object

HOST = 'https://api.github.com' 
PATH = '/'

#'users/digitalWestie/repos'

def make_request(resource):
  url = HOST+PATH+resource
  print 'Making a request to ' + url
  data = BytesIO()
  c = pycurl.Curl()
  c.setopt(c.URL, url)
  c.setopt(c.WRITEFUNCTION, data.write)
  c.perform()
  c.close()
  r = data.getvalue()
  data.close()
  try:
    jsondata = json.loads(r)
    return json.dumps(jsondata,  sort_keys=True, indent=2, separators=(',', ': '))
  except: 
    print "couldn't parse json from request to " + url


def handle_command(command, channel):
  """
    Receives commands directed at the bot and determines if they
    are valid commands. If so, then acts on the commands. If not,
    returns back what it needs for clarification.
  """
  response = "Not sure what you mean. Use the *list all the " + \
         "* command with a resource, delimited by spaces."

{'fraction_non_alphanumeric': 0.11728896103896104, 'fraction_numerical': 0.0012175324675324675, 'mean_word_length': 3.7771317829457365, 'pattern_counts': {'":': 4, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 1, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5120225', 'n_tokens_mistral': 838, 'n_tokens_neox': 812, 'n_words': 283}