-
Notifications
You must be signed in to change notification settings - Fork 2
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
Showing
3 changed files
with
98 additions
and
0 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
'strict'; | ||
document.addEventListener('DOMContentLoaded', function() { | ||
SaihuBot.prototype.responses.push( | ||
{ name: 'google', rule: /(^search |^google |^g* )(.*)/i, action: function(robot, msg) { | ||
let url = 'https://www.google.com/search?q=' + encodeURIComponent(msg[2]); | ||
let link = document.createElement('a'); | ||
link.href = url; | ||
let linkText = document.createTextNode('Search ' + msg[2] + ' via google'); | ||
link.appendChild(linkText); | ||
robot.sendHTML(link); | ||
window.open(url, '_blank'); | ||
}}); | ||
|
||
SaihuBot.prototype.responses.push( | ||
{ name: 'wikipedia', rule: /(^w |^wiki |^wikipedia )(.*)/i, action: function(robot, msg) { | ||
let url = 'http://en.wikipedia.org/w/index.php?title=Special:Search&search=' + encodeURIComponent(msg[2]); | ||
let link = document.createElement('a'); | ||
link.href = url; | ||
let linkText = document.createTextNode('Search ' + msg[2] + ' via wikipedia'); | ||
link.appendChild(linkText); | ||
robot.sendHTML(link); | ||
window.open(url, '_blank'); | ||
}}); | ||
|
||
SaihuBot.prototype.responses.push( | ||
{ name: 'translate', rule: /(^translate |^tr )(.*)/i, action: function(robot, msg) { | ||
let url = 'http://translate.google.com/?q=' + encodeURIComponent(msg[2]); | ||
let link = document.createElement('a'); | ||
link.href = url; | ||
let linkText = document.createTextNode('Translate ' + msg[2] + ' via google translate'); | ||
link.appendChild(linkText); | ||
robot.sendHTML(link); | ||
window.open(url, '_blank'); | ||
}}); | ||
}); |
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,24 @@ | ||
<html> | ||
<head> | ||
<meta charset="utf-8"> | ||
<meta http-equiv="X-UA-Compatible" content="IE=edge"> | ||
<meta name="description" content="client side chatbot that can be embedded in any web site."> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0"> | ||
<title>Saihubot Search</title> | ||
</head> | ||
<body> | ||
<div id="history"></div> | ||
<input id="message"><button id="send">Send</button> | ||
|
||
<p> | ||
>> type `ping`, `time`, or `echo [message]` to see what's happened<br> | ||
>> type `search [keyword]`, `g [keyword]`, `wiki [keyword]` to search<br> | ||
>> <a href="https://github.com/gasolin/saihubot/">Download Saihubot</a> | ||
</p> | ||
|
||
<script defer src="saihubot.js"></script> | ||
<script defer src="saihubot-diagnostics.js"></script> | ||
<script defer src="saihubot-search.js"></script> | ||
<script defer src="ga.js"></script> | ||
</body> | ||
</html> |