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.

add text to database from text on irc

Help for those learning Tcl or writing their own scripts.
Post Reply
User avatar
Fire-Fox
Master
Posts: 299
Joined: Sat Sep 23, 2006 9:01 pm
Location: /dev/null

add text to database from text on irc

Post by Fire-Fox »

Hey!

How do i get tcl to add specific text to database if it has i unique ending

Note: there is no trigger "!"

like :

Code: Select all

some.text.here-endning1
some.text.here-endning2
GreatZ
Fire-Fox | Denmark

Scripts: Relay | Store Text | TvMaze
n
nml375
Revered One
Posts: 2860
Joined: Fri Aug 04, 2006 2:09 pm

Post by nml375 »

I'll try my best to interpret your query, but to be honest, I'm not even sure I'm remotely close to what you are really asking about...

1). You'd like some action to be triggered if a spoken line of text (in a channel or private msg?) ends with a certain word?

2). You'd like some action to be triggered if a spoken line of text (in a channel or private msg?), whose last word is not yet present in some kind of database;
2:a). An SQL-database such as MySQL, PostgreSQL, MSQL, etc.
2:b). A simple Tcl-list or dict.
2:c). A textfile on the filesystem (using some format like csv).

3). ??
NML_375
User avatar
Fire-Fox
Master
Posts: 299
Joined: Sat Sep 23, 2006 9:01 pm
Location: /dev/null

Post by Fire-Fox »

1). You'd like some action to be triggered if a spoken line of text (in a channel or private msg?) ends with a certain word?

- Channel

2). You'd like some action to be triggered if a spoken line of text (in a channel or private msg?), whose last word is not yet present in some kind of database :

- Yes action on the ending off a text like : -html / -php (just example)

2:a). An SQL-database such as MySQL, PostgreSQL, MSQL, etc.

- Mysql (have mysqltcl


2:b). A simple Tcl-list or dict.

- What ? dont understand

I have replied to the questions as good as i could :)
GreatZ
Fire-Fox | Denmark

Scripts: Relay | Store Text | TvMaze
n
nml375
Revered One
Posts: 2860
Joined: Fri Aug 04, 2006 2:09 pm

Post by nml375 »

So it's interpretaton 2:a then...

Use the pubm-binding to catch all channel chatter.
Extract the last word; possibly using split/lindex or regexp patterns?
Build an SQL-query using this word somewhat similar to this:

Code: Select all

set query "SELECT COUNT(*) FROM `database`.`table` WHERE `table`.`field` = '[mysql::escape $varHoldingTheWord]'"
Execute the query and fetch the result.
If the result is larger then 0, there is atleast one match already present in the database, otherwise there was no matches.
NML_375
User avatar
Fire-Fox
Master
Posts: 299
Joined: Sat Sep 23, 2006 9:01 pm
Location: /dev/null

Post by Fire-Fox »

Thanks for the reply!

Well you almost right (or i miss guided you, sorry)

The text thats written on channel should be stored in database, with a giving ending from a switch or some kind...

hope this clear it a little better
GreatZ
Fire-Fox | Denmark

Scripts: Relay | Store Text | TvMaze
n
nml375
Revered One
Posts: 2860
Joined: Fri Aug 04, 2006 2:09 pm

Post by nml375 »

Thus, if the result mentioned in my previous post is 0, issue a new SQL-query with an INSERT command.
But honestly, given the number of posts/threads regarding mysql queries, I figured you had that part covered already.
NML_375
Post Reply