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 

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

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


Joined: 14 Jul 2006
Posts: 1

PostPosted: Fri Jul 14, 2006 5:33 pm    Post subject: Read/Write to mySQL db, almost finished, needs final touch. Reply with quote

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/showthread.php?t=93097&highlight=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 Smile

Code:

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.
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 -> 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