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 

String tolower

 
Post new topic   Reply to topic    egghelp.org community Forum Index -> Scripting Help
View previous topic :: View next topic  
Author Message
Buffy_25
Halfop


Joined: 22 Nov 2003
Posts: 63

PostPosted: Mon Dec 19, 2005 2:47 pm    Post subject: String tolower Reply with quote

Hi,

I have a problem with the following code.
When a user joins and leaves after a certain period, i add (if not created yet in mysql-DB) or update his uptime in mysql-DB (if already created).

My problem is, when a person leaves (i.e. MaRkO) and he was already created as marko, then the database will create a new user in stead of updating his actual ID.

Does any one have an idea why the string tolower isn't working?

Thanks.

Buffy

Code:

proc userleft {nick uhost hand dest key arg} {
set fs1 [open /home/account/eggdrop/logs/timeon.txt a+]
puts $fs1 "$arg"
close $fs1
set user [lindex [split $arg] 0]
set time [join [lrange $arg 1 end]]
mysql_connect datab localhost account passw /var/lib/mysql/mysql.sock
set listuser [mysql_query "SELECT name FROM Userinfo"]
foreach a $listuser {
 lappend list1 [string tolower $a]
 }
 if {[lsearch -exact $list1 [string tolower $user]] == -1} {
   set insert_command [mysql_query "INSERT INTO Userinfo (name) VALUES ('$user')"]
   set newtime [mysql_query "UPDATE Userinfo SET timeon='$time' WHERE name='$user'"]
   set time [convert_online $time]
   set timesec [mysql_query "UPDATE Userinfo SET timeonsec='$time' WHERE name='$user'"]
  } else {
  set presenttime [mysql_query "SELECT timeon FROM Userinfo WHERE name='$user'"]
  set convpresenttime [convert_online $presenttime] #the convert_online is working ok !
  set convuseronline [convert_online $time]
  set useronline [expr $convuseronline+$convpresenttime]
  set onlinetime [duration $useronline]
  set newtime [mysql_query "UPDATE Userinfo SET timeon='$onlinetime' WHERE name='$user'"]
  set newtime [mysql_query "UPDATE Userinfo SET timeonsec='$useronline' WHERE name='$user'"]
 }
}
Back to top
View user's profile Send private message
Sir_Fz
Revered One


Joined: 27 Apr 2003
Posts: 3793
Location: Lebanon

PostPosted: Mon Dec 19, 2005 4:59 pm    Post subject: Reply with quote

string tolower is not applied on all the $user variables in your code. Why don't you initialize it as lower case
Code:
set user [string tolower [lindex [split $arg] 0]]

_________________
Follow me on GitHub

- Opposing

Public Tcl scripts
Back to top
View user's profile Send private message Visit poster's website
Buffy_25
Halfop


Joined: 22 Nov 2003
Posts: 63

PostPosted: Tue Dec 20, 2005 4:23 pm    Post subject: Reply with quote

Hi Sir_Fz,

This could be an option, but the problem is that my variables are used kindly everywhere in my scripts, and i would prefer to avoid to modify whole my scripts.
Therefor i tried to keep my nicks as they are, but just wanted to check between the nick registered in database and the nick that left.

Is there a way that i could make it being applied to all the variables?

Thanks.

Buffy
Back to top
View user's profile Send private message
Sir_Fz
Revered One


Joined: 27 Apr 2003
Posts: 3793
Location: Lebanon

PostPosted: Tue Dec 20, 2005 4:40 pm    Post subject: Reply with quote

If the variable isn't global, you can only apply string tolower inside the proc.
_________________
Follow me on GitHub

- Opposing

Public Tcl scripts
Back to top
View user's profile Send private message Visit poster's website
Buffy_25
Halfop


Joined: 22 Nov 2003
Posts: 63

PostPosted: Sat Dec 24, 2005 4:16 am    Post subject: Reply with quote

I found the problem Sir_Fz ! Smile

Thanks for the notice !

Buffy
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 -> Scripting Help 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