-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Guy Spronck
committed
Jun 23, 2016
1 parent
2b5d26b
commit 4597e49
Showing
4 changed files
with
39 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import { ICommand } from './ICommand'; | ||
import * as Request from 'request'; | ||
|
||
export class Isup implements ICommand { | ||
command = /isup$/; | ||
help = "Checks if a website is up/down."; | ||
usage = "Usage: /isup [url]"; | ||
|
||
|
||
private IsUp(url: string, callback: (isup: boolean) => void): void { | ||
var SERVER_URL = 'http://isup.me/'; | ||
Request(SERVER_URL + url, function(error, response, body) { | ||
callback(body.indexOf('It\'s just you') !== -1); | ||
}); | ||
} | ||
|
||
// Displays hello world | ||
exec(msg, reply): void { | ||
var args: string = msg.args(); | ||
if (args.trim().length == 0) { | ||
reply.text(this.usage); | ||
return; | ||
} | ||
|
||
this.IsUp(args, (isup: boolean) => { | ||
if(isup){ | ||
reply.markdown(`*${args}* looks *up* from here.`); | ||
}else{ | ||
reply.markdown(`*${args}* looks *down* from here.`); | ||
} | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters