This commit is contained in:
BotoX 2018-09-21 15:03:49 +02:00
parent 1fdca881c9
commit 1d18414148
12 changed files with 250 additions and 17 deletions

View File

@ -61,6 +61,7 @@ class AsyncClient():
def OnReceive(self, data):
Obj = json.loads(data)
print(Obj)
if "method" in Obj and Obj["method"] == "publish":
self.Master.OnPublish(Obj)
@ -79,6 +80,7 @@ class AsyncClient():
return None
Data = json.dumps(obj, ensure_ascii = False, separators = (',', ':')).encode("UTF-8")
print(obj)
with (await self.SendLock):
if not self.Protocol:

View File

@ -224,8 +224,8 @@ class AudioClip():
def __del__(self):
self.Logger.info("~AudioClip()")
def Play(self, seconds = None):
return self.AudioPlayer.PlayURI(self.URI, seconds)
def Play(self, seconds = None, *args):
return self.AudioPlayer.PlayURI(self.URI, seconds, *args)
def Stop(self):
return self.AudioPlayer.Stop()
@ -247,7 +247,7 @@ class AudioClip():
self.Player.Storage["Audio"]["LastUseLength"] += Delta
if str(self.Level) in self.Torchlight().Config["AudioLimits"]:
if self.Player:
if self.Player.Storage:
if self.Player.Storage["Audio"]["TimeUsed"] >= self.Torchlight().Config["AudioLimits"][str(self.Level)]["TotalTime"]:
self.Torchlight().SayPrivate(self.Player, "You have used up all of your free time! ({0} seconds)".format(
self.Torchlight().Config["AudioLimits"][str(self.Level)]["TotalTime"]))

View File

@ -50,6 +50,10 @@ class CommandHandler():
Message.append("")
Message[1] = Message[1].strip()
if Message[1] and self.Torchlight().LastUrl:
Message[1] = Message[1].replace("!last", self.Torchlight().LastUrl)
line = Message[0] + ' ' + Message[1]
Level = 0
if player.Access:
Level = player.Access["level"]

View File

@ -37,6 +37,7 @@ class URLFilter(BaseCommand):
self.re_youtube = self.re.compile(r'.*?(?:youtube\.com\/\S*(?:(?:\/e(?:mbed))?\/|watch\?(?:\S*?&?v\=))|youtu\.be\/)([a-zA-Z0-9_-]{6,11}).*?')
async def URLInfo(self, url, yt = False):
Text = None
Info = None
match = self.re_youtube.search(url)
if match or yt:
@ -62,7 +63,8 @@ class URLFilter(BaseCommand):
else:
match = None
url += "#t={0}".format(Time)
if Time:
url += "#t={0}".format(Time)
else:
try:
@ -76,10 +78,13 @@ class URLFilter(BaseCommand):
if not ContentLength:
ContentLength = -1
if ContentType.startswith("text") and not ContentType.startswith("text/plain"):
Soup = self.BeautifulSoup(Content.decode("utf-8", errors = "ignore"), "lxml")
if Soup.title:
self.Torchlight().SayChat("[URL] {0}".format(Soup.title.string))
if ContentType.startswith("text"):
if ContentType.startswith("text/plain"):
Text = Content.decode("utf-8", errors = "ignore")
else:
Soup = self.BeautifulSoup(Content.decode("utf-8", errors = "ignore"), "lxml")
if Soup.title:
self.Torchlight().SayChat("[URL] {0}".format(Soup.title.string))
elif ContentType.startswith("image"):
fp = self.io.BytesIO(Content)
im = self.Image.open(fp)
@ -95,7 +100,7 @@ class URLFilter(BaseCommand):
self.Logger.error(traceback.format_exc())
self.Torchlight().LastUrl = url
return url
return url, Text
async def _rfunc(self, line, match, player):
Url = match.groups()[0]
@ -103,9 +108,14 @@ class URLFilter(BaseCommand):
Url = "http://" + Url
if line.startswith("!yt "):
URL = await self.URLInfo(Url, True)
URL, _ = await self.URLInfo(Url, True)
return "!yt " + URL
if line.startswith("!dec "):
_, text = await self.URLInfo(Url, False)
if text:
return "!dec " + text
asyncio.ensure_future(self.URLInfo(Url))
return -1
@ -455,9 +465,6 @@ class YouTube(BaseCommand):
self.Torchlight().SayPrivate(player, "Torchlight is currently disabled!")
return 1
if self.Torchlight().LastUrl:
message[1] = message[1].replace("!last", self.Torchlight().LastUrl)
Temp = DataHolder()
Time = None
@ -574,6 +581,52 @@ class Say(BaseCommand):
asyncio.ensure_future(self.Say(player, Language, message[1]))
return 0
class DECTalk(BaseCommand):
import tempfile
def __init__(self, torchlight):
super().__init__(torchlight)
self.Triggers = ["!dec"]
self.Level = 0
async def Say(self, player, message):
message = "[:phoneme on]" + message
TempFile = self.tempfile.NamedTemporaryFile(delete = False)
TempFile.close()
Proc = await asyncio.create_subprocess_exec("wine", "say.exe", "-w", TempFile.name,
cwd = "dectalk", stdin = asyncio.subprocess.PIPE)
await Proc.communicate(message.encode('utf-8', errors='ignore'))
AudioClip = self.Torchlight().AudioManager.AudioClip(player, "file://" + TempFile.name)
if not AudioClip:
os.unlink(TempFile.name)
return 1
if AudioClip.Play(None, "-af", "volume=10dB"):
AudioClip.AudioPlayer.AddCallback("Stop", lambda: os.unlink(TempFile.name))
return 0
else:
os.unlink(TempFile.name)
return 1
async def _func(self, message, player):
self.Logger.debug(sys._getframe().f_code.co_name + ' ' + str(message))
Level = 0
if player.Access:
Level = player.Access["level"]
Disabled = self.Torchlight().Disabled
if Disabled and (Disabled > Level or Disabled == Level and Level < self.Torchlight().Config["AntiSpam"]["ImmunityLevel"]):
self.Torchlight().SayPrivate(player, "Torchlight is currently disabled!")
return 1
if not message[1]:
return 1
asyncio.ensure_future(self.Say(player, message[1]))
return 0
class Stop(BaseCommand):
def __init__(self, torchlight):
super().__init__(torchlight)

