Seen: unicode safety
This commit is contained in:
		
							parent
							
								
									713fb3e94a
								
							
						
					
					
						commit
						56bd5a687b
					
				| @ -60,7 +60,7 @@ class Seen(Module): | ||||
|             db = self.get_db() | ||||
|             cur = db.cursor() | ||||
|             statement = 'REPLACE INTO seen_nicks (nick, host, what) VALUES (?, ?, ?)' | ||||
|             cur.execute(statement, (nick, userhost, what)) | ||||
|             cur.execute(statement, (nick, userhost, what.decode('utf-8', 'replace'))) | ||||
|             db.commit() | ||||
|         except sqlite3.Error as e: | ||||
|             db.rollback() | ||||
| @ -77,7 +77,7 @@ class Seen(Module): | ||||
|                 result = cursor.fetchone() | ||||
|                 if result: | ||||
|                     seentime = datetime.strptime(result['time'], '%Y-%m-%d %H:%M:%S').replace(tzinfo=tzutc()) | ||||
|                     replystr = 'last saw {0:s} at {1:s} saying \'{2:s}\''.format(result['nick'], seentime.astimezone(tzlocal()).strftime('%Y/%m/%d %H:%M:%S %Z'), result['what']) | ||||
|                     replystr = 'last saw {0:s} at {1:s} saying \'{2:s}\''.format(result['nick'], seentime.astimezone(tzlocal()).strftime('%Y/%m/%d %H:%M:%S %Z'), result['what'].encode('utf-8', 'ignore')) | ||||
|                     return self.reply(connection, event, replystr) | ||||
|             except sqlite3.Error as e: | ||||
|                 db.rollback() | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user