This is the new home of the egghelp.org community forum.
All data has been migrated (including user logins/passwords) to a new phpBB version.


For more information, see this announcement post. Click the X in the top right-corner of this box to dismiss this message.

invite a user list when users connect server

Help for those learning Tcl or writing their own scripts.
Post Reply
j
juanamores
Master
Posts: 317
Joined: Sun Mar 15, 2015 9:59 am

invite a user list when users connect server

Post by juanamores »

In mSL (mIRC script language) exists a list called notify. See
The notify list is like a buddy list, it notifies you when someone in your list comes on or leaves the IRC network that you are on.

I made a code in mSL, which invites a specific channels, notify list users.
When any user found in the guest list, connects to an IRC server, the bot invites the established channels.

You can achieve this in Tcl?
If you do not understand my ideas is because I can not think in English, I help me with Google Translate. I only speak Spanish. Bear with me. Thanks :)
User avatar
SpiKe^^
Owner
Posts: 831
Joined: Fri May 12, 2006 10:20 pm
Location: Tennessee, USA
Contact:

Post by SpiKe^^ »

I'm fairly sure that anything that can be done in MSL can also be pulled off in Eggdrop TCL.
So the answer to "You can achieve this in Tcl?" is Yes.

Have you searched the internet for a script like that yet?
SpiKe^^

Get BogusTrivia 2.06.4.7 at www.mytclscripts.com
or visit the New Tcl Acrhive at www.tclarchive.org
.
User avatar
caesar
Mint Rubber
Posts: 3776
Joined: Sun Oct 14, 2001 8:00 pm
Location: Mint Factory

Post by caesar »

If the IRC server you are connected to supports ISON then can use this to achieve what you want. On Undernet the result of a ISON will be a raw 303 reply. On what network are you connected?

On Undernet using the raw 303 I got this up and running:

Code: Select all

namespace eval friendInvite { 
	set ison(friends) {"friend_1" "friend_2"}
	set ison(channels) {"#channel" "#anotherChannel"}

	bind cron - {*/5} [namespace current]::check
	bind raw - 303 [namespace current]::reply

	proc reply {from keyword text} {
		variable ison
		set friend [join [lindex [split $text :] 1]]
		if {$friend ne ""} {
			foreach chan $ison(channels) {
				if {[botonchan $chan]} {
					puthelp "INVITE $friend $chan"
				}
			}
		}
	}

	proc check {min hour day month weekday} {
		variable ison
		foreach friend $ison(friends) {
			if {[getchanhost $friend] ne ""} {
				foreach chan $ison(channels) {
					if {![botisop $chan]} continue
					if {[onchan $friend $chan]} continue
					puthelp "INVITE $friend $chan"
				}
			} else {
				puthelp "ISON $friend"
			}
		}
	}
}
It dose a check every 5 minutes, but if needed can be adjusted to whatever suits your needs. mIRC dose a ISON check only when you access the notify list or hit /notify on your own.
Once the game is over, the king and the pawn go back in the same box.
j
juanamores
Master
Posts: 317
Joined: Sun Mar 15, 2015 9:59 am

Post by juanamores »

caesar you are a genius!
Works very well :)
The difference I noticed with mIRC, is that mIRC invites only once at user, when connecting to the network, or if after connecting changing nick, and then return to the original nickname, contained in notification list, in this case again invites.

In the code you have shared with me, inviting the same user indefinitely every x minutes.

Can you fix the code, to invite a user only once, when connected to the network, and then re-invite if you leave the network and enter again or if being on the net the nick is changed, then return to the nick is on the notification list?
If you do not understand my ideas is because I can not think in English, I help me with Google Translate. I only speak Spanish. Bear with me. Thanks :)
User avatar
caesar
Mint Rubber
Posts: 3776
Joined: Sun Oct 14, 2001 8:00 pm
Location: Mint Factory

Post by caesar »

Sure, here's the new code.

Code: Select all

namespace eval friendInvite { 
	set ison(friends) {"friend_1" "friend_2"}
	set ison(channels) {"#channel" "#anotherChannel"}

