Skip to content

Commit

Permalink
Fix for the clonescan (#5)
Browse files Browse the repository at this point in the history
* Update installer.kvs

Small typo.

* Update installer.kvs

Fix for the error that occurs if the createUninstallAlias ​​function is called, when the variable %iNumFiles = 0, this generates an alias(aliasName){}  so an empty alias is not created, but an attempt is made to delete one that Does not exist yet.
Issue kvirc#11 opened on Jan 7, 2016 by un1versal
The rest of the addon is still broken

* Update install.kvs

This in not now playing addon

* Update install.kvs

Moved class(helltrixclone,object) out of the alias hell_clonescan

* Update install.kvs

# Patch 
The menu persisted after the uninstall

* Update install.kvs

more simple

* Update install.kvs

Uninstallation complete now

* Update install.kvs

simplified

* Update install.kvs

Bug in uninstall callback

* Update install.kvs

Fix global clon scan

* Update install.kvs

When a user who shares several channels with our KVIrc, enters the channels and is a clone, our current window is filled with the warnings of the clone detector.
And if a user who is a clone enters when we have a window open that is not a channel or console, the information is lost.
Each clone entry should appear on the channels it entered.
This patch solves it

* Update install.kvs

Error in help message

* Update install.kvs

Closing instances of clonescan object

* Update install.kvs

Patch for a bug which closes the current window if the clonescan not create any window

* Update install.kvs

Changed global variables by variable fields.
At this point, the script works without errors, but with a problem, every time a global scan is done, a new window is created, even for the same channel, it is not reused. If the user does not close them, when uninstalling the script, they remain open

* Fix clonescan

Now the script only opens one window per context, and remembers the windows it has opened, to close them if you uninstall the script

* big bug, mea culpa

if a  /hell_clonescan NickNotInChannel   is done a list of all of users of the channel is printed in the channel, because $mask.host("") returns *

* Warning patch

Patch to avoid a warning message, if the clonescan is called from a window that is not a channel

* Update install.kvs

#Fix for the clonescan.

In this state does not seem to have any type of malfunction.

* Update install.kvs

two messages fix

* Create po dir

* Added laguaje files

Added helltrix.pot and helltrix_es.po

* Create locale dir

* Added helltrix_es.mo

Added spanish translation

* add icon

Adding an icon and unloading translation file

* pics dir

* Add files via upload

Added image hell_clonescan.png

* not more installer

now the clonescan not more uses de installer helper class

* updated po{t}

* helltrix_es.mo update

* Delete installer.kvs

It is no longer necessary
  • Loading branch information
minduser00 authored Sep 4, 2017
1 parent 81ad0b4 commit f3514c1
Show file tree
Hide file tree
Showing 6 changed files with 262 additions and 189 deletions.
264 changes: 135 additions & 129 deletions clonescan/install.kvs
Original file line number Diff line number Diff line change
@@ -1,186 +1,192 @@
# Clone scanner script
# Written by HelLViS69 (2005)
# TODO:
# Languaje files
# Help files

addon.register("HellClonescan","1.0","HelL Clonescan",$tr("A simple script for scanning clones in channels"),"3.2.0")
addon.register("HellClonescan","1.2.8","HelL Clonescan",$tr("A simple script for scanning clones in channels",helltrix),"4.0.4",hell_clonescan.png)
{
# This is our uninstall callback: it will be called by KVIrc when addon.uninstall is invoked
# This is an automatically generated alias that will erase the installed files
alias(hell_clonescan){}
popup.delitem -d -q channeltextview 696969
event(OnJoin,clonescan){}
delpopupitem -d -q channeltextview 696969
alias(hell_clonescan){}

objects.killclass "helltrixclone"

trunload "helltrix"

foreach(%win,%HClone_win{}){
window.close -q %win;
}
%HClone_win{}=$nothing;

# Done
#echo -i=116 Bye
}

# Ok, addon.register succeeded. We can go on with the installation.

# Get the path that this script was launched from
%mypath = $file.extractPath($0)

# get the installer helper class (this is pretty standard and included in the distro)
parse %mypath/utils/installer.kvs

# The installer will copy our files and generate automatically
# an uninstallation alias for them
%installer = $new(installer,0,myinstaller)
# copy files in each subdirectory
# the pics
%installer->$copyFiles("%mypath/pics/","*.png",$file.localdir("pics"))
if($file.exists(%mypath"/pics/"))
addon.installfiles -q -s "HellClonescan" "pics" %mypath"/pics/*.png"

# the translations
%installer->$copyFiles("%mypath/locale/","*.mo",$file.localdir("locale"))
if($file.exists(%mypath"/locale/"))
addon.installfiles -q -s "HellClonescan" "locale" %mypath"/locale/*.mo"

# the documentation
%installer->$copyFiles("%mypath/help/en/nowplaying/","*.html",$file.localdir("help/en/nowplaying"))
# then generate the uninstall alias
%installer->$generateUninstallAlias("hell_clonescan_remove")
# finally kill the installer helper
delete %installer
if($file.exists(%mypath"/help/en/hellclonescan/"))
addon.installfiles -q -s "HellClonescan" "help/en/hellclonescan/" %mypath"/help/en/hellclonescan/*.html"

# Script Alias
alias(hell_clonescan)
{
class(helltrixclone,object){
constructor(){
# Channel mask array in the form nick!ident@host
# script Class
class(helltrixclone,object){
constructor(){
}

cloneCheck($0=nick,$1=host){
%checkNick=$0
%checkHost=$1

if(!%checkNick){
# Global scan
%i=0

foreach(%nick,$chan.users()){
%host=$str.append("*!*@",$mask.host($mask(%nick)))

# Nick array in the form *!*@host
%ArrayNick[%i]=%nick
%DbHost{%ArrayNick[%i]}=%host
%DbCloneNum{%ArrayNick[%i]}=0
# Channel mask array in the form nick!ident@host
foreach(%mask,$chan.users(,,m)){
$$->%DbNick[%i]=$mask.nick(%mask)
$$->%DbHost[%i]=$mask.host(%mask)
%i++;
}
}

cloneCheck($0=nick,$1=host){
%checkNick=$0
%checkHost=$1
%NumUsers=%i

# Global scan
if(!%checkNick){
for(%i=0; %i<%ArrayNick[]#; %i++){
for(%j=0; %j<%ArrayNick[]#; %j++){
if($str.cmp(%DbHost{%ArrayNick[%i]},%DbHost{%ArrayNick[%j]})==0){
%DbCloneNum{%ArrayNick[%i]}=$(%DbCloneNum{%ArrayNick[%i]}+1)
if(!%DbCloneNick{%ArrayNick[%i]})
%DbCloneNick{%ArrayNick[%i]}=%ArrayNick[%j]
else
%DbCloneNick{%ArrayNick[%i]}=$str.append(%DbCloneNick{%ArrayNick[%i]},", "%ArrayNick[%j])

# Delete clone
#%DbHost{%ArrayNick[%j]}=clone_%j
for(%i=0; %i< $(%NumUsers - 1); %i++){
if(!$$->%DbCloneNum[%i]){
for(%j=$(%i + 1); %j< %NumUsers; %j++){
if($str.cmp($$->%DbHost[%i],$$->%DbHost[%j])==0){
if(!$$->%DbCloneNum[%i]){
$$->%DbCloneNick{%i}=$$->%DbNick[%i]", "$$->%DbNick[%j]
$$->%DbCloneNum[%i] = 2
} else {
$$->%DbCloneNick{%i} .= ", "$$->%DbNick[%j]
$$->%DbCloneNum[%i]++
}
# We mark the clone
$$->%DbCloneNum[%j] = -1
}
}
}
} else {
%DbCloneNum{%checkNick}=0
# Nick scan
}
} else {
# Nick scan
if (!%checkHost){
%checkHost=$hostname(%checkNick)
if(!%checkHost){
# Just for sanity check
echo -w=$active [BUG]: $tr("The system could not retrieve the host of",helltrix) %checkNick
echo -w=$active $tr("[BUG]: The system could not retrieve the host of",helltrix) %checkNick
return
} else {
for(%i=0; %i<%ArrayNick[]#; %i++){
if($str.cmp(%DbHost{%ArrayNick[%i]},%checkHost)==0){
%DbCloneNum{%checkNick}=$(%DbCloneNum{%checkNick}+1)
if(!%DbCloneNick{%checkNick})
%DbCloneNick{%checkNick}=%ArrayNick[%i]
else
%DbCloneNick{%checkNick}=$str.append(%DbCloneNick{%checkNick},", "%ArrayNick[%i])

# Delete clone
#%DbHost{%ArrayNick[%j]}=
#%ArrayNick[%j]=
}
}
}
}
$$->%DbCloneNick{%checkNick} = $chan.users(,"*!*@"%checkHost,)
if ($str.contains($$->%DbCloneNick{%checkNick}, ",")){
$$->%DbCloneNick{%checkNick} = $str.replace($$->%DbCloneNick{%checkNick}, ",", ", ")
$$->%DbHost = %checkHost
} else {
$$->%DbCloneNick{%checkNick} =
}
}

createWin(){
# Environment creation
%Clone_win=$window.open(,$tr("Clones",helltrix) $chan.name,$context,113)
echo -w=%Clone_win $b$tr("Scanning for clones...",helltrix)
}

createWin(){
# Environment creation
if (!%HClone_win{$context} || !$window.exists(%HClone_win{$context})){
%HClone_win{$context} = $window.open(,$tr("Clones",helltrix) $context.networkName,$context,113)
} else {
window.maximize %HClone_win{$context}
}

output($0=windowId,$1=nick){
%win=$0
%checkNick=$1
echo -w=%HClone_win{$context} -i=114 $b$tr("Scanning for clones in",helltrix) $chan.name
return %HClone_win{$context}
}

output($0=windowId,$1=nick,$2=host){
if($0){
%win=$0
} else {
%win=$channel
}
%checkNick=$1

if(!%checkNick){
# Output for global scan
if(!%checkNick){
for(%i=0; %i<%ArrayNick[]#; %i++){
if(%DbCloneNum{%ArrayNick[%i]}>1){
if(%win)
echo -w=%win $b%DbCloneNick{%ArrayNick[%i]} $o$tr("on channel",helltrix) $b$chan.name $o$tr("have same mask",helltrix) $b%DbHost{%ArrayNick[%i]}
else
echo -w=$active $b%DbCloneNick{%ArrayNick[%i]} $o$tr("on channel",helltrix) $b$chan.name $o$tr("have same mask",helltrix) $b%DbHost{%ArrayNick[%i]}
}
}
} else {
# Output for nick scan
if(%DbCloneNum{%checkNick}>1){
if(%win)
echo -w=%win $b%DbCloneNick{%checkNick} $o$tr("on channel",helltrix) $b$chan.name $o$tr("have same mask",helltrix) $b%DbHost{%checkNick}
else
echo -w=$active $b%DbCloneNick{%checkNick} $o$tr("on channel",helltrix) $b$chan.name $o$tr("have same mask",helltrix) $b%DbHost{%checkNick}
}

%cf=0
foreach(%i,$keys($$->%DbCloneNick)){
echo -w=%win -i=117 " "$b$$->%DbCloneNick{%i} $b$tr("have same host",helltrix) $b$$->%DbHost[%i]
%cf++
}
if(!%cf)
echo -w=%win -i=114 $b$tr(" No clones found on",helltrix) $chan.name
echo -w=%win -i=114 $b$tr("Scan End",helltrix)
} else {
# Output for nick scan
if($$->%DbCloneNick{%checkNick}){
echo -w=%win -i=117 $b$$->%DbCloneNick{%checkNick} $b$tr("have same host",helltrix) $b$$->%DbHost
} elseif (!$2) {
echo -w=%win -i=114 $tr("No clones found for",helltrix) $b%checkNick
}

if(%win)
echo -w=%win $b$tr("Scan End",helltrix)
#echo -w=%Clone_win $b$tr("No clones found on",helltrix) $chan.name
}
}

}

# Script Alias
alias(hell_clonescan)
{
if (!$channel){
echo -w=$active -i=118 $tr("[Clonescan]: This is not a channel window",helltrix)
return
}
%isNick=$0
%clonescan=$new(helltrixclone)

if(!$0){
if(!%isNick){
%clonescan->$cloneCheck()
%clonescan->$createWin()
%clonescan->$output(%Clone_win,)
%win=%clonescan->$createWin()
%clonescan->$output(%win,)
} else {
# If we want a nick scan
foreach(%isNick,%ArrayNick[]){
if(%isNick==$0)
break
}

if(%isNick!=$0){
echo -w=$active $tr("Usage",helltrix): /helltrix_clonescan [nick]
return
%isHost=$1
if (!$sw(j) && !$chan.ison(%isNick)){
echo -w=$active -i=114 $b%isNick $b$tr("is not in",helltrix) $b$target
} elseif (!%isHost || (%isHost == $hostName(%isNick)) || $sw(j)){
if ($sw(j) && (%isHost != $hostName(%isNick))){
# This only happens, in the case of a join and fast change to vhost
%isHost=$hostName(%isNick)
}
%clonescan->$cloneCheck(%isNick,%isHost)
%clonescan->$output(,%isNick,%isHost)
} else {
echo -w=$active $tr("Usage",helltrix): /hell_clonescan [nick]
}

%isHost=$mask(%isNick,9)

%clonescan->$cloneCheck(%isNick,%isHost)
%clonescan->$output(,%isNick)
}

# Clean array
%ArrayNick[]=
%DbHost{}=
%DbCloneNum{}=
%DbCloneNick{}=

# TODO:
# fix global scan
# language files

delete %clonescan
}

# Script Event
event(OnJoin,clonescan)
{
hell_clonescan $0
hell_clonescan -j $0 $2
}

# Script Popups
defpopup-m ("channeltextview")
{
label(HelLViS69 Clonescan)
item("Clonescan","113"){
hell_clonescan
popup(HelLViS69 Clonescan,113,696969)
{
item("Clonescan", )
{
hell_clonescan
}
}
}
Binary file added clonescan/locale/helltrix_es.mo
Binary file not shown.
Binary file added clonescan/pics/hell_clonescan.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
62 changes: 62 additions & 0 deletions clonescan/po/helltrix.pot
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
# SOME DESCRIPTIVE TITLE.
# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
# This file is distributed under the same license as the PACKAGE package.
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
#
#, fuzzy
msgid ""
msgstr ""
"Project-Id-Version: clonescan 1.2.7\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2017-08-31 15:59+0200\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <[email protected]>\n"
"Language: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=CHARSET\n"
"Content-Transfer-Encoding: 8bit\n"

#: install.kvs:7
msgid "A simple script for scanning clones in channels"
msgstr ""

#: install.kvs:88
msgid "[BUG]: The system could not retrieve the host of"
msgstr ""

#: install.kvs:105
msgid "Clones"
msgstr ""

#: install.kvs:109
msgid "Scanning for clones in"
msgstr ""

#: install.kvs:125 install.kvs:134
msgid "have same host"
msgstr ""

#: install.kvs:129
msgid " No clones found on"
msgstr ""

#: install.kvs:130
msgid "Scan End"
msgstr ""

#: install.kvs:136
msgid "No clones found for"
msgstr ""

#: install.kvs:146
msgid "[Clonescan]: This is not a channel window"
msgstr ""

#: install.kvs:160
msgid "is not in"
msgstr ""

#: install.kvs:169
msgid "Usage"
msgstr ""
Loading

0 comments on commit f3514c1

Please sign in to comment.