basestring checks if the value is a str or unicode type so that either can be used because unicode data is sent to the bot. Unicodes don't register in Python as strings but unicodes register as basestring types. Since unicodes are sent, unicode data cannot be shipped back because unicodes won't register as strings in the API.
Eg:
def newSong(data):
global genre,artist,lameGenres,lameArtists
songData = data['room']['metadata']['current_song']
DJid = songData['djid'] # THIS DATA IS A UNICODE TYPE!
artist = songData['metadata']['artist']
genre = songData['metadata']['genre']
for i in range(len(lameGenres)): # Note: for loop is used because lameGenres contains substrings of disallowed genres in case there are 2 different genres such as "Rap" and "Rap/Hip Hop"
if lameGenres[i].lower() in genre.lower():
eebot.remDj(DJid) # REMDJ WILL NOT WORK WITH UNICODE TYPES!
eebot.speak('%s is not allowed!' % genre)
break
for i in range(len(lameArtists)):
if lameArtists[i].lower() in artist.lower():
eebot.remDj(DJid) # SAME AS ABOVE
eebot.speak('This kind of music is not allowed!')
break
basestring checks if the value is a str or unicode type so that either can be used because unicode data is sent to the bot. Unicodes don't register in Python as strings but unicodes register as basestring types. Since unicodes are sent, unicode data cannot be shipped back because unicodes won't register as strings in the API. Eg:
TLDR: basestring checks for str and unicode types