	bind raw - 303 [namespace current]::reply
	bind evnt - init-server [namespace current]::check

	proc reply {from keyword text} {
		variable ison
		set friend [join [lindex [split $text :] 1]]
		if {$friend eq ""} return
		if {[lsearch -nocase $ison(friends) $friend] eq -1} return
		foreach chan $ison(channels) {
			if {[botonchan $chan]} {
				puthelp "INVITE $friend $chan"
			}
		}
	}

	proc connected init-server {
		variable ison
		foreach friend $ison(friends) {
			puthelp "ISON $friend"
		}
	}
}
It will check the friends list only once after it connected to the IRC network. Is this what you wanted? Or you want it to keep monitoring when one of the friends in the list disconnected and reconnected and invite once?
Once the game is over, the king and the pawn go back in the same box.
w
willyw
Revered One
Posts: 1197
Joined: Thu Jan 15, 2009 12:55 am

Post by willyw »

This is very rough. There are a lot of things that can be done with it, to improve it.

It's purpose is only to demonstrate the idea, as this is what I think the original poster is asking for.

He is used to using the IRC servers built-in "watch" or "monitor" command, and I think these are handled transparently by mIRC.
They provide instant notification, when a nick appears or disappears on the network.

That is part of the problem with this kind of script. It may need to be
customized for the particular network that it is to be used on.
This script works on the one network that I tested it on.

One would benefit from using:
/debug @debugwindow
in mIRC, then experimenting with sending
/notify
and also its variants with switches. Then watch for the raw numerics returned.


Code: Select all

# April 20, 2015

# http://forum.egghelp.org/viewtopic.php?t=19934

# the poster is asking to make something similar to mIRC's built in "notify" list
# mIRC uses the IRC server's /watch command   or the  /monitor command


# Usage:
# To temporarily add a nick to the watch list:
# !addwatch <nick>

# To temporarily remove a nick from the watch list:
# !remwatch <nick>

# To display the current watch list:
# !watchlist 



# You must create a plain text file, with one nick per line
# This file will be read by the bot upon .restart and the nicks in it
# will be added to the watch list held by the IRC server for this session.

#set the path/filename of file that holds the nicks to watch  (Required)
set nicks_watch_file "scripts/added/use_irc_watch/nicks_watch_file.txt"

#set channel where you can experiment and demonstrate this script  (Required - and bot must be on this channel)
set your_demo_chan #eggdrop




##########################################################################
##########################################################################
bind pub - "!addwatch" add_to_watchlist
bind pub - "!remwatch" remove_from_watchlist
bind pub - "!watchlist" get_watch_stats

bind raw - 600 rpl_logon
bind raw - 601 rpl_logoff
bind raw - 606 rpl_watchlist

#Reference : https://www.alien.net.au/irc/irc2numerics.html



#########  to read the nicks to watch, and send them to the IRC server
proc send_watch_command {nicks_watch_file} {

        if {![file exists $nicks_watch_file]} {
                putlog " "
                putlog "$nicks_watch_file not found !"
                putlog " "
                return 0
        }


        set fp [open $nicks_watch_file "r"]
        set data [read -nonewline $fp]
        close $fp

        set lines [split $data "\n"]

        foreach n $lines {
                puthelp "watch +$n"
        }

        putlog "Added these nicks to watch list on IRC server : $lines"
}




proc rpl_logon {from key text } {
global your_demo_chan
        #putserv "privmsg $your_demo_chan :$from       $key        $text"
        putserv "privmsg $your_demo_chan :[lindex [split $text] 1 ] has logged on "

        putserv "invite [lindex [split $text] 1] $your_demo_chan "
}



proc rpl_logoff {from key text} {
global your_demo_chan
        #putserv "privmsg $your_demo_chan :$from      $key         $text"
        putserv "privmsg $your_demo_chan :[lindex [split $text] 1 ] has logged off"
}

proc rpl_watchlist {from key text} {
global your_demo_chan
        putserv "privmsg $your_demo_chan :Watch list of nicks is currently: [lindex [split $text :] 1]"
}




