Exemplo n.º 1
0
def command( command, message, user, recvfrom ):
	link = "http://www.urbandictionary.com/"
	if command != "rurban":
		link += "define.php?term=" + message
	else:
		link += "random.php"
	txt = requests.get( link ).text
	definition = fixHTMLCharsAdvanced( strbetween( txt, "<div class='meaning'>\n", "\n</div>" ) )
	word = fixHTMLCharsAdvanced( strbetween( txt, "<title>Urban Dictionary: ", "</title>" ) )
	if definition != "" and word != "" and not definition.startswith( notDefinedPrefix ):
		toSend = word + ": " + definition
		if len( toSend ) >= 370: # This is roughly the longest message I've been able to send.
			shortLink = googlshort( "http://www.urbandictionary.com/define.php?term=" + word ) # Get a short link here in order to send as much as possible
			toCutOff = len( shortLink ) # Get the length of said link to make room for it
			toSend = toSend[0:(366-toCutOff)] # Using 436 here to allow room for "... " of course
			toSend = toSend.rpartition( " " )[0] # In order to make sure it doesn't cut off in the middle of a word
			toSend += "... " + shortLink # Finally finishing it off
		__main__.sendMessage( toSend, recvfrom )
		return True
	elif definition.startswith( notDefinedPrefix ):
		__main__.sendMessage( message + " isn't defined.", recvfrom )
		return True
	else:
		__main__.sendMessage( "There was a problem. Fix your shit.", recvfrom )
		return False
	return False
Exemplo n.º 2
0
def command( message, user, recvfrom ):
	txt = requests.get( "http://qdb.us/random/" ).text
	quoteNum = fixHTMLCharsAdvanced( strbetween( txt, "\">#", "</a>" ) )
	quote = fixHTMLCharsAdvanced( strbetween( txt, "<span class=qt id=qt" + quoteNum , "</span>" ) )
	quote = quote.replace( "<br />", " / " )
	__main__.sendMessage( "Quote #" + quoteNum + ": " + quote, recvfrom )
	return True
Exemplo n.º 3
0
def command( command, message, user, channel ):
	try:
		if command != "rurban":
			link = "http://urbandictionary.com/define.php?term=" + message
		else:
			link = "http://www.urbandictionary.com/random.php"
		res = requests.get( link )
		definition = __main__.fixHTMLCharsAdvanced( pybotutils.strbetween( res.text, "<div class='meaning'>\n", "\n</div>" ) )
		word = __main__.fixHTMLCharsAdvanced( pybotutils.strbetween( res.text, "<title>Urban Dictionary: ", "</title>" ) )
		if definition != "" and word != "":
			toSend = word + ": " + definition
			if len( toSend ) >= 440: # This is roughly the longest message I've been able to send.
				shortLink = pybotutils.googlshort( "http://www.urbandictionary.com/define.php?term=" + message ) # Get a short link here in order to send as much as possible
				toCutOff = len( shortLink ) # Get the length of said link to make room for it
				toSend = toSend[0:(436-toCutOff)] # Using 436 here to allow room for "... " of course
				toSend = toSend.rpartition( " " )[0] # In order to make sure it doesn't cut off in the middle of a word
				toSend = toSend + "... " + shortLink # Finally finishing it off
			__main__.sendMessage( toSend, channel )
			return True
		else:
			if "<i>" + message + "</i> isn't defined.<br/>Can you define it?" in res.text:
				__main__.sendMessage( message + " isn't defined.", channel )
				return True
			else:
				__main__.sendMessage( "There was a problem. Fix your shit.", channel )
				return False
		return False
	except:
		return False
Exemplo n.º 4
0
def command( message, user, recvfrom ):
	txt = requests.get( "http://mobile-dictionary.reverso.net/english-definition/" + message ).text
	definition = fixHTMLChars( strbetween( txt, "direction=\"target\">", "<span" ) )
	type = fixHTMLChars( strbetween( txt, "style=\"color:#B50000;\" direction=\"\">", "<span" ) )
	if definition != "":
		__main__.sendMessage( message + ": " + type + " - " + definition, recvfrom )
	else:
		__main__.sendMessage( message + " was not found.", recvfrom )
	return True
Exemplo n.º 5
0
def command( message, user, recvfrom ):
	thefml = requests.get( "http://www.fmylife.com/random" ).text
	thefml = strbetween( thefml, "<p class=\"content\">", "</p>" )
	thefml = strbetween( thefml, ">", "</a>" )
	thefml = fixHTMLChars( thefml )
	if thefml == "":
		thefml = "Today, PyBot couldn't find an FML. FML"
	__main__.sendMessage( thefml, recvfrom )
	return True
Exemplo n.º 6
0
def command( message, user, recvfrom ):
	txt = requests.get( "http://www.randomriddles.com/" ).text
	riddle = fixHTMLCharsAdvanced( strbetween( txt, "<strong><i>", " <a ;" ) )
	answer = fixHTMLCharsAdvanced( strbetween( txt, "alert('", "')\"" ) )
	if riddle != "" and answer != "":
		__main__.sendMessage( riddle, recvfrom )
		# Use a timer so we don't block
		threading.Timer( 15.0, __main__.sendMessage, args=( "Answer: " + answer, recvfrom ) ).start()
	return True
Exemplo n.º 7
0
def command(message, user, recvfrom):
    txt = requests.get("http://whatthefuckshouldimakefordinner.com/").text
    meal = fixHTMLChars(strbetween(txt, '" target="_blank">', "</a></dt>"))
    url = fixHTMLChars(strbetween(txt, '<dt><a href="', '" target="_blank">'))
    if meal != "" and url != "":
        __main__.sendMessage(meal + " - " + url, recvfrom)
    else:
        __main__.sendMessage("You will starve!", recvfrom)
    return True
Exemplo n.º 8
0
def command( message, user, recvfrom ):
	txt = requests.get( "https://live.xbox.com/en-US/Profile?gamertag=" + message ).text
	gamerscore = fixHTMLChars( strbetween( txt, "<div class=\"gamerscore\">", "</div>" ) )
	lastseen = fixHTMLChars( strbetween( txt, "<div class=\"presence\">", "</div>" ) )
	gamertag = fixHTMLChars( strbetween( txt, "<title>", "&#39;s Profile" ) ) #get proper case of gamertag
	if gamerscore != "":
		__main__.sendMessage( gamertag + " :: Status: " + lastseen + " :: Gamerscore: " + gamerscore, recvfrom )
	else:
		__main__.sendMessage( message + " was not found.", recvfrom )
	return True
Exemplo n.º 9
0
def command( message, user, recvfrom ):
	status = fixHTMLChars( strbetween( requests.get( "http://isup.me/" + message ).text, "<div id=\"container\">", "<p>" ) ).strip()
	href = strbetween( status, "<a href=\"", "class=\"domain\">" )
	status = status.replace( "<a href=\"" + href + "class=\"domain\">", "" )
	status = status.replace( "</a>", "" ).replace( "</span>", "" ).replace( "  ", " " )
	if status != "":
		__main__.sendMessage( status, recvfrom )
	else:
		__main__.sendMessage( "Something went wrong.", recvfrom )
	return True
Exemplo n.º 10
0
def command( message, user, recvfrom ):
	txt = fixHTMLChars( requests.get( "http://www.zip-info.com/cgi-local/zipsrch.exe?ac=ac&tz=tz&zip=" + message + "&Go=Go" ).text )
	city = strbetween( txt, "</th></tr><tr><td align=center>", "</font>" )
	state = strbetween( txt, "</font></td><td align=center>", "</font></td><td align=center>" )
	acode = strbetween( txt, "<td align=center>" + message + "</font></td><td align=center>", "</font>" )
	timezone = strbetween( txt, acode + "</font></td><td align=center>", "</font></td><td align=center>Yes</font></td></tr></table>" )
	
	if zip != "":
		__main__.sendMessage( "Zip: " + message + " | City: " + city + " | State: " + state + " | Area Code: " + acode + " | Time Zone: " + timezone, recvfrom )
	else:
		__main__.sendMessage( message + " was not found.", recvfrom )
	return True
