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.

Read/Write to mySQL db, almost finished, needs final touch.

Requests for complete scripts or modifications/fixes for scripts you didn't write. Response not guaranteed, and no thread bumping!
Post Reply
m
mape
Voice
Posts: 1
Joined: Fri Jul 14, 2006 3:47 pm

Read/Write to mySQL db, almost finished, needs final touch.

Post by mape »

Hi,

I would love to get some help getting this script kick started into action. What I'm trying to do is link the AJAX driven mySQL module you can find here: http://www.vbulletin.org/forum/showthre ... ight=shout
with my IRC channel.
I have read through lots of documentation but I can't seem to find anything that pertains to what I'm aiming for. I would hope the script is more or less done and just needs some quick changes from someone who knows the TCL syntax/functions by heart.

Well here is my try at it. Note that there is most likely TONS of errors but it should give you the general idea of what I want it to do. The only real "gap" is how I should check whether the latest db entry is in fact new or if it has already been processed. As well as the problem with multiple people sending messages before the bot has had time to output the them. IE I would need some kind of queue system?

So if anyone wants to take a go at it I would be delighted :)

Code: Select all

set mysql(host) "127.0.0.1"
set mysql(port) "3306"
set mysql(user) "root"
set mysql(pass) "secret"
set mysql(data) "forum"
set mysql(??table??) "shout" //the table in the mySQL database

$style= 'a:5:{s:5:"color";s:0:"";s:4:"font";s:0:"";s:4:"bold";s:0:"";s:6:"italic";s:0:"";s:9:"underline";s:0:"";}';

//Add messages from IRC to the database
(when a _message_ is sent by a _user_ in the IRC channel the bot is in // No join,kick,part,notice or anything.){
	$user = Fetch the user sending the message. (how?)
	$sid = mysql(SELECT sid FROM shout ORDER by sid desc limit 1)+1;
	$unixtime = time();
	//Send this sql query to $database @ $server as $user/$pass
	INSERT INTO `shout` ( `sid` , `s_by` , `s_time` , `s_shout` , `s_data` , `s_me` )
	VALUES (
	'$sid', '0', $unixtime, '<span class="irc">'.$user.'</b>: '.$message, $style, '0'
	);
}

//Print messages from the database to IRC
(check database for new entrys(how do I check if they are new?)){
	//How do I solve the fact that there migth be more then 1 message? A queue system?
	if(mysql(SELECT s_by FROM shout ORDER by sid desc limit 1)>0){//If its 0 the message originated from IRC and I don't want that echoed back.
		$message = mySQL(SELECT s_shout FROM shout ORDER by sid desc limit 1);
		$username = mySQL(SELECT username FROM user WHERE userid = (SELECT s_by FROM shout ORDER by sid desc limit 1));
		putserv "$username: $message";
	}
}
/mape

Ps. I have TCL 8.4.13, mysqlTCL 3.01 and eggdrop 1.6.17 configured.
Post Reply