| View previous topic :: View next topic |
| Author |
Message |
Fire-Fox Master

Joined: 23 Sep 2006 Posts: 270 Location: /dev/null
|
Posted: Tue Feb 10, 2009 5:11 pm Post subject: Help with joinmsg |
|
|
Hey how do i add the ??
Something like : | Quote: | | setudef flag joinmsg |
| Code: | package require mysqltcl
bind join - * join:testarea
bind rejn - * join:testarea
##################
### Mysql path ###
##################
# SQL info
set sql(host) "xxxxxxxxxx"
set sql(user) "xxxxxxxxxx"
set sql(pass) "xxxxxxxxxx"
set sql(db) "xxxxxxxxxx"
set sql(port) "xxxx"
##################
### Mysql path ###
##################
if {![info exists db_handle] } {
set db_handle [mysqlconnect -host $sql(host) -user $sql(user) -password $sql(pass) -db $sql(db) -port $sql(port)]
}
###########################################
### Greeting MSG When User Join channel ###
###########################################
proc bt.join.class { chan nick class} {
switch $class {
### The number is the number of the class on the site
### "return 0" means no msg for that class
"default" {set class "Not Found" }
}
}
#################
### Join Proc ###
#################
proc join:testarea {nick host hand chan} {
global botnick db_handle
if {$nick != $botnick} {
if {[mysqlping $db_handle] != 1} {
putserv "PRIVMSG $chan : The connection to the mysql server has been lost."
return 0
}
set sqlnick "SELECT userid FROM joinmsgnicks WHERE nick='[mysqlescape $nick]'"
set resultnick [mysqlquery $db_handle $sqlnick]
set nicki 0
while {[set record [mysqlnext $resultnick]] != ""} {
set userid [lindex $record 0]
incr nicki
}
if { $nicki == 0 } { return 0 }
if { $userid == "" } { return 0 }
set sql "SELECT username, class FROM joinmsgircuser WHERE id='[mysqlescape $userid]'"
set result [mysqlquery $db_handle $sql]
set i 0
while {[set record [mysqlnext $result]] != ""} {
set username [lindex $record 0];
set class [lindex $record 1];
}
set sql "SELECT username, class FROM joinmsgircuser WHERE id='[mysqlescape $userid]'"
set result [mysqlquery $db_handle $sql]
set i 0
while {[set record [mysqlnext $result]] != ""} {
set username [lindex $record 0];
set class [lindex $record 1];
}
mysqlendquery $result
bt.join.class $chan $nick $class
}
}
putlog "Joinmsg" |
_________________ GreatZ
Fire-Fox | Denmark
Scripts: Relay | Store Text | TvMaze |
|
| Back to top |
|
 |
nml375 Revered One
Joined: 04 Aug 2006 Posts: 2857
|
Posted: Tue Feb 10, 2009 5:34 pm Post subject: |
|
|
I must say you pretty much answered your own question there..
To define the custom channel flag "joinmsg", make sure the following piece of code to your script, in such fashion that it will be executed as the script loads (usually in the top of the script):
| Code: | | setudef flag joinmsg |
Once this is done, this flag can be used just like any other flag available in your eggdrop. You probably would like to read up on the channel command (doc/tcl-commands.doc), especially the get option. _________________ NML_375, idling at #eggdrop@IrcNET |
|
| Back to top |
|
 |
Fire-Fox Master

Joined: 23 Sep 2006 Posts: 270 Location: /dev/null
|
Posted: Tue Feb 10, 2009 5:46 pm Post subject: |
|
|
Hey
I did the following thing
| Code: | proc bt.join.class { chan nick class} {
[b]if {[channel get $chan joinmsg]} { [/b]
switch $class {
### The number is the number of the class on the site
### "return 0" means no msg for that class
"default" {set class "Not Found" }
}
[b] }[/b]
}
|
_________________ GreatZ
Fire-Fox | Denmark
Scripts: Relay | Store Text | TvMaze |
|
| Back to top |
|
 |