Exemplo n.º 11
0
def command( message, user, recvfrom ):
	json_data = { "title" : recvfrom, "data" : message, "language" : "text", "expire" : "31536000", "private" : "true" }
	txt = requests.post( "https://paste.kde.org/api/json/create", data=json_data ).text
	pasteid = strbetween( txt, "\"id\": \"", "\"," )
	pastehash = strbetween( txt, "\"hash\": \"", "\"" )
	if pasteid != "" and pastehash != "":
		__main__.sendMessage( "https://paste.kde.org/" + pasteid + "/" + pastehash, recvfrom )
	else:
		if "antispam" in txt:
			__main__.sendMessage( "Paste filtered by anti-spam filter! Try something else.", recvfrom )
		else:
			__main__.sendMessage( "Paste unsuccessful. Try again later!", recvfrom )
	return True
Exemplo n.º 12
0
def command( message, user, recvfrom ):
	message = message.strip().lower()
	if message in signs:
		txt = requests.get( "http://www.astrology.com/horoscope/daily/" + message + ".html" ).text
		horoscope = fixHTMLCharsAdvanced( strbetween( strbetween( txt, "<div class=\"page-horoscope-text\" style=\"", "<div" ), ">", "</div>" ) )
		if horoscope != "":
			__main__.sendMessage( horoscope, recvfrom )
		else:
			__main__.sendMessage( message + "'s sign not found today. :(", recvfrom )
	elif message == "":
		__main__.sendMessage( "Usage: horoscope [sign]", recvfrom )
	else:
		__main__.sendMessage( "Invalid sign. Valid signs: " + (", ".join( signs )), recvfrom )
	return True
Exemplo n.º 13
0
def googlshort( link ):
	try:
		# TODO: Why do we need to do this every time...
		with open( "Utilities" + os.sep + "pybotutils" + os.sep + "googlapikey.txt", "r" ) as apikeyfile:
			GOOGL_API_KEY = apikeyfile.read()
		if not link.startswith( "http://goo.gl/" ) and not link.startswith( "https://goo.gl/" ):
			json_data = "{\n\t\"longUrl\" : \"" + link + "\"\n}"
			theheaders = { "content-type" : "application/json" }
			res = requests.post( "https://www.googleapis.com/urlshortener/v1/url?key=" + GOOGL_API_KEY, data=json_data, headers=theheaders )
			return pybotutils.strbetween( res.text, "\"id\": \"", "\"" )
		else:
			res = requests.get( "https://www.googleapis.com/urlshortener/v1/url?key=" + GOOGL_API_KEY + "&shortUrl=" + link )
			return pybotutils.strbetween( res.text, "\"longUrl\": \"", "\"" )
	except:
		return ""
Exemplo n.º 14
0
def handle( packet ):
	try:
		if packet['rest'][0] == "#": # just parsing channel messages here
			user = strbetween( packet['host'], ":", "!" )
			if __main__.getAccessLevel( user ) < 0:
				return False # Get out of here banned loser!
			msgsplit = packet['rest'].split( " :", maxsplit=1 )
			channel = msgsplit[0]
			splitmessage = msgsplit[1].split( " " )
			titleFound = False
			for totest in splitmessage:
				if urlregex.search( totest ): # great, we found a URL!
					if not totest.startswith( "http" ): # We need this at the start for some damn reason
						totest = "http://" + totest
					try: # who knows what we got sent to
						tosend = ""
						if "imgur.com" in totest:
							tosend = imgur( totest )
						elif "youtube.com" in totest or "youtu.be" in totest:
							tosend = youtube( totest )
						else:
							tosend = normalLink( totest )
						tosend = tosend.replace( "google", "Google" ).replace( "Google", "\x02\x03" + "02,00G\x03" + "04,00o\x03" + "08,00o\x03" + "02,00g\x03" + "03,00l\x03" + "04,00e\x03\x02" )
						if tosend != "":
							__main__.sendMessage( tosend, channel )
							titleFound = True
					except:
						continue
			return titleFound
		return False
	except:
		return False
