1- from collections import deque
2- import time
31import asyncio
42import re
3+ import time
4+ from collections import deque
55
66from sqlalchemy import Table , Column , String , PrimaryKeyConstraint
77
88from cloudbot import hook
9- from cloudbot .util import timeformat , database
109from cloudbot .event import EventType
10+ from cloudbot .util import timeformat , database
1111
1212table = Table (
1313 'seen_user' ,
@@ -83,7 +83,7 @@ def resethistory(event, conn):
8383
8484
8585@hook .command ()
86- def seen (text , nick , chan , db , event ):
86+ def seen (text , nick , chan , db , event , is_valid_nick ):
8787 """<nick> <channel> - tells when a nickname was last in active in one of my channels
8888 :type db: sqlalchemy.orm.Session
8989 :type event: cloudbot.event.Event
@@ -96,14 +96,14 @@ def seen(text, nick, chan, db, event):
9696 if text .lower () == nick .lower ():
9797 return "Have you looked in a mirror lately?"
9898
99- if not re . match ( "^[A-Za-z0-9_|\^\*\`.\-\]\[\{\} \\ \\ ]*$" , text . lower () ):
99+ if not is_valid_nick ( text ):
100100 return "I can't look up that name, its impossible to use!"
101101
102102 if '_' in text :
103103 text = text .replace ("_" , "/_" )
104104
105- last_seen = db .execute ("select name, time, quote from seen_user where name like :name escape '/' and chan = :chan" ,
106- {'name' : text , 'chan' : chan }).fetchone ()
105+ last_seen = db .execute ("SELECT name, time, quote FROM seen_user WHERE name LIKE :name ESCAPE '/' AND chan = :chan" ,
106+ {'name' : text , 'chan' : chan }).fetchone ()
107107
108108 text = text .replace ("/" , "" )
109109
0 commit comments