mirror of
https://github.com/vgstation-coders/vgstation13.git
synced 2025-12-10 10:21:11 +00:00
Added CC-Nanotrasen, an IRC bot made by Skibiliano and given to us by him under CC-BY-SA 3.0 licensing WHAT DOES THIS MEAN? It means all servers running this SVN now have the option to use an easy to configure IRC bot capable of relaying adminhelps from ingame to the server/channel of their choice. - Runs on python 2.6 scripts with psyco support - Relaying can be toggled from config.txt (so you don't runtime with every adminhelp if you decide not to use it) - Comes with a bunch of other useful and fun tools too - Added a new global proc, send2irc(msg,msg2) YOU'LL NEVER GUESS WHAT IT DOES CONSIDERING WHAT I JUST MENTIONED ----msg and msg2 are just what text gets relayed to irc, separated by a |, for instance send2irc(hello, world) would come out as "CC_NanoTrasen: Hello | World git-svn-id: http://tgstation13.googlecode.com/svn/trunk@2783 316c924e-a436-60f5-8080-3fe189b3f50e
76 lines
2.8 KiB
Python
76 lines
2.8 KiB
Python
from urllib2 import urlopen
|
|
from CORE_DATA import directory,no_absolute_paths
|
|
def YTCV2(youtube_url,cache=1,debug=0):
|
|
import time
|
|
__doc__ = "Cache 0 = No cache access, Cache 1 = Cache access (Default)"
|
|
if cache == 1:
|
|
import md5
|
|
import pickle
|
|
crypt = md5.md5(youtube_url)
|
|
try:
|
|
cryp = crypt.hexdigest()
|
|
if no_absolute_paths:
|
|
tiedosto = open("YTCache/"+cryp,"r")
|
|
else:
|
|
tiedosto = open(directory+"\NanoTrasen\YTCache\\"+cryp,"r")
|
|
aha = pickle.load(tiedosto)
|
|
tiedosto.close()
|
|
return aha[0]
|
|
except:
|
|
if no_absolute_paths:
|
|
tiedosto = open("YTCache/"+crypt.hexdigest(),"w")
|
|
else:
|
|
tiedosto = open(directory+"\NanoTrasen\YTCache\\"+crypt.hexdigest(),"w")
|
|
else:
|
|
pass
|
|
youtube_url = youtube_url.replace("http//","http://")
|
|
if youtube_url.lower()[0:7] != "http://" and youtube_url[0:4] == "www.":
|
|
youtube_url = "http://" + youtube_url
|
|
if youtube_url.count("/") + youtube_url.count("\\") < 3:
|
|
return "Reflex: Video cannot exist"
|
|
else:
|
|
if youtube_url[0:7].lower() != "http://":
|
|
return "Reflex: Incorrect link start"
|
|
try:
|
|
website = urlopen(youtube_url)
|
|
except:
|
|
return "Reflex: Incorrect link!"
|
|
for i in website:
|
|
if i.count('<meta name="title" content') == 1:
|
|
epoch = time.time()
|
|
if type(i[30:-3]) != str:
|
|
if cache == 1:
|
|
aha = ["No title for video",epoch]
|
|
pickle.dump(aha,tiedosto)
|
|
tiedosto.close()
|
|
tiedosto.close()
|
|
return "Video deleted"
|
|
else:
|
|
result = i[30:-3]
|
|
if "&quot;" in result:
|
|
result = result.replace("&quot;",'"')
|
|
else:
|
|
pass
|
|
if "&amp;" in result:
|
|
result = result.replace("&amp;","&")
|
|
else:
|
|
pass
|
|
if "&#39;" in result:
|
|
result = result.replace("&#39;","'")
|
|
else:
|
|
pass
|
|
if cache == 1:
|
|
aha = [result,epoch]
|
|
pickle.dump(aha,tiedosto)
|
|
tiedosto.close()
|
|
tiedosto.close()
|
|
return result
|
|
|
|
if cache == 1:
|
|
epoch = time.time()
|
|
aha = ["No title for video, could be removed / does not exist at all",epoch]
|
|
pickle.dump(aha,tiedosto)
|
|
tiedosto.close()
|
|
tiedosto.close()
|
|
return "No title for video, could be removed / does not exist at all"
|