Exemplo n.º 15
0
def youtube( link ):
	try:
		# Preserve initial link var for BreakoutException
		youtubelink = link
		
		ourdata = fetchLinkData( youtubelink, 3.75 )
		
		title = fixHTMLCharsAdvanced( strbetween( ourdata, "<meta itemprop=\"name\" content=\"", "\">" ) )
		
		views = format( int( strbetween( ourdata, "<meta itemprop=\"interactionCount\" content=\"", "\">" ) ), "," )
		if views == "":
			raise BreakoutException
		
		return "\x02\x03" + "01,00You\x03" + "00,04Tube\x03:\x02 \"" + title + "\"" + " | Views: " + views
	except: # Handle it like a normal link?
		return normalLink( link )
Exemplo n.º 16
0
def command( message, user, recvfrom ):
	message = message.split( " " )
	if len( message ) != 3 or not message[0].isdigit():
		__main__.sendMessage( "Usage: currency [amount] [from] [to]", recvfrom )
	else:
		txt = requests.get( "http://www.fxexchangerate.com/m/converter-" + message[0] + "-" + message[1] + "-to-" +  message[2] + ".html" ).text
		from1 = fixHTMLCharsAdvanced( strbetween( txt, "<title>Converter ", " To" ) )
		to1 = fixHTMLCharsAdvanced( strbetween( txt, "Bid Price: ", "</div>" ) )
		toname = fixHTMLCharsAdvanced( strbetween( txt, "To ", " - FX Exchange Rate</title>" ) )
		updated = fixHTMLCharsAdvanced( strbetween( txt, "Updated:: ",  "</div>" ) )
		if from1 != "" and " = 0 " not in from1:
			__main__.sendMessage( from1 + " = " + to1 + " " + toname + " :: Last Updated: " + updated , recvfrom )
			return True
		else:
			__main__.sendMessage( "Conversion unsuccessful! Make sure to use proper currency codes.", recvfrom )
	return False
Exemplo n.º 17
0
def command( message, user, recvfrom ):
	insult = fixHTMLCharsAdvanced( strbetween( requests.get( "http://www.randominsults.net/" ).text, "<strong><i>", "</i></strong>" ) )
	if insult != "":
		__main__.sendMessage( message + ": " + insult, recvfrom )
	else:
		__main__.sendMessage( "There was a problem. Fix your shit.", recvfrom )
	return True
Exemplo n.º 18
0
def normalLink( link ):
	try:
		ourdata = fetchLinkData( link )
		if ourdata == "":
			return ""
		# Some places have decided 'hey lets use whitespaces in titles for no particular reason'; f**k them
		urlstitle = strbetween( ourdata, "<title>", "</title>" ).strip()
		if urlstitle != "":
			return "\x02URL:\x02 " + fixHTMLCharsAdvanced( urlstitle )
		elif "<TITLE>" in ourdata:
			# f****n pricks using caps can f**k off, seriously f**k them too
			urlstitle = strbetween( ourdata, "<TITLE>", "</TITLE>" ).strip() # see above
			if urlstitle != "":
				return "\x02URL:\x02 " + fixHTMLCharsAdvanced( urlstitle )
		return ""
	except:
		return ""
Exemplo n.º 19
0
def command( message, user, recvfrom ):
	txt = requests.get( "http://mobile-dictionary.reverso.net/english-synonyms/" + message ).text
	synonym = fixHTMLChars( strbetween( txt, "direction=\"target\">", "<span" ) )
	if synonym != "":
			__main__.sendMessage( "Synonyms for " + message + ": " + synonym, recvfrom )
	else:
		__main__.sendMessage( message + " was not found.", recvfrom )
	return True
