# Path: twitchapi/krakenv5/channels.py
# def setChannelTitle(channel, title):
#     args = [channel]
#     header = {
#             u'Accept': u'application/vnd.twitchtv.v5+json',
#             u'Authorization' : u'OAuth %s' % EDITOR_TOKEN,
#             u'Content-Type': u'application/json',
#     }
# 
#     data = {
#         u'channel' : {
#             u'status' : title
#         }
#     }
# 
#     if len(title) < 1 or len(title) > 140:
#         return "Title String is not an appropriate length"
# 
#     status = endpoints.endpoint_put('channels', CLIENT_ID,
#         data=json.dumps(data), header=header, endpoint_args = args)
# 
#     return status
# 
# def getChannelId(channel):
#     return getChannelObject(channel)['_id']


from twitchapi.krakenv5.channels import setChannelTitle, getChannelId
import ConfigParser

def react_chat_settitle(args):
    config = ConfigParser.ConfigParser()
    config.read('config.ini')
    channelName = config.get('CHAT', 'channel')
    channel = str(getChannelId(channelName))

# Path: twitchapi/krakenv5/channels.py
# def setChannelTitle(channel, title):
#     args = [channel]
#     header = {
#             u'Accept': u'application/vnd.twitchtv.v5+json',
#             u'Authorization' : u'OAuth %s' % EDITOR_TOKEN,
#             u'Content-Type': u'application/json',
#     }
# 
#     data = {
#         u'channel' : {
#             u'status' : title
#         }
#     }
# 
#     if len(title) < 1 or len(title) > 140:
#         return "Title String is not an appropriate length"
# 
#     status = endpoints.endpoint_put('channels', CLIENT_ID,
#         data=json.dumps(data), header=header, endpoint_args = args)
# 
#     return status
# 
# def getChannelId(channel):
#     return getChannelObject(channel)['_id']


# Path: twitchapi/commands/settitle.py
from twitchapi.krakenv5.channels import setChannelTitle, getChannelId
import ConfigParser


def react_chat_settitle(args):
    config = ConfigParser.ConfigParser()
    config.read('config.ini')
    channelName = config.get('CHAT', 'channel')
    channel = str(getChannelId(channelName))

    setChannelTitle(channel, ' '.join(args))