<?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/16333" />

	<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>2008-11-28T13:21:30-04:00</updated>

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

		<entry>
		<author><name><![CDATA[tomekk]]></name></author>
		<updated>2008-11-28T13:21:30-04:00</updated>

		<published>2008-11-28T13:21:30-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=85995#p85995</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=85995#p85995"/>
		<title type="html"><![CDATA[Problems with reading from a file]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=85995#p85995"><![CDATA[
Hey<br><div class="codebox"><p>Code: </p><pre><code># Author: tomekk # e-mail:  tomekk/@/oswiecim/./eu/./org # home page: http://tomekk.oswiecim.eu.org/ # # Version 0.1 # # This file is Copyrighted under the GNU Public License. # http://www.gnu.org/copyleft/gpl.html# file with users and urlsset db_file "my_db.txt"############################################################bind pub - !add add_procbind pub - !edit edit_procbind pub - !del del_procbind pub - !list list_procbind pub - !change change_procif {![file exists $db_file]} {set need_new_one [open $db_file w]close $need_new_one}proc grab_users { } {global db_fileset db_hand [open $db_file r]set all_users [read $db_hand]close $db_handreturn $all_users}proc check_user { user } {global db_fileset exists 0foreach each_line [split [grab_users] "\n"] {set user_nick [lindex [split $each_line] 0]if {$user == $user_nick} {set exists 1break}}return $exists}proc add_proc { nick uhost hand chan arg } {global db_fileset our_args [split $arg]set our_user [lindex $our_args 0]set our_user_url [lindex $our_args 1]if {$our_user_url != ""} {set db_hand [open $db_file a]puts $db_hand "$our_user $our_user_url"close $db_hand}}proc edit_proc { nick uhost hand chan arg } {global db_fileset our_args [split $arg]set our_user [lindex $our_args 0]set our_user_url [lindex $our_args 1]if {$our_user_url != ""} {if {[check_user $our_user] == 1} {set db_users [grab_users]set new_file [open $db_file w]foreach each_line [split $db_users "\n"] {if {$each_line != ""} {set split_line [split $each_line]set just_nick [lindex $split_line 0]set just_url [lindex $split_line 1]if {$just_nick == $our_user} {puts $new_file "$just_nick $our_user_url"} {puts $new_file "$just_nick $just_url"}}}close $new_file}}}proc del_proc { nick uhost hand chan arg } {global db_fileset our_args [split $arg]set our_user [lindex $our_args 0]if {$our_user != ""} {if {[check_user $our_user] == 1} {set db_users [grab_users]set new_file [open $db_file w]foreach each_line [split $db_users "\n"] {if {$each_line != ""} {set split_line [split $each_line]set just_nick [lindex $split_line 0]set just_url [lindex $split_line 1]if {$just_nick != $our_user} {puts $new_file "$just_nick $just_url"}}}close $new_file}}}proc list_proc { nick uhost hand chan arg } {global db_fileset user_list [list]foreach each_line [split [grab_users] "\n"] {if {$each_line != ""} {set split_line [split $each_line]set just_nick [lindex $split_line 0]lappend user_list $just_nick}}set rdy_list [join $user_list ", "]putquick "PRIVMSG $chan :$rdy_list"}proc change_proc { nick uhost hand chan arg } {global db_fileset our_args [split $arg]set our_user [lindex $our_args 0]if {$our_user != ""} {if {[check_user $our_user] == 1} {foreach each_line [split [grab_users] "\n"] {if {$each_line != ""} {set split_line [split $each_line]set just_nick [lindex $split_line 0]set just_url [lindex $split_line 1]if {$just_nick == $our_user} {# delete this line# put here your MySQL queryputquick "PRIVMSG $chan :$just_nick =&gt; $just_url"}}}                }}}putlog "tiny-db.tcl ver 0.1 by tomekk loaded"</code></pre></div>I just wrote, try it.<br><br>manual:<br>!add user <a href="http://somewhere.com/" class="postlink">http://somewhere.com/</a> - adding a user to a file (one by one, line by line)<br>!edit user <a href="http://some.new.url.com/" class="postlink">http://some.new.url.com/</a> - updating user's url (if user exists)<br>!del user - deleting user from db, if there are more than one user with the same then script will delete all of them<br>!list - shows all users nicks from db on $chan<br>!change - this is the command for your MySQL<br><br>I don't want to install this stuff for MySQL,<br>I wrote u a comment in source,<br>just delete line with "putquick" and insert there some MySQL query,<br>user's url data is in "just_url" variable<br><br>Yoy can rename all bind etc.<br><br>cheers <img class="smilies" src="https://forum.eggheads.org/images/smilies/icon_smile.gif" width="15" height="15" alt=":)" title="Smile"><br><br>P.S<br>or ignore this post if im wrong ;p<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=10332">tomekk</a> — Fri Nov 28, 2008 1:21 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[SL0RD]]></name></author>
		<updated>2008-11-17T22:17:48-04:00</updated>

		<published>2008-11-17T22:17:48-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=85855#p85855</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=85855#p85855"/>
		<title type="html"><![CDATA[Problems with reading from a file]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=85855#p85855"><![CDATA[
So basically what I want to do is create a "database" like this:<div class="codebox"><p>Code: </p><pre><code>User1 http://user1url.comUser2 http://user2url.comUser3 http://user3url.comUser4 http://user4url.com</code></pre></div>I want to be able to do this with that database:<br><br>1. Add to the "database" &amp;&amp; Update an existing User's URL<br>2. Delete Users from the "database" by just using their nick<br>3. List all the user's names in the channel<br>4. If I do !change user3 in my channel i want it to write user3's url to a var so i can input it into a mysql table<br><br>I have been trying to get this to work for days and days. here is my attempt feel free to modify it or w/e you need to do and if you have any advice or know of a better way to do this please tell me. Also I want to be able to do all of this from my channel.<br><div class="codebox"><p>Code: </p><pre><code>#mysql sever infoset host "HOST"set user "username"set passwd "passwd"set db "Database"#make sure you have the right packagepackage require mysqltcl#set the database file set streamers "scripts/stms.txt"    #bind your commands    bind pub - !addfeed add:feedbind pub - !delfeed del:feedbind pub - !feeds list:feedbind pub - !feed feed:feedif {![file exists $cmdsfile]} { set fileid [open $cmdsfile w] close $fileid}set feeds [list]foreach donecmd [split [read [set fileid [open $streamers]]][close $fileid] \n][unset fileid] { if {[string match -nocase "Stream name - *" $donecmd]} {  lappend feeds [lindex [split $donecmd] 3] }}proc add:feed {nick uhost hand chan text} {global streamers  if {$chan == "#sops"} {  set fs [open $streamers a]  set name [lindex $text 0]  set url [join [lrange [split $text] 1 end]]  puts $fs "Stream name: $name Stream URL: $url"  close $fs  }}proc del:feed {nick uhost hand chan text} {global streamers  if {$chan == "#sops"} {  set fs [open $streamers "r"]  set data [read -nonewline $fs]  close $fs  set lines [split $data "\n"]  set name [lindex $text 0]  set match "Stream name - $name"  while {[set i [lsearch -glob $lines $match]]&gt;-0} {    set lines [lreplace $lines $i $i]    set fs [open $streamers a]    puts $fs [join $lines "\n"]    close $fs    }  }}proc list:feed {nick uhost hand chan text} {global allcommands  if {$chan == "#sops"} {    if {[llength $feeds]} {      puthelp "privmsg $chan :Available Streamers: [join $feeds {, }]"    } {      puthelp "privmsg $chan :No Available Streamers"    }  }}proc feed:feed { nick uhost chan handle arg } {global host user passwd db  if {$chan == "#sops"} {    if {isop $nick $chan} {     set stream [lindex $text 0]    set feed [list]foreach donecmd [split [read [set fileid [open $streamers]]][close $fileid] \n][unset fileid] { if {[string match -nocase "$stream Stream URL - *" $donecmd]} {  lappend feed [lindex [split $donecmd] 3] }}set con [::mysql::connect -host $host -user $user -password $passwd]  ::mysql::use $con $db::mysql::exec $con "UPDATE `streameronline` SET `StreamerUSC` = 'http://ustream.tv/e06,Q7h6Mbuey8aOxTltiQUyBKjIDFx4.usc'"puthelp "privmsg #sops :Update successfull"        putlog "Update successfull"      ::mysql::close $con             }      }    }putlog "Script loaded: Stream Switcher"</code></pre></div><p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=10253">SL0RD</a> — Mon Nov 17, 2008 10:17 pm</p><hr />
]]></content>
	</entry>
	</feed>