Exemplo n.º 20
0
def command( message, user, recvfrom ):
	# .co.uk works with both UK and USA. .com does not!
	wbpostfix = ".co.uk"
	#splitmessage = message.split( ' ', maxsplit=1 )
	#if len( splitmessage ) == 2:
	#	if len( splitmessage[0] ) == 3 and len( splitmessage[1] ) == 3:
	#		wbpostfix = ".co.uk"
	txt = requests.get( "http://weather.weatherbug" + wbpostfix + "/Common/SearchResults.html?loc=" + message + "&is_search=true&nav_section=1&loc_country=WORLD&zcode=z6286&submit=GO" ).text
	try:
		location = fixHTMLCharsAdvanced( strbetween( txt, "\r\n<div class=\"boxhdr\">", "</h2>" ) ).replace( "  ", "" ).replace( "<h2>", "" ).strip() # Oh god this is ugly. so very ugly.
		farTemp = fixHTMLChars( strbetween( txt, "<div><strong><span id=\"divTemp\" class=\"entry-title\">", "&deg;F</span></strong>" ) ) #Fahrenheit
		celTemp = str( round( ( float( farTemp ) - 32 ) * 5 / 9, 1 ) ) #celsius
		humidity = fixHTMLChars( strbetween( txt, "<span id=\"divHumidity\" class=\"strong-value\">", "</span></div>" ) )
		feelsLikeLabel = fixHTMLChars( strbetween( txt, "<span id=\"spanFeelsLikeLabel\">", "</span>" ) )
		feelsLikeF = fixHTMLChars( strbetween( txt, "<span id=\"divFeelsLike\" class=\"strong-value\">", "&deg;F</span></div>" ) )
		feelsLikeC = str( round( ( float( feelsLikeF ) - 32 ) * 5 / 9, 1 ) ) #celsius
		rain = fixHTMLChars( strbetween( txt, "<span id=\"divRain\" class=\"strong-value\">", "</span></div>" ) )
		gust = fixHTMLChars( strbetween( txt, "<span id=\"divGust\" class=\"strong-value\">", "</span></div>" ) )
		if farTemp != "":
			toSend = location + " | Temperature: " + farTemp + "°F/" + celTemp + "°C"
			if humidity != "":
				toSend = toSend + " | Humidity: " + humidity
			if feelsLikeLabel != "" and feelsLikeF != "":
				toSend = toSend + " | " + feelsLikeLabel + ": " + feelsLikeF + "°F/" + feelsLikeC + "°C"
			if rain != "":
				toSend = toSend + " | Rain: " + rain
			if gust != "":
				toSend = toSend + " | Gust: " + gust
			__main__.sendMessage( toSend, recvfrom )
			return True
	except:
		pass
	__main__.sendMessage( message + " was not found.", recvfrom )
	return False
Exemplo n.º 21
0
def command( message, user, recvfrom ):
	message = message.strip()
	if message != "":
		definition = fixHTMLChars( strbetween( requests.get( "http://tangorin.com/general/" + message ).text, "<span class=\"kana\"><ruby><rb>", "</rb>" ) )
		if definition != "":
			__main__.sendMessage( message + ": " + definition, recvfrom )
		else:
			__main__.sendMessage( message + " was not found.", recvfrom )
	else:
		__main__.sendMessage( "Usage: jdic [words]", recvfrom )
	return True
Exemplo n.º 22
0
def command( message, user, recvfrom ):
	txt = fixHTMLChars( requests.get( "http://ws.audioscrobbler.com/2.0/user/" + message + "/recenttracks.xml?limit=1" ).text )
	artist = strbetween( txt, "<artist>", "</artist>" )
	song = strbetween( txt, "<name>", "</name>" )
	album = strbetween( txt, "<album>", "</album>" )
	
	if album != "":
		albumtext = " from the album " + album
	else:
		albumtext = ""
	
	if "<track nowplaying=\"true\">" in txt:
		nowplaying = " is listening "
	else:
		nowplaying = " last listened "
	if song != "":
		__main__.sendMessage( message + nowplaying + "to " + song + " by " + artist + albumtext, recvfrom )
	else:
		__main__.sendMessage( message + " was not found.", recvfrom )
	return True
