egghelp.org community Forum Index
[ egghelp.org home | forum home ]
egghelp.org community
Discussion of eggdrop bots, shell accounts and tcl scripts.
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

add command to dreamer invite script?

 
Post new topic   Reply to topic    egghelp.org community Forum Index -> Scripting Help
View previous topic :: View next topic  
Author Message
brood
Voice


Joined: 01 Sep 2005
Posts: 30

PostPosted: Wed Dec 28, 2005 7:13 am    Post subject: add command to dreamer invite script? Reply with quote

Hi, im using invite script by dreamer

Code:

###########################################
#                     
# Channel invite 0.1 BETA         
# Scripted by Dreamer            
#                      
###########################################
#   
# Type /msg <botnick> @add <nick> <pass>
# to add someone to the database
# Type /msg <botnick> @invite <nick> <pass>
# to get invited in to channel
#
# History:
# 0.1: First version
#
###########################################
# EDIT FROM HERE

# Channel where the bot wil invite
set chan_1 "#TCG"

# Name of the database
set db scripts/chan.invite

# STOP EDITING FROM HERE

set ver "0.1"

bind msg n add add_1
bind msg - invite inv_1

putlog "Channel invite $ver by Dreamer loaded"

# Script starts now

proc add_1 { nick uhost hand args } {
   global chan_1 db
   set args [split $args " "]
   set user [lindex $args 0]
   set user [string range $user 1 end]
   set pass [lindex $args 1]
   set pass [string range $pass 0 end-1]
   if { $user == "" || $pass == "" } {
         putserv "PRIVMSG $nick :Please instert a Nickname and a password"
         return 0
   }
   set up $user|$pass
   set wfile [open $db a+]
   puts $wfile $up
   close $wfile
   putserv "PRIVMSG $chan_1 :\002\[\0039DB-UPDATE\003\]\002 + \002$user\002 is added to INVITE-Database by \002$nick\002"
}

proc inv_1 { nick uhost hand arg } {
   global chan_1 db
   set found 0
   set arg [split $arg " "]
   set user1 [lindex $arg 0]
   set user1 [string range $user1 0 end]
   set pass1 [lindex $arg 1]
   set pass1 [string range $pass1 0 end]
   set up1 $user1|$pass1
   set found 0
   set fs [open $db r]
   while {![eof $fs]} {
   gets $fs line
   if {$line == $up1} { set found 1 }
   }
   close $fs
   if {$found} {
   putserv "PRIVMSG $chan_1 :\002\[\0039INVITE\003\]\002 - \002$user1\002 invited himself as \002$nick\002"
    putserv "invite $nick $chan_1"
   } else {
   putserv "PRIVMSG $nick :Wrong pass or username !!!!"
   putserv "PRIVMSG $chan_1 : \002\[\0034INTRUDER\003\]\002 - $nick tried to get in the channel with wrongpass or username"
   }
}



Can a command be added to delete nicks I dont want to be in the invite-db annymore? Something like:

/msg <botnick> @del <nick>

thanks
Back to top
View user's profile Send private message
IRCNick
Halfop


Joined: 12 Oct 2005
Posts: 64
Location: Germany

PostPosted: Wed Dec 28, 2005 8:08 am    Post subject: Reply with quote

