Commit Graph

12 Commits

Author SHA1 Message Date
c1439ca4c5 useless: remove .abuse trigger 2021-08-17 14:12:38 +00:00
noxy
be2d9ab27f Update bot/useless.py 2021-05-12 18:41:54 +00:00
noxy
c1be5ee2af hebamme command 2021-05-12 18:34:06 +00:00
noxy
ade97db922 useless: add vampir trigger 2020-11-20 16:50:26 +00:00
2d41d0c0bb useless: add corona trigger 2020-05-01 23:19:31 +00:00
80cfa2f815 useless: fix syntax warning
storage: shorten code
2020-03-16 22:04:29 +00:00
e03f5d0a43 add auto reconnect for postgres
This only works on the second database interaction, since psycopg2 only notices that
the connection is gone, when a query is executed.

So in the common case reconnect works as follows:
- some bot method calls a cursor function like .execute(), .fetchone(), etc.
  - this raises an error if the connection is broken
  - if following code then requests a new cursor, this will also fail since psycopg2
    now knows that the connection is gone
  - the error is caught in storage.DBConn.cursor(), a new connection will be set up
    of which a new cursor is yielded
If the error happens in connection.commit() or .rollback() instead we can instantly
reconnect since these methods are wrapped.

So why not wrap the cursor methods as well?
Consider the following example:
A query is the last thing that was executed on a cursor.
The database connection is lost.
Now .fetchone() is called on the cursor.
We could wrap .fetchone() and reconnect, but we'd have to use a new cursor since
cursors are linked to connections. And on this new cursor .fetchone() wouldn't
make any sense, since we haven't executed a query on this cursor.
2020-03-16 21:51:32 +00:00
Flummi
9388a39291 lowfry deep fried 2019-07-16 13:47:19 +00:00
1dac1571e2 remove +R, add +B on connect
add .iframe command
2018-12-10 16:04:59 +00:00
c36569d33d
fix ree regex 2018-08-14 12:52:58 +02:00
6b1c3a4e8f
add a lot of useless and ascii commands 2018-08-14 01:07:57 +02:00
mrhanky
f33a17038a
Huge cleanup and refactoring :> 2017-08-22 17:43:48 +02:00