| View previous topic :: View next topic |
| Author |
Message |
Hugo2 Voice
Joined: 06 Dec 2012 Posts: 2
|
Posted: Thu Dec 06, 2012 3:33 pm Post subject: Irc channel into MySql database? |
|
|
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 |
|
 |
tomekk Master

Joined: 28 Nov 2008 Posts: 255 Location: Oswiecim / Poland
|
Posted: Thu Dec 06, 2012 3:47 pm Post subject: |
|
|
| Whole channel text into mysql table? |
|
| Back to top |
|
 |
Hugo2 Voice
Joined: 06 Dec 2012 Posts: 2
|
Posted: Thu Dec 06, 2012 3:57 pm Post subject: |
|
|
| Yes, I want every entry in the channel to go to the mysql database. |
|
| Back to top |
|
 |
tomekk Master

Joined: 28 Nov 2008 Posts: 255 Location: Oswiecim / Poland
|
Posted: Thu Dec 06, 2012 4:58 pm Post subject: |
|
|
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 |
|
 |
|