I'm newbie in tcl but I want to learn, thats why I'm trying. This code is untested and could be wrong (I'm fast sure that it is wrong), use it on your own risk !

Ok add after
Code:
bind msg n add add_1

this line
Code:
bind msg n del del_1


and add this proc after the first proc
Code:

proc del_1 [nick uhost hand args } {
   global chan_1db
   set args [split $args " "]
   set user [lindex $args 0]
   set user [string range $user 1 end]
   set pass [lindex $args 1]
   set pass [string range $pass 0 end-1]
   set deluser $user|$pass
   set found 0
   set wfile [open $db a+]
   while {![eof $wfile]} {
   gets $wfile line
   if {$line == $deluser} {
    delete $deluser
   set found 1
    }
   }
   close $wfile
   if {$found} {
   puthelp "NOTICE $nick : \002\[\0039DB-UPDATE\003\]\002 + \002$user\002 is deleted successful from INVITE-Database"
   } else {
   puthelp "NOTICE $nick :The username was not found in the Database"
   }
}


And the command to delete nicks should be:
Code:
/msg <botnick> @del <nick> <pass>


Good luck
Back to top
View user's profile Send private message Visit poster's website
brood
Voice


Joined: 01 Sep 2005
Posts: 30

PostPosted: Wed Dec 28, 2005 5:58 pm    Post subject: Reply with quote

sorry, it doesnt seem to work Sad

but thanks for the response[/code]
Back to top
View user's profile Send private message
Sir_Fz
Revered One


Joined: 27 Apr 2003
Posts: 3793
Location: Lebanon

PostPosted: Wed Dec 28, 2005 6:59 pm    Post subject: Reply with quote

"Doesn't work" doesn't help you, you probably got an error and didn't bother to post it here.
Code:
proc del_1 [nick uhost hand args } {

should be
Code:
proc del_1 {nick uhost hand args } {

for starters.
_________________
Follow me on GitHub

- Opposing

Public Tcl scripts
Back to top
View user's profile Send private message Visit poster's website
Alchera
Revered One


Joined: 11 Aug 2003
Posts: 3344
Location: Ballarat Victoria, Australia

PostPosted: Wed Dec 28, 2005 7:01 pm    Post subject: Reply with quote

brood wrote:
sorry, it doesnt seem to work Sad

but thanks for the response[/code]

Code:
.set errorInfo

... then paste result into your post. Smile
_________________
Add [SOLVED] to the thread title if your issue has been.
Search | FAQ | RTM
Back to top
View user's profile Send private message Visit poster's website
IRCNick
Halfop


Joined: 12 Oct 2005
Posts: 64
Location: Germany

PostPosted: Wed Dec 28, 2005 7:28 pm    Post subject: Reply with quote

Sir_Fz wrote:
"Doesn't work" doesn't help you, you probably got an error and didn't bother to post it here.
Code:
proc del_1 [nick uhost hand args } {

should be
Code:
proc del_1 {nick uhost hand args } {

for starters.


Thank you, this was actually a type error...
But I think this isn't the problem. I wasn't very sure, what I have to do if I want to erase a line in some text file. I tried to search tcl.tk but I found nothing and I just writed:
Code:

delete $deluser

but I think, that this insn't the right syntax, it could be better if I add just -. instead of erasing the whole line. Hmm how I said I'm not very sure for the syntax.
Back to top
View user's profile Send private message Visit poster's website
Sir_Fz
Revered One


Joined: 27 Apr 2003
Posts: 3793
Location: Lebanon

PostPosted: Wed Dec 28, 2005 11:17 pm    Post subject: Reply with quote

You can read the file into a list, delete the line from the list and write the new list to the file.
_________________
Follow me on GitHub

- Opposing

Public Tcl scripts
Back to top
View user's profile Send private message Visit poster's website
brood
Voice


Joined: 01 Sep 2005
Posts: 30

PostPosted: Thu Dec 29, 2005 11:40 am    Post subject: Reply with quote

Quote:

Sir_Fz wrote:
"Doesn't work" doesn't help you, you probably got an error and didn't bother to post it here.
Code:
proc del_1 [nick uhost hand args } {

should be
Code:
proc del_1 {nick uhost hand args } {

for starters.


I notice that type error when I tried it.

the error i get is:

Quote:

Tcl error [del-1] : cant read "db": no such variable


I found the mistake:

Code:

   global chan_1db


should be
Code:

   global chan_1 db


Now it response to: /msg <botnick> @del <nick> <pass>

But if try a nick and pass thats in the db it will only say:

Quote:

*botnick* The username was not found in the Database


So it is not finding the nicks that are in the db.

I checked the db and the nicks are still there.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    egghelp.org community Forum Index -> Scripting Help All times are GMT - 4 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Forum hosting provided by Reverse.net

Powered by phpBB © 2001, 2005 phpBB Group
subGreen style by ktauber