Exemplo n.º 23
0
def command( message, user, recvfrom ):
	if message == "" or message == " ":
		__main__.sendMessage( "Usage: geoip [ip.add.re.ss/domain.name]", recvfrom )
		return True
	txt = requests.get( "http://freegeoip.net/json/" + message ).text
	ip = strbetween( txt, "\"ip\":\"", "\"," )
	latitude = strbetween( txt, "\"latitude\":", ",\"" )
	longitude = strbetween( txt, "\"longitude\":", ",\"" )
	#countryCode = strbetween( txt, "\"country_code\":\"", "\"," )
	countryName = strbetween( txt, "\"country_name\":\"", "\"," )
	#regionCode = strbetween( txt, "\"region_code\":\"", "\"," )
	regionName = strbetween( txt, "\"region_name\":\"", "\"," )
	city = strbetween( txt, "\"city\":\"", "\"," )
	#zipcode = strbetween( txt, "\"zipcode\":\"", "\"," )
	if ip != "": # IP has to be there if there was any useful info
		toSend = "IP: " + ip
		if city != "" and countryName != "" and regionName != "":
			toSend += " | Location: "
			if city != "":
				toSend += city + ", "
			if regionName != "":
				toSend += regionName + ", "
			if countryName != "":
				toSend += countryName
		if latitude != "" and longitude != "":
			toSend += " | Coordinates: " + latitude + "," + longitude
		if toSend == "IP: " + ip + " | Coordinates: 38,-97": # This is a bullshit result
			toSend = message + " was not found."
		__main__.sendMessage( toSend, recvfrom )
	else:
		__main__.sendMessage( message + " was not found.", recvfrom )
Exemplo n.º 24
0
def command( message, user, recvfrom ):
	message = message.strip()
	if message == "":
		message = user
	txt = requests.get( "https://steamdb.info/calculator/?player=" + message ).text
	playername = strbetween( txt, "<title>", " · " )
	if playername != "Error":
		construct = playername + ": "
		table = strbetween( txt, "<p><br>[list]", "[/list]</p>" )
		worth = strbetween( table, "[*][b]Worth:[/b] ", "</p>" )
		if worth != "":
			construct += worth
		owned = strbetween( table, "<p>[*][b]Games owned:[/b] ", "</p>" )
		notplayed = strbetween( table, "<p>[*][b]Games not played:[/b] ", " [i](" )
		if owned != "" and notplayed != "":
			played = str( int( owned ) - int( notplayed ) )
			construct += " | " + played + "/" + owned + " Games Played/Owned"
		__main__.sendMessage( construct, recvfrom )
		return True
	else:
		__main__.sendMessage( message + " was not found.", recvfrom )
		return False
	return False
