From 30ce2df512521bf46427c8cc1da62688c9f2eebf Mon Sep 17 00:00:00 2001 From: devel Date: Fri, 16 Mar 2018 19:50:02 +0100 Subject: [PATCH 1/2] Added user cookie plugins --- cookie-user/cookie-user.js | 61 ++++++++++++++++++++++++++++++++++++++ cookie-user/readme.md | 6 ++++ 2 files changed, 67 insertions(+) create mode 100644 cookie-user/cookie-user.js create mode 100644 cookie-user/readme.md diff --git a/cookie-user/cookie-user.js b/cookie-user/cookie-user.js new file mode 100644 index 0000000..af4246d --- /dev/null +++ b/cookie-user/cookie-user.js @@ -0,0 +1,61 @@ +function randString(n) { + if(!n) + { + n = 5; + } + + var text = ''; + var possible = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789'; + + for(var i=0; i < n; i++) + { + text += possible.charAt(Math.floor(Math.random() * possible.length)); + } + + return text; +} + +// Cookies +function createCookie(name, value, days) { + if (days) { + var date = new Date(); + date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000)); + var expires = "; expires=" + date.toGMTString(); + } + else var expires = ""; + + document.cookie = name + "=" + value + expires + "; path=/"; +} + +function readCookie(name) { + var nameEQ = name + "="; + var ca = document.cookie.split(';'); + for (var i = 0; i < ca.length; i++) { + var c = ca[i]; + while (c.charAt(0) == ' ') c = c.substring(1, c.length); + if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length, c.length); + } + return null; +} + +function eraseCookie(name) { + createCookie(name, "", -1); +} + + var cookie = readCookie('cookie_name'); + console.log(cookie); + if (cookie == null) { + var value = randString(9); + createCookie('cookie_name', value, 30); + } + + +kiwi.plugin('ident', function(kiwi) { + + kiwi.state.$on('network.new', function(event) { + event.network.username = cookie; + + }); + +}); + diff --git a/cookie-user/readme.md b/cookie-user/readme.md new file mode 100644 index 0000000..ba564ef --- /dev/null +++ b/cookie-user/readme.md @@ -0,0 +1,6 @@ +* Simos +* admin@simosnap.org +* https://github.com/SimosNap + +### Description +Set a random value saved in a cookie as kiwiirc username. From 4f8862e50837cc034f3f0ca92b5cbe0ce2eeafe4 Mon Sep 17 00:00:00 2001 From: H7-25 Date: Mon, 4 Jun 2018 00:13:51 +0200 Subject: [PATCH 2/2] Nickserv Plugin --- nickserv/nickserv.css | 18 +++++++ nickserv/nickserv.js | 114 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 132 insertions(+) create mode 100644 nickserv/nickserv.css create mode 100644 nickserv/nickserv.js diff --git a/nickserv/nickserv.css b/nickserv/nickserv.css new file mode 100644 index 0000000..1c1709d --- /dev/null +++ b/nickserv/nickserv.css @@ -0,0 +1,18 @@ +.kiwi-ns-error:before { + font-family:FontAwesome; + content: "\f071" ; + margin-right:5px; +} +.kiwi-ns-input { + border-top:1px solid rgba(0, 0, 0, 0.2) !important; + padding:10px !important; +} +.kiwi-ns-button { + font-size:1.2em;border-radius:0px; +} + +.kiwi-ns-button:before { + font-family:FontAwesome; + content: "\f023" ; + margin-right:5px; +} \ No newline at end of file diff --git a/nickserv/nickserv.js b/nickserv/nickserv.js new file mode 100644 index 0000000..e3fae69 --- /dev/null +++ b/nickserv/nickserv.js @@ -0,0 +1,114 @@ +// Plugin Config ######################################################################### + +// NickServ Identify Regex +var IDString = "^Questo nick è registrato e protetto. Se questo è il tuo"; +// NickServ Identify text +var IDText = "Il nick scelto risulta registrato, inserisci la password per autenticarti."; +// IDentify Button text +var IDButton = "IDENTIFICATI"; +// Wrong password Regex +var WPString = "^Password errata"; +// Wrong password text +var WPText = "Password errata!"; +// Services enforce nick Regex +var ENString = "^Il tuo nick sarà cambiato in"; +// Login success Regex +var LSString = "^Password accettata - adesso sei riconosciuto"; +// Account confirmation request Regex +var ConfirmReqString = "^Il tuo indirizzo email non è stato confermato. Per confermarlo, segui le istruzioni contenute nella email che hai ricevuto quando ti sei registrato"; +// Account confirmation text +var ConfirmReqText = "Inserisci il codice di conferma ricevuto per email per completare la registrazione dell\' account."; +// Invalid Confirmation code Regex +var InvalidConfirmString = "^Codice di attivazione non valido"; +// Invalid Confirmation code text +var InvalidConfirmText = "Codice di attivazione non valido. Inserisci il codice di conferma ricevuto per email per completare la registrazione dell\' account."; +// A valid confirmation code has been entered +var ValidConfirmString = "^Il tuo indirizzo email per (.*) è stato confermato." + +// Confirm Button text +var ConfirmButton = "CONFERMA REGISTRAZIONE"; +// End Plugin Config #################################################################### + +var IDRe = new RegExp(IDString ,""); +var WPRe = new RegExp(WPString ,""); +var ENRe = new RegExp(ENString ,""); +var LSRe = new RegExp(LSString ,""); +var ConfirmReqRe = new RegExp(ConfirmReqString ,""); +var InvalidConfirmRe = new RegExp(InvalidConfirmString ,""); +var ValidConfirmRe = new RegExp(ValidConfirmString ,""); + +var link = document.createElement("link"); +link.type = "text/css"; +link.rel = "stylesheet"; +link.href = "/plugins/nickserv.css"; +document.head.appendChild(link); + +var nsdialog = kiwi.Vue.extend({ + + data: function data() { + return { + pwdInput: '' + } + }, + + methods: { + onIdentify: function () { + kiwi.state.$emit('input.raw', '/NS identify '+ this.pwdInput ) + } + }, + + template: '

' + IDText + '

', +}); + +var confirmdialog = kiwi.Vue.extend({ + + data: function data() { + return { + codeInput: '' + } + }, + + methods: { + onIdentify: function () { + kiwi.state.$emit('input.raw', '/NS confirm '+ this.codeInput ) + } + }, + + template: '

' + ConfirmReqText + '

', +}); + +kiwi.plugin('nickserv', function(kiwi) { + + kiwi.on('irc.notice', function(event) { + console.log(event); + if ((event.nick == 'NickServ') && (event.message.match(IDRe))) { + kiwi.state.$emit('mediaviewer.show', {component: nsdialog }) + } + if ((event.nick == 'NickServ') && (event.message.match(WPRe))) { + var el = document.getElementById("validate") + el.innerHTML = WPText ; + } + if ((event.nick == 'NickServ') && (event.message.match(ConfirmReqRe))) { + kiwi.state.$emit('mediaviewer.show', {component: confirmdialog }) + } + + if ((event.nick == 'NickServ') && (event.message.match(InvalidConfirmRe))) { + var el = document.getElementById("validate") + el.innerHTML = InvalidConfirmText ; + } + + if ((event.nick == 'NickServ') && (event.message.match(ENRe))) { + kiwi.state.$emit('mediaviewer.hide') + } + + if ((event.nick == 'NickServ') && (event.message.match(LSRe))) { + kiwi.state.$emit('mediaviewer.hide') + } + + if ((event.nick == 'NickServ') && (event.message.match(ValidConfirmRe))) { + kiwi.state.$emit('mediaviewer.hide') + } + + }); + +});