<commit_before>"""Checks if someone has posted a link already and yells at them.
@package ppbot

"""
import re
from datetime import datetime

from dateutil.relativedelta import relativedelta


from sqlalchemy import Table, Column, Integer, String, MetaData, ForeignKey, DateTime, Text, func
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy.orm import relationship, backref

from modules import *
from models import Model

Base = declarative_base()
class Url(Base, Model):
    __tablename__ = 'urldupe_urls'

    id = Column(Integer, primary_key=True)
    url = Column(Text, nullable=False)
    time = Column(DateTime, default=func.now())
    username = Column(String(50), nullable=False)
    channel = Column(String(50), nullable=False)

    def __init__(self, **kwargs):
        Model.__init__(self)
        Base.__init__(self)
        self.metadata = Base.metadata

        for name, val in kwargs.iteritems():
            self.__setattr__(name, val)

    def __repr__(self):
        return "<Url: %s, %s, %s>" % (self.url, self.username, self.channel)

    def get_dupes(self, **kwargs):
        """Checks if URL is in the database."""

        return self.session.query(Url).filter_by(
                    url=self.url, channel=self.channel
                ).order_by(Url.time).all()


class Urldupe(Module):
    
    def __init__(self, *args, **kwargs):
        """Constructor"""
        
        Module.__init__(self, kwargs=kwargs)
        
        self.url_pattern = re.compile('http://[^ ]+')

    def _register_events(self):
        self.add_event('pubmsg', 'urldupe')
        
    def urldupe(self, event):
        """Action to react/respond to chat messages."""
        
        m = self.url_pattern.search(event['message'])

        if m:
            # check if this url has been posted before
            url = Url(
                url=m.group(0),
                username=event['nick'],<commit_msg>whitespace.<commit_after>"""Checks if someone has posted a link already and yells at them.
@package ppbot

"""
import re
from datetime import datetime

from dateutil.relativedelta import relativedelta


from sqlalchemy import Table, Column, Integer, String, MetaData, ForeignKey, DateTime, Text, func
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy.orm import relationship, backref

from modules import *
from models import Model

Base = declarative_base()
class Url(Base, Model):
    __tablename__ = 'urldupe_urls'

    id = Column(Integer, primary_key=True)
    url = Column(Text, nullable=False)
    time = Column(DateTime, default=func.now())
    username = Column(String(50), nullable=False)
    channel = Column(String(50), nullable=False)

    def __init__(self, **kwargs):
        Model.__init__(self)
        Base.__init__(self)
        self.metadata = Base.metadata

        for name, val in kwargs.iteritems():
            self.__setattr__(name, val)

    def __repr__(self):
        return "<Url: %s, %s, %s>" % (self.url, self.username, self.channel)

    def get_dupes(self, **kwargs):
        """Checks if URL is in the database."""

        return self.session.query(Url).filter_by(
                    url=self.url, channel=self.channel
                ).order_by(Url.time).all()


class Urldupe(Module):

    def __init__(self, *args, **kwargs):
        """Constructor"""

        Module.__init__(self, kwargs=kwargs)

        self.url_pattern = re.compile('http://[^ ]+')

    def _register_events(self):
        self.add_event('pubmsg', 'urldupe')

    def urldupe(self, event):
        """Action to react/respond to chat messages."""

        m = self.url_pattern.search(event['message'])

        if m:
            # check if this url has been posted before
            url = Url(
                url=m.group(0),
                username=event['nick'],
{'fraction_non_alphanumeric': 0.11867501304121023, 'fraction_numerical': 0.0026082420448617634, 'mean_word_length': 2.782051282051282, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '612253', 'n_tokens_mistral': 1168, 'n_tokens_neox': 1120, 'n_words': 305}