Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also .

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also .
Choose a base branch
Nothing to show
...
Choose a head branch
Nothing to show
  • 9 commits
  • 4 files changed
  • 0 commit comments
  • 2 contributors
Showing with 49 additions and 1 deletion.
  1. +1 −1 .travis/deploy.sh
  2. +1 −0 Readme.md
  3. +23 −0 scripts/servisi.coffee
  4. +24 −0 test/servisi.coffee
View
@@ -7,4 +7,4 @@ chmod 600 .travis/deploy_key.pem # this key should have push access
ssh-add .travis/deploy_key.pem
rm -rf .travis/deploy_key.pem
git remote add dokku dokku@$APP_HOSTNAME:$APP
-git push --force dokku HEAD:master
+git push --force dokku HEAD:master
View
@@ -52,5 +52,6 @@ Pomoč:
.videl <nick> -- Kdaj je bil uporabnik zadnjič na kanalu, sporočilo
.vreme <kraj> dobi podatke o vremenu za <kraj>
.vrzi -- Glava ali cifra
+ .xkcd <parameter> -- Izpiše naslov xkcd stripa in doda povezavo. <parameter>: random - izbere naključni comic, help - izpiše pomoč
.yt <iskalni niz> -- Išči na youtube
```
View
@@ -179,3 +179,26 @@ module.exports = (bot) ->
r.reply "Vrednost BTC v #{currency.toUpperCase()}: last: #{data.last}, low: #{data.low}, high: #{data.high}, bid: #{data.bid}, ask: #{data.ask}"
else
r.reply "Bitstamp is down"
+
+ bot.regexp /^\.xkcd\s?(.+)?/,
+ (match, r) ->
+ if match[1] == "help"
+ r.reply "Za prikaz zadnjega vnosa na xkcd.com vnesi ukaz '.xkcd', za prikaz naključnega vnosa vnesi '.xkcd random'"
+ else if match[1] == "random"
+ bot.fetchJSON "https://xkcd.com/info.0.json", (data) ->
+ if data && ! null
+ max = data.num
+ random = Math.floor(Math.random() * (max - 1) + 1)
+ bot.fetchJSON "https://xkcd.com/#{random}/info.0.json", (data2) ->
+ if data2 && ! null
+ r.reply "#{data2.safe_title}: #{data2.img}"
+ else
+ r.reply "Ne najdem"
+ else if match[1] == undefined
+ bot.fetchJSON "https://xkcd.com/info.0.json", (data) ->
+ if data && ! null
+ r.reply "#{data.safe_title}: #{data.img}"
+ else
+ r.reply "Ne najdem"
+ else
+ r.reply "Ne najdem"
View
@@ -102,3 +102,27 @@ describe 'servisi.coffee', ->
bot.test ".btc usd", (msg) ->
expect(msg).to.be.a('string')
done()
+
+ it 'test .xkcd', (done)->
+ bot.test ".xkcd", (msg) ->
+ expect(msg).to.be.a('string')
+ expect(msg).to.not.equal "Ne najdem"
+ done()
+
+ it 'test .xkcd help', (done)->
+ bot.test ".xkcd help", (msg) ->
+ expect(msg).to.be.a('string')
+ expect(msg).to.equal "Za prikaz zadnjega vnosa na xkcd.com vnesi ukaz '.xkcd', za prikaz naključnega vnosa vnesi '.xkcd random'"
+ done()
+
+ it 'test .xkcd random', (done)->
+ bot.test ".xkcd random", (msg) ->
+ expect(msg).to.be.a('string')
+ expect(msg).to.not.equal "Ne najdem"
+ done()
+
+ it 'test xkcd znj', (done)->
+ bot.test ".xkcd znj", (msg) ->
+ expect(msg).to.be.a('string')
+ expect(msg).to.equal "Ne najdem"
+ done()

No commit comments for this range