« first day (515 days earlier)      last day (2894 days later) » 

11:01 AM
Plop!
 
11:49 AM
@Sam have few minutes?
 
Sam
@AshishAhujaツ I will in 10-15 mins.
 
Oh np. I have to go in 10 mins. I'll ask you tonight or tomorrow. Thanks.
 
Sam
Ok
 
Sam
Cya
 
 
1 hour later…
Sam
1:20 PM
@Gunr Can I borrow your eyes for a couple of mins?
 
yep
 
Sam
Great. So I'm messing around with npgsql on a simple table (just two columns).
 value |   idf
-------+---------
 and   | 2.53774
 to    |  1.0892
 the   |  2.3292
 want  |   9.327
 it    |       2
 good  |   0.302
^ An example
If I execute SELECT * FROM mytable; via psql I get the right results.
However, doing this from C# returns nothing:
var cmdStr = "SELECT * FROM myTable;";

using (var con = new NpgsqlConnection(connectionString))
using (var cmd = new NpgsqlCommand(cmdStr, con))
{
  con.Open();

  var reader = cmd.ExecuteReader();

  ...
}
 
quotes
your table name has a capital in it
wrap the object name (table name) in double quotes
or change the table to not have caps
 
Sam
Ah, right
 
so it depends on how you created the table
if you forced using caps or not
 
Sam
1:29 PM
CREATE TABLE IF NOT EXISTS GlobalTerms
GlobalTerms is the actual name of the table.
So I guess it's actually all lowercase.
 
if you use the all-lower-case version in code, what happens?
an error about the name or 0 rows?
 
Sam
Still 0 rows
 
> I’ve discovered over the years that while PGAdmin might be a useful and friendly way to manage your databases, it also automatically uses double quotes when creating tables. This means that if you create a table with PGAdmin, you might find yourself struggling to find or query it afterwards.
 
Sam
^ Never seen this before.
 
hum...
 
Sam
1:33 PM
Oh
And
 
dumb question, you do have rows in the table right?
 
Sam
If I use an NpgsqlDataAdapter instead, I can see the rows.
 
oh
 
Sam
@gunr2171 Yep
 
well ok
you might also want to look at using a DataSet (dumping results into it), easier to view the data
 
Sam
1:34 PM
Hmm
 
@Sam well that should be the correct way to go
 
Sam
@gunr2171 But I thought that would dump everything into memory.
Which I'm trying to avoid.
 
ok, so you're just going to read the stream one entry at a time
that should work
 
Sam
public IEnumerator<Dictionary<string, object>> GetEnumerator()
{
  // rd is the NpgsqlDataReader passed in from the constructor.
  while (rd.Read())
  {
    yield return GetRow();
  }
}

private Dictionary<string, object> GetRow()
{
  var row = new Dictionary<string, object>();

  for (var i = 0; i < rd.FieldCount; i++)
  {
    row[rd.GetName(i)] = rd.GetValue(i);
  }

  return row;
}
^ That's how I'm iterating over the rows.
(In a separate class)
 
GetEnumerator? Are you making a class that inherits from IEnumerable?
 
Sam
1:39 PM
@gunr2171 With the data adapter?
@gunr2171 Yes
I cut out the boilerplate code in the snippet.
 
why inherit? Why not make a method that returns an IEnumerable and use yield return within?
 
Sam
I... never thought of that.
 
let me write up an example....
 
Sam
Ok
 
class DatabaseAccessor
{
	private string ConnectionString {get;set;}

	public DatabaseAccessor(string connectionString)
	{

	}

	public IEnumerable<YourObject> EnumEntries()
	{
		var sqlQuery = "select * from globalterms;";

		using (var connection = new NpgsqlConnection(ConnectionString))
		using (var command = new NpgsqlCommand(sqlQuery, connection))
		{
			connection.Open();

			var reader = ....

			foreach(var entry in <your reader>)
			{
				//parse the row into some object
				YourObject parsedObject = new YourObject();
(forgot to set the variable in the constructor)
 
Sam
1:48 PM
And var reader = .... == var reader = command.ExecuteReader();?
 
I think so
 
Sam
Ok, thanks! :)
 
then use something to iterate though the reader
that's what you use in the foreach
 
Sam
Yeah
 
but that should be much cleaner than implementing your own IEnumerable
 
Sam
1:50 PM
Right
I'll have to remember that for future use.
It works :D
Awesome
Thanks again @gunr.
 
woot!
no problem
 
2:20 PM
Hiya!
 
Sam
Hey
 
@Sam Have a few minutes now?
 
Sam
Yep
 
Um well... I had this dumb question when I was implementing the privilege system for the bot
I know that you have to manually add the user id's to some file and always check them etc etc but
Whenever a user posts a message, I didn't get how you can find the user id of the person posting the message. Do you know how?
 
Sam
It's easy if you're listening to the websocket.
But I don't know how you're watching chat.
Or anything about your chat library.
 
2:25 PM
Okay. I'll tell you how the bot does that. Just lemme open the files. 2 mins
 
Sam
Ok, no rush.
 
PLOT TWIST, I AM THE TROLL!!
3
 
Sam
TIL gunr is 6 yo.
 
@Sam Yeah. Here is how we're getting the messages:
 
I'm 6 years old in chat bot years
 
Sam
2:30 PM
ofc
With 1 chatbot year ~= 4 earth years?
 
The main has a never ending for loop which only ends when we command it to
 
That'd mean that I'm 5,25 years old ô.ô
 
@Sam don't know. not awake enough to do mental math
 
The loop calls a function which basically gets the message using a function.
 
Sam
@AshishAhujaツ Sounds like you're polling.
Can you link to the source?
 
2:33 PM
Yup. Do you want the repo, or the functions I'm talking about?
 
Sam
Just the functions please.
 
Sure.
The function runChatBot which is being called by main.
 
Sam
Reading...
 
The function processChatRoomEvents which gets the messages using CURL
^^ and is also called by runChatBot
Oh sorry. That link is wrong.
 
Sam
Yeah, I was going to ask where processChatRoomEvents was defined.
 
Sam
Thanks
 
And when runChatBot get's the message, it calls processMessage github.com/NobodyNada/chatbot/blob/master/chatbot/…
I don't think it is related to this, but just in case
 
Sam
And where is poll defined? xD
 
poll? In which function is it??
 
2:39 PM
Nobody worked on this part, so I'm not very good with it. I mainly implemented the commands.
thanks
 
Sam
Oh, ok.
Hmm
 
Oh poll! That's a standard library function
include in poll.h
 
Sam
Ah
Sorry, my C/C++ isn't great. lol
 
np. Even I'm not really good in websockets.
 
Sam
Ok, well I'm struggling to read this.
I'll just tell ya what I know.
 
2:43 PM
No problem. I think an explanation will be enough
 
Sam
Every message posted in a chat room will have a user_id field in the JSON (when you're listening via the websocket). This is the ID of the message's author.
 
Sam
All you need to do is parse this field.
 
Then I think I can get it using the the cJSON file's functions.
Lemme check it out.
Thanks
 
Sam
Np
Sorry I couldn't actually do anything xD
 
2:48 PM
Na na. You've helped me. I didn't know this, and Nobody isn't coming anytime soon, so then I would've just been stuck doing nothing
 
Sam
Ok
 
I think I've got it. All I need to do is get the json, and do cJSON_GetObjectItem(event, "user_id")->valueint;
Thanks. Now I can make the privilege system
 
Sam
\o/
 
Can't understand why I didn't get this earlier. Just one single line :P
Thanks for your time!
 
3:17 PM
Night o/!
 
Sam
Cya
 
 
5 hours later…
8:13 PM
Hello everyone! (nagato v2 docker)
 
@Sam so you know, closey takes a long time to start up on the Joining room step.
 
Sam
Yep
 
it seems to scale on the number of people in the room
 
Sam
Ye​p
 
: (
@Closey status
 
8:14 PM
SOCVR Chatbot, running at nagato v2 docker, version 951ae800 on master, running for 1 minute and 8 seconds (tracking latency 1000ms).
 
Sam
May 26 at 20:52, by Sam
@gunr2171 Use .JoinRoom("url", true); for a quicker room joining time.
but
 
hum
 
Sam
Ping stripping will fail for the first few mins (or however long it takes to init the users list).
 
hum. ok
@Closey stop bot
 
@gunr2171 I'm shutting down...
Goodbye! (nagato v2 docker)
 
8:18 PM
well, time to start in the main room and try again
 
oh, side note: it was Undo who caused the PK_ProfileId error from yesterday
so maybe it's moderator related
 
Sam
Hmm
 
8:34 PM
\o/
 
9:21 PM
perfect
 

« first day (515 days earlier)      last day (2894 days later) »