nml375 Revered One
Joined: 04 Aug 2006 Posts: 2857
|
Posted: Tue Feb 10, 2009 5:59 pm Post subject: |
|
|
That would be the proper way of testing whether "joinmsg" is set for the specific channel, yes. _________________ NML_375, idling at #eggdrop@IrcNET |
|
| Back to top |
|
 |
Fire-Fox Master

Joined: 23 Sep 2006 Posts: 270 Location: /dev/null
|
Posted: Tue Feb 10, 2009 6:03 pm Post subject: |
|
|
Yes i noticed, i tryed with +joinmsg, and made a /hop (the bot reply with the welcome msg) and then with -joinmsg (Nothing happend)
so i must say it works  _________________ GreatZ
Fire-Fox | Denmark
Scripts: Relay | Store Text | TvMaze |
|
| Back to top |
|
 |
Fire-Fox Master

Joined: 23 Sep 2006 Posts: 270 Location: /dev/null
|
Posted: Thu Feb 12, 2009 8:07 am Post subject: |
|
|
Sorry for bump
Is it possible to add so i can add the users via !tcl commands instead of i have to login to the mysql to add the users?
the output : | Quote: | | [@LillePil] Welcome To ::: Apache ::: Bot Commander |
_________________ GreatZ
Fire-Fox | Denmark
Scripts: Relay | Store Text | TvMaze |
|
| Back to top |
|
 |
nml375 Revered One
Joined: 04 Aug 2006 Posts: 2857
|
Posted: Thu Feb 12, 2009 11:13 am Post subject: |
|
|
Assuming the account has insert/update privileges for the table, sure.
Would be a mere matter of a proper INSERT query sent using the mysqlquery command
Since I don't know the table structure for your database, I really can't say much more than that. _________________ NML_375, idling at #eggdrop@IrcNET |
|
| Back to top |
|
 |
Fire-Fox Master

Joined: 23 Sep 2006 Posts: 270 Location: /dev/null
|
Posted: Thu Feb 12, 2009 11:27 am Post subject: |
|
|
| nml375 wrote: | Assuming the account has insert/update privileges for the table, sure.
Would be a mere matter of a proper INSERT query sent using the mysqlquery command
Since I don't know the table structure for your database, I really can't say much more than that. |
Hey again
Here is the table structure
| Code: |
CREATE TABLE `joinmsgircuser` (
`id` int(10) unsigned NOT NULL auto_increment,
`username` varchar(40) NOT NULL default '',
`class` tinyint(3) unsigned NOT NULL default '1',
PRIMARY KEY (`id`),
UNIQUE KEY `username` (`username`),
KEY `username_status` (`username`)
) TYPE=MyISAM AUTO_INCREMENT=32 ;
CREATE TABLE `joinmsgnicks` (
`id` int(16) NOT NULL auto_increment,
`nick` varchar(32) NOT NULL default '',
`userid` int(16) default NULL,
PRIMARY KEY (`id`)
) TYPE=MyISAM AUTO_INCREMENT=33 ;
|
_________________ GreatZ
Fire-Fox | Denmark
Scripts: Relay | Store Text | TvMaze |
|
| Back to top |
|
 |
nml375 Revered One
Joined: 04 Aug 2006 Posts: 2857
|
Posted: Thu Feb 12, 2009 11:41 am Post subject: |
|
|
I was hoping for a slight explanation of the fields and any relationship.. but here it goes...
Generic syntax for inserts:
| Code: | | INSERT INTO table (field1, field2) VALUES (data1, data2) |
In this case, you've got two auto_increment-fields, so you should not set these. This leaves us with "username", "class" for the joinmsgircuser table, and "nick", "userid" for the joinmsgnicks table.
The code you've posted suggests joinmsgnicks.userid links with joinmsgircuser.id, but you'll have to confirm this...
In order to retrieve the last_insertid, use the mysqlinsertid command.
Btw, I am a bit puzzled as to why you repeat the same query. _________________ NML_375, idling at #eggdrop@IrcNET |
|
| Back to top |
|
 |
