BastliBridge

git clone git://xatko.vsos.ethz.ch/BastliBridge.git
Log | Files | Refs | Submodules | README

commit d6d42833d7f9aea8135def2718f29c348e329308
parent 6d0281a5959d0461af2543f11fd90cf266f034c0
Author: Dominik Schmidt <das1993@hotmail.com>
Date:   Fri, 26 Jan 2018 13:22:30 +0000

Merge remote-tracking branch 'origin/master' into HEAD

Diffstat:
Msrc/bastlibridge/telegram.d | 4++--
Msrc/bot.d | 5++++-
Msrc/proxy.d | 15++++-----------
3 files changed, 10 insertions(+), 14 deletions(-)

diff --git a/src/bastlibridge/telegram.d b/src/bastlibridge/telegram.d @@ -305,7 +305,7 @@ struct Telegram{ return _botName; } - string getFile(in char[] file_id){ + JSONValue getFile(in char[] file_id){ JSONValue j; j.object=null; j["file_id"]=file_id; @@ -317,7 +317,7 @@ struct Telegram{ j=r.get; auto v="file_path" in j; if(v) - return v.str; + return j; else throw new TelegramException(cast(string)("Path of file "~file_id~" was not found")); } diff --git a/src/bot.d b/src/bot.d @@ -334,7 +334,7 @@ struct Bot{ try{ auto split=msg.findSplit(" "); auto cmdbot=split[0].findSplit("@"); - if(cmdbot[1].length==0 && cmdbot[2]!=telegram.botName){ + if(cmdbot[1].length!=0 && cmdbot[2]!=telegram.botName){ trace("Not one of our commands"); } else{ @@ -403,6 +403,9 @@ struct Bot{ info("Connecting to IRC on ", ircAddress.toString); tryNTimes!(()=>ircClient.connect(ircAddress), (e)=>warning(e))(max_retries); + if(controlPath.exists()){ + remove(controlPath); + } controlSocket.bind(controlAddress); controlSocket.listen(10); } diff --git a/src/proxy.d b/src/proxy.d @@ -81,20 +81,12 @@ void handleClient(Socket newsock){ not_found(); } else{ - string path; + JSONValue file; try{ - path=telegram.getFile(req.url[2..$]); - if(path.length==0){ - not_found(); - return; - } + file=telegram.getFile(req.url[2..$]); } catch(TelegramException e){ - res.response(404, "Not Found"); - res.header("Connection", "close"); - res.header("Content-Type", "text/plain"); - res.data(fof); - res.perform(newsock); + not_found(); return; } catch(Exception e){ @@ -105,6 +97,7 @@ void handleClient(Socket newsock){ res.perform(newsock); return; } + string path=file["file_path"].str; static HttpRequest!void r2; r2.request("GET", chain("file/bot", telegram.token, "/", path)); r2.header("Host", telegram.ApiAddr);