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 

Irc channel into MySql database?

 
Post new topic   Reply to topic    egghelp.org community Forum Index -> Script Requests
View previous topic :: View next topic  
Author Message
Hugo2
Voice


Joined: 06 Dec 2012
Posts: 2

PostPosted: Thu Dec 06, 2012 3:33 pm    Post subject: Irc channel into MySql database? Reply with quote

Hello!
I have been looking for an eggdrop script that reads one or more channels and puts it into a MySql database. It will read/copy from an IRC channel and add it to a MySql database. Is there anyone who could help me with this? Or know if there is anything simular to this here on the forums? I've been looking like crazy, but I dont find anything. If you help me, I am forever grateful and can certainly give something in return.

/ Hugo2
Back to top
View user's profile Send private message
tomekk
Master


Joined: 28 Nov 2008
Posts: 255
Location: Oswiecim / Poland

PostPosted: Thu Dec 06, 2012 3:47 pm    Post subject: Reply with quote

Whole channel text into mysql table?
Back to top
View user's profile Send private message Visit poster's website
Hugo2
Voice


Joined: 06 Dec 2012
Posts: 2

PostPosted: Thu Dec 06, 2012 3:57 pm    Post subject: Reply with quote

Yes, I want every entry in the channel to go to the mysql database.
Back to top
View user's profile Send private message
tomekk
Master


Joined: 28 Nov 2008
Posts: 255
Location: Oswiecim / Poland

PostPosted: Thu Dec 06, 2012 4:58 pm    Post subject: Reply with quote

Try this one, kinda old but should work:
Code:
# Author: tomekk
# e-mail:  tomekk/@/tomekk/./org
# home page: http://tomekk.org/
#
# Version 0.1
#
# This file is Copyrighted under the GNU Public License.
# http://www.gnu.org/copyleft/gpl.html

# channel_name = channel table name in database
set channels_tables { #chan1 #chan2 }

# SQL user
set sql_user "myuser"

# SQL pass
set sql_pass "mypass"

# SQL server host
set sql_host "localhost"

# SQL database
set sql_dbase "mydbname"

##############################################################
package require mysqltcl

bind pubm - "*" eat_me

proc eat_me { nick uhost hand chan arg } {
        global channels_tables sql_user sql_pass sql_host sql_dbase

        foreach channel_table $channels_tables {
                if {$channel_table == $chan} {
                        set mysql_hand [::mysql::connect -host $sql_host -user $sql_user -password $sql_pass]

                        ::mysql::use $mysql_hand $sql_dbase

                        set escaped_nick [::mysql::escape $mysql_hand $nick]
                        set escaped_arg [::mysql::escape $mysql_hand $arg]

                        ::mysql::sel $mysql_hand "INSERT INTO `$channel_table` (`id`, `nick`, `text`) VALUES(NULL, '$escaped_nick', '$escaped_arg')"

                        ::mysql::close $mysql_hand
                }
        }
}

putlog "mysqlchan.tcl ver 0.1 by tomekk loaded"


table structure:
Code:
CREATE TABLE `#chan1` (
`id` INT NOT NULL AUTO_INCREMENT ,
`nick` VARCHAR( 32 ) NOT NULL ,
`text` TEXT NOT NULL ,
PRIMARY KEY ( `id` )
) ENGINE = MYISAM ;


Generally - it should work, but there can be problems with char encoding.
Try it.

/hint/
lsearch can be used instead of foreach, but anyway - this should be not a problem
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    egghelp.org community Forum Index -> Script Requests 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