Fire-Fox Master

Joined: 23 Sep 2006 Posts: 270 Location: /dev/null
|
Posted: Thu Feb 12, 2009 2:03 pm Post subject: |
|
|
| nml375 wrote: | I was hoping for a slight explanation of the fields and any relationship.. but here it goes...
Generic syntax for inserts:
| Code: | | INSERT INTO table (field1, field2) VALUES (data1, data2) |
In this case, you've got two auto_increment-fields, so you should not set these. This leaves us with "username", "class" for the joinmsgircuser table, and "nick", "userid" for the joinmsgnicks table.
The code you've posted suggests joinmsgnicks.userid links with joinmsgircuser.id, but you'll have to confirm this...
In order to retrieve the last_insertid, use the mysqlinsertid command.
Btw, I am a bit puzzled as to why you repeat the same query. |
Hey
| Quote: | | Btw, I am a bit puzzled as to why you repeat the same query. |
A mate of mine made it a while back. it was made like this:
If a user signed up on a site, and when the same user joined irc they got a greeting message, something like : Welcome ::: Nick ::: UserClass (On the site)
And yes then the script don't need the second script i believe?
but could you help me make it right? im not that good to anything  _________________ GreatZ
Fire-Fox | Denmark
Scripts: Relay | Store Text | TvMaze |
|
| Back to top |
|
 |
nml375 Revered One
Joined: 04 Aug 2006 Posts: 2857
|
Posted: Thu Feb 12, 2009 3:09 pm Post subject: |
|
|
Roger that.
The following code will create new records in both joinmsgnicks and joinmsgircuser, based on the previous mentioned assumption:
| Code: | set query1 [mysqlquery "INSERT INTO joinmsgircuser (username, class) VALUES (\"[mysqlescape $username]\", [mysqlescape $class])"]
set query2 [mysqlquery "INSERT INTO joinmsgnicks (nick, userid) VALUES (\"[mysqlescape $nickname]\", [mysqlinsertid $db_handle])"]
mysqlendquery $query1
mysqlendquery $query2 |
This would then be placed in some proc, triggered with the binding of your liking. Data should be made available in the variables username, class, and nickname. _________________ NML_375, idling at #eggdrop@IrcNET |
|
| Back to top |
|
 |
Fire-Fox Master

Joined: 23 Sep 2006 Posts: 270 Location: /dev/null
|
Posted: Thu Feb 12, 2009 3:14 pm Post subject: |
|
|
| nml375 wrote: | Roger that.
The following code will create new records in both joinmsgnicks and joinmsgircuser, based on the previous mentioned assumption:
| Code: | set query1 [mysqlquery "INSERT INTO joinmsgircuser (username, class) VALUES (\"[mysqlescape $username]\", [mysqlescape $class])"]
set query2 [mysqlquery "INSERT INTO joinmsgnicks (nick, userid) VALUES (\"[mysqlescape $nickname]\", [mysqlinsertid $db_handle])"]
mysqlendquery $query1
mysqlendquery $query2 |
This would then be placed in some proc, triggered with the binding of your liking. Data should be made available in the variables username, class, and nickname. |
Thanks. but why should i remove from the script (it not used to a site anymore. only when users join my irc channel )
Could i get you to add it into the script i pasted?
And then add a tcl command so i just need to type !addmsg (or something) Nickname (and some text)
So it would look like : "Welcome ::: NickName ::: Some text here
Self retrived from the database. _________________ GreatZ
Fire-Fox | Denmark
Scripts: Relay | Store Text | TvMaze |
|
| Back to top |
|
 |
nml375 Revered One
Joined: 04 Aug 2006 Posts: 2857
|
Posted: Thu Feb 12, 2009 3:32 pm Post subject: |
|
|
If you simply want someone to "fix" the script for you, I would recommend that you try the "Script Request" category instead. _________________ NML_375, idling at #eggdrop@IrcNET |
|
| Back to top |
|
 |
|