Пример #1
0
 def send_spam(self, server, nick, user, host, target, msg):
     if host in self.pmed or target.lower() in self.excpt: 
         return
 
     msg = choice(self.db)
     self.pmed.append(host)
     send_msg(server, nick, msg)
Пример #2
0
    def run(self, server, nick, user, host, target, msg, lang, code):
        url, output = libpad.sandbox(code, lang)

        if len(output) <= self.max_width:
            send_msg(server, target, output)
        else:
            send_msg(server, target, url)
Пример #3
0
 def list_folder(self, server, nick, user, host, target, msg):
     """
     """
     content = '\n'.join(os.listdir(self.folder))
 
     url, _ = libpad.sandbox(content, '') 
     send_msg(server, target, url)
Пример #4
0
def send_file(con, nick, user, host, target, msg):
    if not msg.startswith('.send'):
        return

    cmd, filename, port = msg.split(' ')
    resource = '%s/%s' % (FOLDER, filename)
    size = getsize(resource)
    fd = open(resource, 'rb')

    def is_done(msg):
        send_msg(con, nick, msg)
        fd.close()

    try:
        dcc = DccServer(fd, int(port), timeout=50)
    except Exception:
        is_done('Couldnt list on the port!')
        raise

    dcc.add_map(DONE, lambda *args: is_done('Done.'))
    dcc.add_map(CLOSE, lambda *args: is_done('Failed!'))
    dcc.add_map(ACCEPT_ERR, lambda *args: is_done("Accept error!"))
    dcc.add_map(TIMEOUT, lambda *args: is_done('TIMEOUT!'))

    HEADER = '\001DCC SEND %s %s %s %s\001'
    request = HEADER % (filename, ip_to_long(con.myaddr), port, size)
    send_msg(con, nick, request)
Пример #5
0
def check_file_existence(con, xxx_todo_changeme, filename, address, port,
                         size):
    (nick, user, host, target, msg) = xxx_todo_changeme
    resource = '%s/%s' % (FOLDER, filename)
    if isfile(resource):
        send_msg(con, nick, 'File already exists.')
    else:
        recv_file(con, nick, resource, address, port, size)
Пример #6
0
 def note_del(self, server, nick, user, host, target, msg, peer):
     peer = peer.lower()
     msgs = self.base.get(peer, [])
     orig_len = len(msgs)
     msgs = [m for m in msgs if m.source[1:] != (user, host)]
     if msgs: self.base[peer] = msgs
     elif peer in self.base: del self.base[peer]
     send_msg(server, target or nick, '%s: %d notes deleted.' % (
         nick, orig_len - len(msgs)))
Пример #7
0
 def check(self, server, nick, user, host, target, msg):
     struct = search(REG_LINK, msg)
     if not struct: 
         return
     req   = requests.get(struct.group('address'))
     html  = Html()
     dom   = html.feed(req.text)
     title = dom.fst('title').text()
     send_msg(server, target, title)
Пример #8
0
    def drop_msg(self, area, wid, target):
        """
        Drop msgs and update the areavi.
        """

        data = wid.get()
        area.append(H1 % (self.misc.nick, data))
        send_msg(self.con, target, data)
        wid.delete(0, 'end')
Пример #9
0
    def build(self, server, nick, user, 
                    host, target, msg, exp):

        try:
            data = str(run(exp))
        except Exception as e:
            send_msg(server, target, str(e))
        else:
            send_msg(server, target, post(data, 
                'Math formulae', 'Ameliabot'))
Пример #10
0
    def check(self, server, nick, user, host, target, msg, peer):
        try:
            initial = self.database[peer.lower()] 
        except:
            send_msg(server, target, "No records for that nick.")
        else:
            final   = time.time()
            rate    = final - initial
            hour    = int(rate / (60 ** 2))
            rate    = int(rate % (60 ** 2))
            min     = int(rate / 60)
            sec     = int(rate % 60)

            send_msg(server, target, 
                '%s last seen %s:%s:%s ago.' % (peer, hour, min, sec))