Exemplo n.º 25
0
def command( message, user, recvfrom ):
	# There is a lot of shit. Cut off as much as possible before sending it to the HTML parser in an effort to speed up parsing
	datlongtext = strbetween( requests.get( "http://www.google.com/search?q=" + message ).text, " id=\"resultStats\">", "</html>" )
	datlongtext = datlongtext.replace( "<b>", "" ).replace( "</b>", "" ).replace( "<em>", "" ).replace( "</em>", "" ) # Get rid of bolds, this tends to be used just to highlight the keyword searched
	resultOneUnparsed = strbetween( datlongtext, "<h3 class=\"r\">", "</h3>" ) # The link and result text come between this
	datlongtext = datlongtext.replace( "<h3 class=\"r\">" + resultOneUnparsed + "</h3>", "" ) # Now that we got the first one, get rid of it to find the next one
	resultTwoUnparsed = strbetween( datlongtext, "<h3 class=\"r\">", "</h3>" )
	datlongtext = datlongtext.replace( "<h3 class=\"r\">" + resultTwoUnparsed + "</h3>", "" )
	resultThreeUnparsed = strbetween( datlongtext, "<h3 class=\"r\">", "</h3>" )
	datlongtext = datlongtext.replace( "<h3 class=\"r\">" + resultThreeUnparsed + "</h3>", "" )
	# Great, now we've got the three results isolated. Let's parse them!
	resultOneLink = strbetween( resultOneUnparsed, "<a href=\"/url?q=", "&amp;sa=U" )
	resultTwoLink = strbetween( resultTwoUnparsed, "<a href=\"/url?q=", "&amp;sa=U" )
	resultThreeLink = strbetween( resultThreeUnparsed, "<a href=\"/url?q=", "&amp;sa=U" )
	resultOneText = strbetween( resultOneUnparsed, "\">", "</a>" )
	resultTwoText = strbetween( resultTwoUnparsed, "\">", "</a>" )
	resultThreeText = strbetween( resultThreeUnparsed, "\">", "</a>" )
	if resultOneLink != "" and resultOneText != "":
		__main__.sendMessage( htmlCleaner( resultOneText ) + " - " + htmlCleaner( resultOneLink ), recvfrom )
	if resultTwoLink != "" and resultTwoText != "":
		threading.Timer( 0.5, __main__.sendMessage, args=( htmlCleaner( resultTwoText ) + " - " + htmlCleaner( resultTwoLink ), recvfrom ) ).start()
	if resultThreeLink != "" and resultThreeText != "":
		threading.Timer( 1.0, __main__.sendMessage, args=( htmlCleaner( resultThreeText ) + " - " + htmlCleaner( resultThreeLink ), recvfrom ) ).start()
	return True
Exemplo n.º 26
0
def handle( packet ):
	try:
		if packet['rest'][0] != "#": # just parsing PM messages here
			message = packet['rest'].split( " :", maxsplit=1 )[1].strip()
			if message[0] != "\x01" and message[-1] != "\x01": # CTCPs tend to use this, derp
				return False
			user = strbetween( packet['host'], ":", "!" )
			if __main__.getAccessLevel( user ) < 0:
				return False # Get out of here banned loser!
			message = message[1:-1] # Just chop off the \x01s now
			toSend = ""
			if message == "VERSION":
				toSend = "NOTICE " + user + " :\x01VERSION PyBot " + __main__.pyBotVersion + ".\x01"
			elif message == "TIME":
				toSend = "NOTICE " + user + " :\x01TIME " + time.strftime( "%a %b %d %X" ) + "\x01"
			elif message.startswith( "PING " ):
				toSend = "NOTICE " + user + " :\x01" + message + "\x01"
			if toSend != "":
				__main__.sendPacket( __main__.makePacket( toSend ) )
				return True
		return False
	except:
		return False
Exemplo n.º 27
0
def command( message, user, recvfrom ):
	thefact = fixHTMLChars( strbetween( requests.get( "http://randomfunfacts.com/" ).text, "<font face=\"Verdana\" size=\"4\"><strong><i>", "</i></strong>" ) )
	if thefact == "":
		thefact = "I failed to fetch an actual fact. Sorry!"
	__main__.sendMessage( thefact, recvfrom )
	return True
Exemplo n.º 28
0
def command( message, user, recvfrom ):
	thehaiku = fixHTMLCharsAdvanced( strbetween( requests.get( "http://prestopnik.com/emo_haiku/" ).text, "<div align=center><BR><BR>", "<BR><BR><BR><BR></div>" ) ).replace( "<BR>", " " )
	if thehaiku == "":
		thehaiku = "I should probably. Write an actual haiku. For error message."
	__main__.sendMessage( thehaiku, recvfrom )
	return True
Exemplo n.º 29
0
def getMessageUser(packet):
    return pybotutils.strbetween(packet["host"], ":", "!")
Exemplo n.º 30
0
def command( message, user, recvfrom ):
	thewotd = strbetween( requests.get( "http://dictionary.reference.com/wordoftheday/" ).text, "<title>Get the Word of the Day - ", " |" )
	if thewotd == "":
		thewotd = "fail"
	__main__.sendMessage( "Word of the Day: " + thewotd, recvfrom )
	return True