proc add_to_watchlist {nick uhost handle chan text} {
        putserv "watch +[lindex [split $text] 0 ]"
        putserv "privmsg $chan :[lindex [split $text] 0 ] temporarily added to watch list"
        putserv "privmsg $chan :Edit the watch list file, to make it permanent for next restart of bot"
}

proc remove_from_watchlist {nick uhost handle chan text} {
        putserv "watch -[lindex [split $text] 0 ]"
        putserv "privmsg $chan :[lindex [split $text] 0 ] temporarily removed from watch list"
        putserv "privmsg $chan :Edit the watch list file, to permanently remove for next restart of bot"
}


proc get_watch_stats {nick uhost handle chan text} {
        putserv "watch stat"
}






#########  read the nicks to watch, and send them to the IRC server
bind evnt - init-server do_watch_command_wrap

proc do_watch_command_wrap {type} {
global nicks_watch_file
        send_watch_command $nicks_watch_file
}
#########
For a fun (and popular) Trivia game, visit us at: irc.librairc.net #science-fiction . Over 300K Q & A to play in BogusTrivia !
w
willyw
Revered One
Posts: 1197
Joined: Thu Jan 15, 2009 12:55 am

Post by willyw »

juanamores:

What network is your bot on?
and what is the address?
For a fun (and popular) Trivia game, visit us at: irc.librairc.net #science-fiction . Over 300K Q & A to play in BogusTrivia !
j
juanamores
Master
Posts: 317
Joined: Sun Mar 15, 2015 9:59 am

Post by juanamores »

willyw wrote:juanamores:

What network is your bot on?
and what is the address?
Network: chathispano
Adress: irc.irc-hispano.org
this adress connect to miranda.chathispano.com or ariel.chathispano.com

In a while I'll try the code you have shared.
Now I am testing the caesar´s code. :)

Very grateful for your interest my friend. :D
If you do not understand my ideas is because I can not think in English, I help me with Google Translate. I only speak Spanish. Bear with me. Thanks :)
j
juanamores
Master
Posts: 317
Joined: Sun Mar 15, 2015 9:59 am

Post by juanamores »

caesar wrote: Or you want it to keep monitoring when one of the friends in the list disconnected and reconnected and invite once?
Yes, I want to keep monitoring when one of the friends in the list disconnected and reconnected and invite once, and if possible, if someone after being invited changing nick, and then returns to nick that is listed, re-invite too.

EDIT:

Dear caesar, code shared with willyw does exactly what I want.

Only I have to modify it to suit my needs.
The changes I plan are:
a) that adding a user to the list, modify the txt file, in this code must be modified manually.
b) also that deleting a user, it modify the file.
c) not invite all users to the same channel, but depending on your flag, the invite to the channel concerned.
Some users will be invited to all channels of staff, others just one.
I think this got work to go editing. :)

Very grateful to caesar and willyw for their important help. :D
If you do not understand my ideas is because I can not think in English, I help me with Google Translate. I only speak Spanish. Bear with me. Thanks :)
w
willyw
Revered One
Posts: 1197
Joined: Thu Jan 15, 2009 12:55 am

Post by willyw »

juanamores wrote: ...
Only I have to modify it to suit my needs.
Excellent!
It wasn't meant to be all finished.
I'm glad if you can use it enough to get started and modify it to your needs.
The changes I plan are:
a) that adding a user to the list, modify the txt file, in this code must be modified manually.
b) also that deleting a user, it modify the file.
Visit here:
http://forum.egghelp.org/viewtopic.php?t=6885

and you might find some info that is helpful with that.

c) not invite all users to the same channel, but depending on your flag, the invite to the channel concerned.
Some users will be invited to all channels of staff, others just one.
I think this got work to go editing. :)
Have fun with your bot, and with writing your own TCL for it!
:)
For a fun (and popular) Trivia game, visit us at: irc.librairc.net #science-fiction . Over 300K Q & A to play in BogusTrivia !
Post Reply