<?xml version="1.0" encoding="UTF-8"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en-gb">
	<link rel="self" type="application/atom+xml" href="https://forum.eggheads.org/app.php/feed/topic/10890" />

	<title>egghelp/eggheads community</title>
	<subtitle>Discussion of eggdrop bots, shell accounts and tcl scripts.</subtitle>
	<link href="https://forum.eggheads.org/index.php" />
	<updated>2005-12-04T05:39:45-04:00</updated>

	<author><name><![CDATA[egghelp/eggheads community]]></name></author>
	<id>https://forum.eggheads.org/app.php/feed/topic/10890</id>

		<entry>
		<author><name><![CDATA[Buffy_25]]></name></author>
		<updated>2005-12-04T05:39:45-04:00</updated>

		<published>2005-12-04T05:39:45-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=57934#p57934</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=57934#p57934"/>
		<title type="html"><![CDATA[Mysql.mod / checking info]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=57934#p57934"><![CDATA[
demond,<br><br>I made a less complex script to see how all those basic commands were working, and i got it working now <img class="smilies" src="https://forum.eggheads.org/images/smilies/icon_smile.gif" width="15" height="15" alt=":)" title="Smile"> <br><br>"Lappend" is a wonderfull option  <img class="smilies" src="https://forum.eggheads.org/images/smilies/icon_razz.gif" width="15" height="15" alt=":P" title="Razz"> <br><br>Thanks for your time.<br><br>Buffy<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=4178">Buffy_25</a> — Sun Dec 04, 2005 5:39 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[demond]]></name></author>
		<updated>2005-11-29T23:16:56-04:00</updated>

		<published>2005-11-29T23:16:56-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=57818#p57818</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=57818#p57818"/>
		<title type="html"><![CDATA[Mysql.mod / checking info]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=57818#p57818"><![CDATA[
well, what I presented to you in pseudo-code is extremely simple IMO, you should be able to grasp and implement it<br><br>I've got the feeling what you're trying to do is your first script, and you feel quite uncomfortable with basic programming stuff; if that's the case, you need to start from the basics - for example, write a script which adds or removes element, or/and searches through a Tcl list; then try to find common elements in 2 lists<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=5056">demond</a> — Tue Nov 29, 2005 11:16 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[Buffy_25]]></name></author>
		<updated>2005-11-29T07:38:35-04:00</updated>

		<published>2005-11-29T07:38:35-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=57803#p57803</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=57803#p57803"/>
		<title type="html"><![CDATA[Mysql.mod / checking info]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=57803#p57803"><![CDATA[
Demond,<br><br>I tried to set it up with 2 seperated lists, but i'm kind of stuck with the .Txt file since it's containing info like this (txt after the nicknames):<br><blockquote class="uncited"><div>David was online for 2 hours 1 minute 3 seconds <br>Marcus was online for 1 day 3 hours 21 minutes 2 seconds <br>Helen was online for 35 minutes 25 seconds <br>Odeline was online for 3 days 25 minutes 3 seconds <br>... </div></blockquote>This is what i have as code:<div class="codebox"><p>Code: </p><pre><code>bind pub - "!update_data" update proc update {nick uhost hand chan arg} { set file [open /usr/account/eggdrop/logs/times.txt r]   set buf [read $file]   close $file   foreach line [split $buf \n] {     set line [string trim $line " "]     if {$line == ""} {continue}     set line [split $line]     set user_nick [lindex $line 0]    set uptime($user_nick) [join [lrange [split $line] 1 end]]  }mysql_connect MyDB localhost user passw /var/lib/mysql/mysql.sock set listuser [mysql_query "SELECT name FROM Userinfo"]   foreach element $listuser {       if {[lsearch $user_nick $element] == -1} {       putserv "PRIVMSG #channel :$user_nick isn't in the database and will be created"      set new_command [mysql_query "INSERT INTO Userinfo (name, useruptime) VALUES ('$usernick', '$uptime($user_nick)'"]       } else { putserv "PRIVMSG #channel :$user_nick is in the database and his uptime will be updated"         set presenttime [mysql_query "SELECT useruptime FROM Userinfo WHERE name='$user_nick'"]        set convpresenttime [converter $presenttime]        set convuseronline [converter $uptime($user_nick)]        set useronline [expr $convuseronline+$convpresenttime]        set onlinetime [duration $useronline]        set newtime [mysql_query "UPDATE Userinfo SET useruptime='$onlinetime' WHERE name='$user_nick'"]       }    } } proc converter {time} { #Working OK !}</code></pre></div>I'm lost, since my database isn't being updated as mentioned above  <img class="smilies" src="https://forum.eggheads.org/images/smilies/icon_sad.gif" width="15" height="15" alt=":(" title="Sad"> <br><br>Isn't this the correct way of working ?<br>Or are there any faultly lines?<br>(check if name exists, if not create new entry in database with the time behind the nick OR name exists, then update the uptime in database)<br><br>Thanks.<br><br>Buffy<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=4178">Buffy_25</a> — Tue Nov 29, 2005 7:38 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[demond]]></name></author>
		<updated>2005-11-29T00:14:25-04:00</updated>

		<published>2005-11-29T00:14:25-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=57786#p57786</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=57786#p57786"/>
		<title type="html"><![CDATA[Mysql.mod / checking info]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=57786#p57786"><![CDATA[
you are confused, <em class="text-italics">user_nick</em> is not an array (even it was, you handle it incorrectly - [array get] returns list of key-&gt;value pairs, not just values)<br><br>I suggested you create 2 lists separately - that implies you need not use nested loops, which doesn't make sense; follow this pseudo-code:<div class="codebox"><p>Code: </p><pre><code>open fileread each line into list1close fileopen dbSELECT name FROM userinfofetch each record into list2close dbforeach element $list1 {   if {[lsearch $list2 $element] == -1} {   # name from file is not in database, proceed accordingly   }}</code></pre></div><p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=5056">demond</a> — Tue Nov 29, 2005 12:14 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[Buffy_25]]></name></author>
		<updated>2005-11-28T07:35:11-04:00</updated>

		<published>2005-11-28T07:35:11-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=57759#p57759</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=57759#p57759"/>
		<title type="html"><![CDATA[Mysql.mod / checking info]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=57759#p57759"><![CDATA[
Hi demond,<br><br>I tried to put this into code, but it aint working (and no error):<br><div class="codebox"><p>Code: </p><pre><code>bind pub - "!update_data" updateproc update {nick uhost hand chan arg} {mysql_connect MyDB localhost user passw /var/lib/mysql/mysql.sockset file [open /usr/account/eggdrop/logs/times.txt r]   set buf [read $file]   close $file   foreach line [split $buf \n] {    set line [string trim $line " "]     if {$line == ""} {continue}     set line [split $line]     set user_nick [lindex $line 0]    foreach a [array get user_nick] {     set listuser [mysql_query "SELECT name FROM Userinfo"]      foreach e $listuser {      if {[lsearch -exact $e $a] == -1} {      putserv "PRIVMSG #channel :$e isn't in the database"           #so if no match, user isn't in my mysql data      }      else { putserv "PRIVMSG #channel :$e is in the database"               #if match, then confirm user is in mysql data      }      }   } }}</code></pre></div>Thanks for the help.<br><br>Buffy<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=4178">Buffy_25</a> — Mon Nov 28, 2005 7:35 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[demond]]></name></author>
		<updated>2005-11-26T17:26:56-04:00</updated>

		<published>2005-11-26T17:26:56-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=57719#p57719</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=57719#p57719"/>
		<title type="html"><![CDATA[Mysql.mod / checking info]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=57719#p57719"><![CDATA[
you need to SELECT * from db first, create a Tcl list out of it, and [foreach] name in this list to [lsearch] the list you made out of your text file<br><br>or, if the db is too large, bind a SELECT variable to each name in your file list and execute the SQL statement multiple times<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=5056">demond</a> — Sat Nov 26, 2005 5:26 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[Buffy_25]]></name></author>
		<updated>2005-11-26T09:53:16-04:00</updated>

		<published>2005-11-26T09:53:16-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=57699#p57699</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=57699#p57699"/>
		<title type="html"><![CDATA[Mysql.mod / checking info]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=57699#p57699"><![CDATA[
Hi,<br><br>On my linux computer i'm running mysql + mysql.mod<br><br>I have a mysql database that is keeping the users online time in my channel.<br>So i have :<br><blockquote class="uncited"><div>id      names     uptime<br>1       David      2 days 5 hours 24 minutues 1 second<br>2       Helen      5 weeks 3 days 29 minutes<br>3       Bonjo      6 days 4 hours 2 minutes</div></blockquote>Now i have normal txt file, that contains the following:<blockquote class="uncited"><div>David was online for 2 hours 1 minute 3 seconds<br>Marcus was online for 1 day 3 hours 21 minutes 2 seconds<br>Helen was online for 35 minutes 25 seconds<br>Odeline was online for 3 days 25 minutes 3 seconds<br>David was online for 3 hours 2 minutes 25 seconds<br>Helen was online for 5 hours 3 minutes 1 second<br>...</div></blockquote>What i would like to do, is to make a little script that read the txt file, and checks if the users in the txt file are known in my mysql database.<br>If exist, the uptime will be updated [expr]<br>If the nick doesn't exist, it will have to be created.<br><br>I have already the following, but i don't know how to check if the field "names" has a user of my txt file.<br><div class="codebox"><p>Code: </p><pre><code>bind pub - "!update_data" updateproc update {nick uhost hand chan arg} {mysql_connect MyDB localhost username passw /var/lib/mysql/mysql.sock  set file [open /usr/account/eggdrop/logs/times.txt r]   set buf [read $file]   close $file   foreach line [split $buf \n] {    set line [string trim $line " "]     if {$line == ""} {continue}     set line [split $line]     set user_nick [lindex $line 0]     set user_online [join [lrange $line 4 end]]     set user_online [converter $user_online]  #the proc convert is working good (put all in seconds)    if {![info exists useronline($user_nick)]} {       set useronline($user_nick) $user_online     } else {       set useronline($user_nick) [expr $useronline($user_nick)+$user_online]     }   }   foreach {user_nick user_online} [array get useronline] {#** here should come the part to check if user exists or not, but i'm totally lost for this part**#So if user exist, i'll go directly to update of database#If user doesn't exist, create the user with default data of table#this is the part to update the database uptimeset presenttime [mysql_query "SELECT useruptime FROM Userinfo WHERE name='$usernick'"]set convpresenttime [converter $presenttime]set convuseronline [converter $user_online]set useronline [expr $convuseronline+$convpresenttime]set onlinetime [duration $user_online($user_nick)]set newtime [mysql_query "UPDATE Userinfo SET useruptime='$onlinetime' WHERE name='$usernick'"] }}}</code></pre></div>Thank you.<br><br>Buffy<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=4178">Buffy_25</a> — Sat Nov 26, 2005 9:53 am</p><hr />
]]></content>
	</entry>
	</feed>