View File

@ -57,12 +57,14 @@ class FFmpegAudioPlayer():
self.Master.Logger.debug("~FFmpegAudioPlayer()")
self.Stop()
def PlayURI(self, uri, position = None):
def PlayURI(self, uri, position, *args):
if position:
PosStr = str(datetime.timedelta(seconds = position))
Command = ["/usr/bin/ffmpeg", "-ss", PosStr, "-i", uri, "-acodec", "pcm_s16le", "-ac", "1", "-ar", str(int(self.SampleRate)), "-f", "s16le", "-"]
Command = ["/usr/bin/ffmpeg", "-ss", PosStr, "-i", uri, "-acodec", "pcm_s16le", "-ac", "1", "-ar", str(int(self.SampleRate)), "-f", "s16le", *args, "-"]
else:
Command = ["/usr/bin/ffmpeg", "-i", uri, "-acodec", "pcm_s16le", "-ac", "1", "-ar", str(int(self.SampleRate)), "-f", "s16le", "-"]
Command = ["/usr/bin/ffmpeg", "-i", uri, "-acodec", "pcm_s16le", "-ac", "1", "-ar", str(int(self.SampleRate)), "-f", "s16le", *args, "-"]
print(Command)
self.Playing = True
asyncio.ensure_future(self._stream_subprocess(Command))

View File

@ -1,9 +1,11 @@
#!/usr/bin/python3
# -*- coding: utf-8 -*-
import asyncio
import logging
class GameEvents():
def __init__(self, master):
self.Logger = logging.getLogger(__class__.__name__)
self.Torchlight = master
self.Callbacks = {}

BIN
dectalk/MSVCRTd.DLL Normal file

Binary file not shown.

BIN
dectalk/dectalk.dll Normal file

Binary file not shown.

BIN
dectalk/dtalk_us.dic Normal file

Binary file not shown.

BIN
dectalk/say.exe Normal file

Binary file not shown.

BIN
dectalk/speak.exe Normal file

Binary file not shown.

View File

