-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add: Search files
- Loading branch information
Janez Troha
committed
Jan 13, 2014
1 parent
cae0ff6
commit ba15ec7
Showing
5 changed files
with
62 additions
and
27 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,39 @@ | ||
module.exports = (bot) -> | ||
|
||
bot.regexp /^.apt (.+)/, | ||
".apt <paket> -- Najde pakete po imenu na packages.ubuntu.com", | ||
(match, r) -> | ||
|
||
apt = (paket, cb)=> | ||
url = "http://packages.ubuntu.com/search?suite=all&searchon=names&keywords=#{encodeURI(paket)}" | ||
bot.fetchHTML url , ($)-> | ||
if $? | ||
paketi = [] | ||
for paket in $("#psearchres h3") | ||
arches = [] | ||
for arch in $(paket).next().find("li .resultlink") | ||
arches.push $(arch).text().trim() | ||
paketi.push "#{$(paket).text().replace("Package ","")} {#{arches.join(", ")}}" | ||
cb paketi.join "\n" | ||
else | ||
cb "Ne najdem" | ||
|
||
apt match[1].trim(), (answer)-> | ||
r.reply answer | ||
|
||
bot.regexp /^.aptf (.+)/, | ||
".aptf <ime_datoteke> -- Najde pakete po vsebini na packages.ubuntu.com", | ||
(match, r) -> | ||
aptf = (paket, cb)=> | ||
url = "http://packages.ubuntu.com/search?searchon=contents&keywords=#{encodeURI(paket)}&mode=exactfilename&suite=saucy&arch=any" | ||
bot.fetchHTML url , ($)-> | ||
if $? | ||
paketi = [] | ||
for paket in $("td.file") | ||
paketi.push [$(paket).text().trim(), $(paket).next().text().trim()].join(" > ") | ||
cb paketi.join "\n" | ||
else | ||
cb "Ne najdem" | ||
|
||
aptf match[1].trim(), (answer)-> | ||
r.reply answer |
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,21 @@ | ||
chai = require 'chai' | ||
should = chai.should() | ||
expect = chai.expect | ||
|
||
fat = require '../lib/fat_tests' | ||
|
||
describe 'apt.coffee', -> | ||
this.timeout 16000 | ||
bot = require("../scripts/apt")(new fat.BotTest()) | ||
|
||
it 'test .apt libssl-dev', (done)-> | ||
bot.test ".apt libssl-dev", (msg)-> | ||
expect(msg).to.be.a('string') | ||
msg.should.equal 'libssl-dev {lucid, lucid-updates, precise, precise-updates, quantal, quantal-updates, raring, raring-updates, saucy, saucy-updates, trusty}' | ||
done() | ||
|
||
it 'test .aptf evp.h', (done)-> | ||
bot.test ".aptf evp.h", (msg)-> | ||
expect(msg).to.be.a('string') | ||
msg.should.equal '/usr/include/hcrypto/evp.h > heimdal-dev\n/usr/include/heimdal/hcrypto/evp.h > heimdal-multidev\n/usr/include/openssl/evp.h > libssl-dev\n/usr/include/xmlsec1/xmlsec/openssl/evp.h > libxmlsec1-dev' | ||
done() |
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