Пример #11
0
    def send_auth(self, con):
        # It is what we use to send data. send_msg function uses
        # ssock.dump function to dump commands.
        SockWriter(con)
        SockReader(con)

        # This protocol spawns FOUND whenever it finds \r\n.
        Terminator(con)

        Irc(con)

        con.add_map(CLOSE, lambda con, err: lose(con))

        # Now, it basically means: when it '376' irc command is
        # issued by the server then calls self.auto_join.
        # We use auto_join to send the sequence of JOIN
        # commands in order to join channels.
        con.add_map('376', self.auto_join)

        # Below the remaining stuff follows the same pattern.
        con.add_map('JOIN', self.on_join)
        con.add_map('PING', self.on_ping)
        con.add_map('PART', self.on_part)
        con.add_map('376', self.on_376)
        con.add_map('NOTICE', self.on_notice)
        con.add_map('PRIVMSG', self.on_privmsg)
        con.add_map('332', self.on_332)
        con.add_map('001', self.on_001)
        con.add_map('001', self.on_002)
        con.add_map('003', self.on_003)
        con.add_map('004', self.on_004)
        con.add_map('333', self.on_333)
        con.add_map('353', self.on_353)
        con.add_map('366', self.on_366)
        con.add_map('474', self.on_474)
        con.add_map('302', self.on_302)

        send_cmd(con, 'NICK %s' % self.nick)
        send_cmd(con, 'USER %s' % self.user)
        send_msg(con, 'nickserv', 'identify %s' % self.password)
Пример #12
0
 def note_add(self, server, nick, user, host, target, msg, peer, data):
     msgs = self.base[peer.lower()]
     user_msgs = [m for m in msgs if m.source[1:] == (user, host)
                  or user.startswith('~') and m.source[2] == host]
     if len(user_msgs) + 1 > MAX_NOTES_PER_PEER:
         send_msg(server, target,
             '%s: you may leave no more than %d notes for "%s".' % (
             nick, MAX_NOTES_PER_PEER, peer))
     elif len(msgs) + 1 > MAX_NOTES:
         send_msg(server, target,
             '%s: there are too many notes saved for "%s".' % (
              nick, peer))
     else:
         msgs.append(Message(
             source=(nick,user,host), message=data))
         self.base[peer.lower()] = msgs
         send_msg(server, target,
         '%s: note for "%s" saved.' % (nick, peer))
Пример #13
0
def login(server, nick, user, host, target, msg, password):
    if password == server.adm_passwd:
        known.add(host)
        send_msg(server, nick, 'Logged!')
    else:
        send_msg(server, nick, 'Invalid password!')
Пример #14
0
def send_welcome(server, nick, user, host, channel):
        send_msg(server, channel, 'Welcome to our relaxed place !')
Пример #15
0
def listen(server, nick, user, target, msg, lang_x, lang_y):
    data = source.translate(msg, lang_x, lang_y) 
    send_msg(server, target, '%s %s' % (nick, data))
Пример #16
0
 def is_done(msg):
     send_msg(con, nick, msg)
     fd.close()
Пример #17
0
 def send_question(self, server, nick, user, host, channel):
     if not (host.lower() in self.pmed or nick.lower() in self.pmed): 
         Timer(randint(0, self.timeout), lambda : 
                         send_msg(server, nick, choice(self.questions)))
         self.register_user(self.pmed, self.pmed_file, nick, host)
Пример #18
0
	def getinfo(self, server, nick, user, host, target, msg, player):
		result = getPlayerInfo(player)
		send_msg(server,target,str(ircOutput(result)))
Пример #19
0
 def translate(self, server, nick, user, host, target, msg, lang1, lang2, data):
     data = self.google_translator.translate(data, lang1, lang2)
     send_msg(server, target, data)
Пример #20
0
 def check_answer(self, server, nick, user, host, target, msg):
     if (nick in self.pmed or host in self.pmed) and \
                        not (nick in self.blacklist or host in self.blacklist):
         Timer(randint(0, self.timeout), lambda : 
                          send_msg(server, nick, choice(self.suggestions)))
         self.register_user(self.blacklist, self.blacklist_file, nick, host)
Пример #21
0
def send(server, nick, user, host, target, msg, person, note):
        send_msg(server, person, note)
Пример #22
0
def pipe_chan(server, nick, user, host, target, msg,):
    chan_list = mapping.get((server, target.upper()))
    if not chan_list: return

    for ind in chan_list:
        send_msg(server, ind, '(%s)%s %s' % (target, nick, msg))
Пример #23
0
 def send_note(self, server, nick, user, host, channel):
     if nick.lower() not in self.base: return
     for msg in self.base[nick.lower()]:
         send_msg(server, channel, '%s: <%s> %s' % (
             nick, '%s!%s@%s' % msg.source, msg.message))
     del self.base[nick.lower()]
Пример #24
0
 def check_msg(self, server, nick, user, host, target, msg):
     if search(self.pattern, msg): 
         send_msg(server, target, self.make_seq())
Пример #25
0
 def send_quote(self, server, nick, user, host, target, msg):    
     quote = choice(self.data)
     send_msg(server, target, quote)