@ -1,3 +1,173 @@
[
{"names": ["!tuturu"], "sound": "Tutturuu_v1.wav"}
{"names": ["!tuturu"], "sound": "Tutturuu_v1.wav"},
{"names": ["!baka"], "sound": ["baka.wav", "Baka.mp3"]},
{"names": ["!buhi"], "sound": "buhi.wav"},
{"names": ["!nyan"], "sound": "nyanpass.wav"},
{"names": ["!trial"], "sound": "trial.wav"},
{"names": ["!mail"], "sound": "yuu_new_mail.wav"},
{"names": ["!balrog"], "sound": "balrog_scream.wav"},
{"names": ["!bluescreen", "!error"], "sound": "error.wav"},
{"names": ["!hallelujah"], "sound": "hallelujah.wav"},
{"names": ["!scream"], "sound": "ascream7.wav"},
{"names": ["!trap"], "sound": "itsatrap.wav"},
{"names": ["!whores"], "sound": "whores.wav"},
{"names": ["!gandalf"], "sound": "vozyoucannotpass.wav"},
{"names": ["!cat"], "sound": "gato.wav"},
{"names": ["!turtle", "!turtles"], "sound": "iliketurtles.wav"},
{"names": ["!laser"], "sound": "blade_out.wav"},
{"names": ["!king", "!kingoftheworld"], "sound": "vulcan.wav"},
{"names": ["!seeyou", "!seeyouagain"], "sound": "seph_iseeyou.wav"},
{"names": ["!chosen"], "sound": "seph_onlythechosen.wav"},
{"names": ["!goodbye", "!saygoodbye"], "sound": "seph_saygoodbye.wav"},
{"names": ["!slow"], "sound": "seph_slow.wav"},
{"names": ["!late", "!toolate"], "sound": "seph_toolate.wav"},
{"names": ["!growl"], "sound": "bahamut_growl2.wav"},
{"names": ["!buyspins", "!buy_spins"], "sound": "BUYSPINS1.wav"},
{"names": ["!death", "!deathscream"], "sound": "d_death_scream.wav"},
{"names": ["!attack", "!meetyourend"], "sound": "z_godend.wav"},
{"names": ["!die", "!guardian"], "sound": "z_guardianend.wav"},
{"names": ["!applause"], "sound": "applause.wav"},
{"names": ["!retreat"], "sound": "stage_x_gandalf_retreat-1-0.wav"},
{"names": ["!idiot"], "sound": "idiot.wav"},
{"names": ["!duck", "!quack"], "sound": "quack.wav"},
{"names": ["!triple"], "sound": "triple.wav"},
{"names": ["!solo"], "sound": "solo.wav"},
{"names": ["!oniichan", "!onii-chan"], "sound": "Onii-chan.wav"},
{"names": ["!gameover"], "sound": ["Gameover.wav", "gameoveryeah.mp3"]},
{"names": ["_wombo"], "sound": "WomboCombo.wav"},
{"names": ["!camera"], "sound": "MOM GET THE CAMERA.wav"},
{"names": ["_no"], "sound": "NOOOOOOOOOOO.wav"},
{"names": ["!hihi"], "sound": "skullz.wav"},
{"names": ["!yatta"], "sound": "Hiro Yatta.wav"},
{"names": ["!over"], "sound": "over.wav"},
{"names": ["_cena"], "sound": "cena.wav"},
{"names": ["!victory"], "sound": "ffvii_victory.wav"},
{"names": ["!2012"], "sound": ["2012_1.wav", "2012_2.wav", "2012_3.wav", "2012_4.wav"]},
{"names": ["!nein"], "sound": "hitler_nein.wav"},
{"names": ["!allahu", "!akbar"], "sound": "allahu_akbar.wav"},
{"names": ["!chopper"], "sound": "gettothechopper.wav"},
{"names": ["!payback"], "sound": "blain - payback time.wav"},
{"names": ["!scotland"], "sound": "scotland.wav"},
{"names": ["!happening"], "sound": "happening.wav"},
{"names": ["!topkek"], "sound": "topkek.wav"},
{"names": ["!welcome", "!ricefields"], "sound": "welcome_to_the_ricefields.wav"},
{"names": ["!inception"], "sound": "inception.wav"},
{"names": ["!x"], "sound": "xfiles.wav"},
{"names": ["!stfu"], "sound": ["stfu.wav", "stfu2.mp3", "stfu3.mp3"]},
{"names": ["!goat"], "sound": ["goat1.wav", "goat2.wav", "goat3.wav", "goat4.wav", "goat5.wav", "goat6.wav"]},
{"names": ["_pika"], "sound": "pika.wav"},
{"names": ["!doit"], "sound": "doit.wav"},
{"names": ["!benis"], "sound": "grossenbenis.wav"},
{"names": ["!omg"], "sound": "omg.wav"},
{"names": ["!wow"], "sound": ["wow.wav", "rexy_wow.wav"]},
{"names": ["!prepare", "!battle"], "sound": "stage_2_preparaos-0-0.wav"},
{"names": ["!meme"], "sound": "nicememe.wav"},
{"names": ["!nyaa"], "sound": ["nyaa_1.wav", "nyaa_2.wav", "nyaa_3.wav", "nyaa_4.wav", "nyaa_5.wav", "nyaa_6.wav"]},
{"names": ["!ah"], "sound": ["FFVII_Cry.wav", "aaa.mp3"]},
{"names": ["!feelsbad"], "sound": "feelsbadman.wav"},
{"names": ["!admun"], "sound": "admun_please.wav"},
{"names": ["!population"], "sound": "population.wav"},
{"names": ["!why", "!immigration"], "sound": "immigration.wav"},
{"names": ["_fag", "_fags"], "sound": "normalfags.wav"},
{"names": ["!tutury"], "sound": "tutury.wav"},
{"names": ["!lew"], "sound": "Bewlewlewlew.wav"},
{"names": ["!pudi"], "sound": "Pudi Pudi (Short).wav"},
{"names": ["!hey", "!listen"], "sound": "Hey Listen.wav"},
{"names": ["!comeon"], "sound": "Come on.mp3"},
{"names": ["!stopp"], "sound": "itstimetostop.mp3"},
{"names": ["!cancer"], "sound": "cancer.mp3"},
{"names": ["!heil"], "sound": "heil.mp3"},
{"names": ["!nico"], "sound": "niconiconi.mp3"},
{"names": ["!cock"], "sound": ["cock1.mp3", "cock2.mp3", "cock3.mp3", "cock4.mp3", "cock5.mp3", "cock6.mp3"]},
{"names": ["!rock"], "sound": "LetsRock.mp3"},
{"names": ["!fmlaugh"], "sound": "fmlaugh.mp3"},
{"names": ["!monopoly"], "sound": "monopoly.mp3"},
{"names": ["!kiddin", "!kidding"], "sound": "rexy r u kiddin me.mp3"},
{"names": ["!noice"], "sound": "Noice.mp3"},
{"names": ["!rexy"], "sound": "rexywaah.mp3"},
{"names": ["!kaboom"], "sound": "kaboom.mp3"},
{"names": ["!honk"], "sound": "honk.wav"},
{"names": ["_how", "_happen"], "sound": "how_could_this_happen_to_me.mp3"},
{"names": ["!spam"], "sound": "No_Spammerino_In_The_Chatterino.mp3"},
{"names": ["!ohoho"], "sound": ["ohoho_1.mp3", "ohoho_3.mp3", "ohoho_4.mp3", "ohoho_5.mp3", "ohoho_6.mp3", "ohoho_7.mp3", "ohoho_8.mp3", "ohoho_9.mp3", "ohoho_10.mp3", "ohoho_11.mp3", "ohoho_12.mp3", "ohoho_13.mp3", "ohoho_14.mp3", "ohoho_15.mp3", "ohoho_16.mp3", "ohoho_17.mp3", "ohoho_18.mp3", "ohoho_19.mp3", "ohoho_20.mp3", "ohoho_21.mp3", "ohoho_22.mp3", "ohoho_23.mp3", "ohoho_24.mp3", "ohoho_25.mp3", "ohoho_26.mp3", "ohoho_27.mp3", "ohoho_28.mp3", "ohoho_29.mp3", "ohoho_30.mp3", "ohoho_31.mp3", "ohoho_32.mp3", "ohoho_33.mp3", "ohoho_34.mp3", "ohoho_35.mp3", "ohoho_36.mp3", "ohoho_37.mp3", "ohoho_38.mp3", "ohoho_39.mp3", "ohoho_40.mp3", "ohoho_41.mp3", "ohoho_42.mp3", "ohoho_43.mp3", "ohoho_44.mp3", "ohoho_45.mp3", "ohoho_46.mp3", "ohoho_47.mp3", "ohoho_48.mp3", "ohoho_49.mp3", "ohoho_50.mp3", "ohoho_51.mp3", "ohoho_52.mp3", "ohoho_53.mp3", "ohoho_54.mp3", "ohoho_55.mp3", "ohoho_56.mp3", "ohoho_57.mp3", "ohoho_58.mp3", "ohoho_59.mp3", "ohoho_60.mp3", "ohoho_61.mp3", "ohoho_62.mp3", "ohoho_63.mp3", "ohoho_64.mp3", "ohoho_65.mp3", "ohoho_66.mp3", "ohoho_67.mp3", "ohoho_68.mp3", "ohoho_69.mp3", "ohoho_70.mp3", "ohoho_71.mp3", "ohoho_72.mp3", "ohoho_73.mp3", "ohoho_74.mp3", "ohoho_75.mp3", "ohoho_76.mp3", "ohoho_77.mp3", "ohoho_78.mp3", "ohoho_79.mp3", "ohoho_80.mp3", "ohoho_81.mp3", "ohoho_82.mp3", "ohoho_83.mp3", "ohoho_84.mp3", "ohoho_85.mp3", "ohoho_86.mp3", "ohoho_87.mp3", "ohoho_88.mp3", "ohoho_89.mp3"]},
{"names": ["!nigga"], "sound": "GTA V - Niggaaaa.mp3"},
{"names": ["!sugoi"], "sound": "sugoi_sugoi.mp3"},
{"names": ["!cry"], "sound": ["cry1.wav", "cry2.wav", "cry3.wav", "cry4.wav", "cry5.wav", "cry6.wav", "cry7.wav"]},
{"names": ["!hehe", "!giggle"], "sound": "Giggle.mp3"},
{"names": ["_tuturemix"], "sound": "tuturemix.mp3"},
{"names": ["!monkey"], "sound": ["chimp1.wav", "chimp2.wav"]},
{"names": ["!ka", "!kaka"], "sound": ["Nisemonogatari-Shinobu-Kaka.ogg", "Nisemonogatari-Shinobu-K-ka.ogg"]},
{"names": ["!jodel"], "sound": "jodel.mp3"},
{"names": ["!nigger"], "sound": ["nigger.mp3", "nigger2.mp3"]},
{"names": ["!nyaaa"], "sound": "nyaaa.mp3"},
{"names": ["!run"], "sound": "run.wav"},
{"names": ["!goodbye"], "sound": "goodbye.wav"},
{"names": ["!noo"], "sound": "LOTR_Noooooo.wav"},
{"names": ["!dayum"], "sound": "daaamn.mp3"},
{"names": ["!goddammit", "!goddamnit"], "sound": "goddammit.mp3"},
{"names": ["!surprise"], "sound": "surprisemotherfucker1.mp3"},
{"names": ["!csi"], "sound": "yeeaah.mp3"},
{"names": ["!nope"], "sound": "engineer_no01.mp3"},
{"names": ["!joke"], "sound": "rimshot.mp3"},
{"names": ["!weed"], "sound": "smokeweederryday.mp3"},
{"names": ["!toasty"], "sound": "toasty.mp3"},
{"names": ["!damn"], "sound": "wheredyoufindthis.mp3"},
{"names": ["!nuts"], "sound": "suckmynuts.mp3"},
{"names": ["!wake"], "sound": "wakemeup.mp3"},
{"names": ["!bye"], "sound": "bye.mp3"},
{"names": ["!ilikeit"], "sound": "ilikeit.mp3"},
{"names": ["!milk"], "sound": "milk.mp3"},
{"names": ["!pussy"], "sound": "pussy.mp3"},
{"names": ["!retard"], "sound": ["retard.mp3", "retard2.mp3"]},
{"names": ["!sorry"], "sound": "sry.mp3"},
{"names": ["!wtf"], "sound": "wtf.mp3"},
{"names": ["!brb"], "sound": "brb.mp3"},
{"names": ["!cricket"], "sound": "cricket.mp3"},
{"names": ["!hax"], "sound": "hax.mp3"},
{"names": ["!hi"], "sound": "hi.mp3"},
{"names": ["!moo"], "sound": "moo.mp3"},
{"names": ["!rape"], "sound": "rape.mp3"},
{"names": ["!tada"], "sound": "tada.mp3"},
{"names": ["!yay"], "sound": "yay.mp3"},
{"names": ["!yes"], "sound": "yes.mp3"},
{"names": ["!cyka"], "sound": "cyka.mp3"},
{"names": ["!racist"], "sound": "racist.mp3"},
{"names": ["!roger"], "sound": "roger.mp3"},
{"names": ["!tooslow"], "sound": "tooslow.mp3"},
{"names": ["!steam"], "sound": "steam.wav"},
{"names": ["!good"], "sound": "that_s_pretty_good.mp3"},
{"names": ["_crawling"], "sound": "crawling.mp3"},
{"names": ["_nigga", "_nigger"], "sound": "100percent_fixed.mp3"},
{"names": ["!nukyun"], "sound": ["nukyun1.mp3", "nukyun2.mp3", "nukyun3.mp3", "nukyun4.mp3", "nukyun5.mp3", "nukyun6.mp3", "nukyun7.mp3", "nukyun8.mp3", "nukyun9.mp3", "nukyun10.mp3", "nukyun11.mp3", "nukyun12.mp3", "nukyun13.mp3", "nukyun14.mp3", "nukyun15.mp3", "nukyun16.mp3", "nukyun17.mp3", "nukyun18.mp3", "nukyun19.mp3", "nukyun20.mp3", "nukyun21.mp3", "nukyun22.mp3", "nukyun23.mp3", "nukyun24.mp3", "nukyun25.mp3", "nukyun26.mp3", "nukyun27.mp3"]},
{"names": ["!harambe"], "sound": "harambe.mp3"},
{"names": ["!horn"], "sound": "vu_horn_quick.wav"},
{"names": ["!hood"], "sound": "hood.mp3"},
{"names": ["!gtfo"], "sound": ["gtfo.mp3", "gtfo2.mp3"]},
{"names": ["!pomf"], "sound": "pomf.mp3"},
{"names": ["!gay"], "sound": "putingay.mp3"},
{"names": ["!pedo"], "sound": "pedobear.mp3"},
{"names": ["!kys"], "sound": "kys.mp3"},
{"names": ["!english"], "sound": "englishonly.mp3"},
{"names": ["!knowledge"], "sound": "Knowledge.m4a"},
{"names": ["!mana"], "sound": "mana.mp3"},
{"names": ["!dodge"], "sound": ["dodge1.mp3", "dodge2.mp3"]},
{"names": ["!love"], "sound": "sheep.mp3"},
{"names": ["!timotei"], "sound": "Timotei.wav"},
{"names": ["!daniel"], "sound": "daniel.mp3"},
{"names": ["!cne"], "sound": ["it_is_may.mp3", "cnelaugh.mp3"]},
{"names": ["_cne"], "sound": "Cne_goes_apocalypse_mode.mp3"},
{"names": ["!avocados"], "sound": "avocados.mp3"},
{"names": ["!succ"], "sound": "succ.mp3"},
{"names": ["!tutu", "!papa"], "sound": "papatutuwawa.mp3"},
{"names": ["!nani"], "sound": "nani.mp3"},
{"names": ["!squee"], "sound": "squee.mp3"},
{"names": ["!ptb"], "sound": "07ptb.wav"},
{"names": ["!wall"], "sound": "wall.mp3"},
{"names": ["!bomb"], "sound": "bomb.mp3"},
{"names": ["!wrong"], "sound": "wrong.mp3"},
{"names": ["!china"], "sound": ["china1.mp3", "china2.mp3", "china3.mp3", "china4.mp3", "china5.mp3", "china6.mp3", "china7.mp3"]},
{"names": ["!oof"], "sound": "oof.mp3"},
{"names": ["!pan"], "sound": "panpakapan.mp3"},
{"names": ["!shoulder"], "sound": "oh_my_shoulder.mp3"},
{"names": ["_awaken"], "sound": "awaken.mp3"}
]