예제 #1
0
def announce(prefix, chan, params):

    for ch in bot.chans:

        bot.say(ch, '%s: %s' % (style.color('Ann', style.RED), ' '.join(params)))
예제 #2
0
    def parse_loop(self):
        while self.connected:
            msg = self.iqueue.get()

            if msg == StopIteration:
                self.connect()
                continue

            if self.debug and msg: print(msg)

            regex = re.compile(
                r'(?::(([^@! ]+)!?([^@ ]+)?@?([^ ]+)?))? ?([^ ]+) ?([^: ]*) :?(.*)?'
            )

            try:
                prefix, nick, ident, host, type, chan, message = re.findall(
                    regex, msg)[0]

            except:
                continue

            message = style.remove(message)

            params = re.findall(r'(?<=")\w[^"]+(?=")|[^" ]+', message)

            # do response waiting
            for waiting in self.waiting:
                if type in waiting['keys']:
                    if waiting['prefix'] and not self.match(
                            waiting['prefix'], prefix):
                        continue
                    if waiting['chan'] and not self.match(
                            waiting['chan'], chan):
                        continue
                    if waiting['message'] and not self.match(
                            waiting['message'], message):
                        continue

                    waiting['values'].append([(nick, ident, host), chan,
                                              params])

                    if type not in waiting['end']: break

                if type in waiting['end'] and waiting['values']:
                    self.waiting.remove(waiting)

                    break

            # do events

            if type in self.events:
                for func in self.events[type]:
                    # must be performed in specific channel
                    if hasattr(func, '_channel'):
                        if getattr(func, '_channel') != chan:
                            continue

                    self.thread(func, ((nick, ident, host), chan, params))

            # do commands
            if type == 'PRIVMSG' and params and params[0].startswith(
                    self.config.get('prefix', '$')):
                command = params[0][1:]

                params.pop(0)

                ignore = self.config.get('ignore', [])

                if command in self.commands and not self.match(ignore, prefix):
                    if chan != self.config.get('log'):
                        self.log('%s %s called by %s in %s (%s)' %
                                 (style.color('Command:', style.GREEN),
                                  command, nick, chan, ', '.join(params)))

                    if chan == self.nick:
                        chan = nick

                    for func in self.commands[command]:
                        self.thread(
                            self.command,
                            (func, chan, prefix, nick, ident, host, params))

        print('Exited parse loop.')
예제 #3
0
#--------------------------------------------------#

import sys
import json
import optparse
import urllib2
from json import loads
from urllib2 import (Request, urlopen, URLError, HTTPError, unquote)
from pprint import pprint
sys.path.append("app/")
from settings import option
from style import color

(folder, thumb, tag, team, announce, tmdb_api_key, tag_thumb) = option()

(BLUE, RED, YELLOW, GREEN, END) = color()

def main():

    #___ HELP ___#
    usage = "./genprez.py LANGUAGE QUALITY CODECS SUBS SIZE ID_IMDB"
    parser = optparse.OptionParser(usage = usage)
    (options, args) = parser.parse_args()
    if (len(args) != 6):
        parser.print_help()
        parser.exit(1)

    #___ VALUES ___#
    lang = sys.argv[1]
    qualite = sys.argv[2]
    format = sys.argv[3]
예제 #4
0
    def parse_loop(self):

        while self.connected:
            msg = self.iqueue.get()

            if msg == StopIteration:
                self.connect()

                continue

            if self.debug and msg: print(msg)

            regex = re.compile(r'(?::(([^@! ]+)!?([^@ ]+)?@?([^ ]+)?))? ?([^ ]+) ?([^: ]*) :?(.*)?')

            try:
                prefix, nick, ident, host, type, chan, message = re.findall(regex, msg)[0]

            except: continue

            message = style.remove(message)

            params = re.findall(r'(?<=")\w[^"]+(?=")|[^" ]+', message)

            # do events

            if type in self.events:
                for func in self.events[type]:

                    # must be performed in specific channel

                    if hasattr(func, '_channel'):
                        if getattr(func, '_channel') != chan:
                            continue

                    self.thread(func, ((nick, ident, host), chan, params))

            # do commands

            if type == 'PRIVMSG' and params and params[0].startswith(self.config.get('prefix', '$')):
                command = params[0][1:]

                params.pop(0)

                ignore = self.config.get('ignore', [])

                if command in self.commands and not self.match(ignore, prefix):

                    if chan != self.config.get('log'):

                        self.log('%s %s called by %s in %s (%s)' % (
                            style.color('Command:', style.GREEN),
                            command,
                            nick,
                            chan,
                            ', '.join(params)
                            ))

                    if chan == self.nick:
                        chan = nick

                    for func in self.commands[command]:

                        # must or must not be a PM

                        if hasattr(func, '_pm'):
                            if getattr(func, '_pm'):
                                if chan.startswith('#'):
                                    continue

                            elif not chan.startswith('#'):
                                continue

                        # must be performed in specific channel

                        if hasattr(func, '_channel'):
                            if getattr(func, '_channel') != chan:
                                continue

                        # command can or must be diverted

                        where = chan

                        divert = self.config.get('divert', {})

                        if hasattr(func, '_divert'):
                            if chan in divert:
                                where = divert[chan]

                            if where not in self.chans:
                                continue

                        if hasattr(func, '_control'):
                            if not chan in divert or where not in self.chans:
                                continue

                        # admin perm overrides all

                        admin = self.config['perms'].get('admin', {})

                        if self.match(admin, prefix):
                            pass

                        # user must have permission, overrides flags

                        elif hasattr(func, '_perm'):
                            perm = getattr(func, '_perm')

                            if perm not in self.config['perms']:
                                continue

                            if not self.match(self.config['perms'][perm], prefix):
                                continue

                        # user must have specific flag(s)

                        elif hasattr(func, '_flags'):
                            self.perms_check.append({
                                'nick': nick,
                                'func': func,
                                'perm': getattr(func, '_flags'),
                                'chan': where,
                                'args': ((nick, ident, host), where, params)
                            })

                            self.do('WHO', where)

                            continue

                        self.thread(func, args=((nick, ident, host), where, params))

        print('Exited parse loop.')
예제 #5
0
파일: imgur.py 프로젝트: fajrconnect/AnkoA
#     Made with love by grm34 (FRIPOUILLEJACK)     #
#     [email protected] .......     #
# Greetz: thibs, Rockweb, c0da, Hydrog3n, Speedy76 #
#--------------------------------------------------#

import sys
import optparse
import urllib
import urllib2
import base64
import BeautifulSoup
from urllib2 import (urlopen, URLError, HTTPError)
sys.path.append("app/")
from style import color

(BLUE, RED, YELLOW, GREEN, END) = color()

usage = "./imgur.py /path/to/image.png"
parser = optparse.OptionParser(usage=usage)
(options, args) = parser.parse_args()
if (len(args) < 1 or len(args) > 2):
    parser.print_help()
    parser.exit(1)

try:
    img_file = open(sys.argv[1], "rb")
    img = base64.b64encode(img_file.read())
    url = 'http://api.imgur.com/2/upload'
    key = {'key': '02b62fd8f1d5e78321e62bb42ced459e', 'image': img}
    data = urllib.urlencode(key)
    req = urllib2.Request(url, data)
예제 #6
0
def get_submissions(num):

    global subs
    global resize

    r = praw.Reddit(user_agent='IRC SubWatch by /u/Dissimulate')

    try:

        r.refresh_access_information()

    except:

        print('Failed to refresh access information, exiting thread %s.' % num)

        return

    if r.user == None:

        print('Failed to auth, exiting thread %s.' % num)

        return

    print('Watch thread %s started.' % num)

    start = bot.load_time

    while not bot.connected and start == bot.load_time:

        time.sleep(3)

    while bot.connected and start == bot.load_time:

        try:

            shrink.get_nowait()

            break

        except:
            pass

        names = []

        tocheck = {}

        while len(tocheck) < min(
                subs.qsize(), 25) and bot.connected and start == bot.load_time:

            sub = subs.get()

            if sub['name'] in todel:

                continue

            elapsed = time.time() - sub['checked']

            if elapsed < 30:

                subs.put(sub)

                time.sleep(2)

                continue

            elif elapsed > 60 and elapsed < 1400000000:

                print('DELAY: %s' % elapsed)

            names.append(sub['name'])

            tocheck[sub['name']] = sub

        if not len(tocheck):

            time.sleep(5)

            continue

        try:

            new_threads = []

            multisub = r.get_subreddit('+'.join(tocheck.keys()))

            for sub in tocheck:

                tocheck[sub]['checked'] = time.time()

            for thread in reversed(
                    list(multisub.get_new(limit=len(tocheck) * 4))):

                sub = thread.subreddit.display_name

                if thread.created_utc > tocheck[sub.lower()]['thread']:

                    new_threads.append(thread)

                    tocheck[sub.lower()]['thread'] = thread.created_utc

            for thread in new_threads:

                sub = thread.subreddit.display_name

                prefix = 'Self post:' if thread.is_self else 'Link post:'

                message = '%s "%s" posted in /r/%s by %s. %s%s' % (
                    style.color(prefix, style.GREEN), thread.title, sub,
                    thread.author, thread.short_link,
                    style.color(' NSFW', style.RED) if thread.over_18 else '')

                for chan in bot.config['watch'][sub.lower()]:

                    if chan in bot.config['stopped']: continue

                    # channel has keywords set

                    if len(bot.config['watch'][sub.lower()][chan]):

                        words = bot.config['watch'][sub.lower()][chan]

                        minus = [
                            x.lstrip('-') for x in words if x.startswith('-')
                        ]

                        if minus:

                            regex = re.compile(r'\b(%s)\b' % '|'.join(minus),
                                               re.I)

                            if re.search(regex, thread.title):

                                bot.say(chan, thread.title)

                                continue

                        plus = [
                            x.lstrip('+') for x in words if x.startswith('+')
                        ]

                        if plus:

                            regex = re.compile(r'\b(%s)\b' % '|'.join(plus),
                                               re.I)

                            if re.search(regex, thread.title):

                                def repl(match):

                                    return style.bold(match.group(0))

                                new_title = re.sub(regex, repl, thread.title)

                                bot.say(
                                    chan,
                                    message.replace(thread.title, new_title))

                    else:

                        bot.say(chan, message)

        except:

            traceback.print_exc()

            print('Failed to fetch new posts. %s' % time.strftime('%H:%M:%S'))

        for sub in tocheck:

            subs.put(tocheck[sub])

        time.sleep(2)
예제 #7
0
def announce(prefix, chan, params):

    for ch in bot.chans:

        bot.say(ch,
                '%s: %s' % (style.color('Ann', style.RED), ' '.join(params)))
예제 #8
0
파일: bot.py 프로젝트: Dissimulate/DissBot
    def parse_loop(self):
        while self.connected:
            msg = self.iqueue.get()

            if msg == StopIteration:
                self.connect()
                continue

            if self.debug and msg: print(msg)

            regex = re.compile(r'(?::(([^@! ]+)!?([^@ ]+)?@?([^ ]+)?))? ?([^ ]+) ?([^: ]*) :?(.*)?')

            try:
                prefix, nick, ident, host, type, chan, message = re.findall(regex, msg)[0]

            except: continue

            message = style.remove(message)

            params = re.findall(r'(?<=")\w[^"]+(?=")|[^" ]+', message)

            # do response waiting
            for waiting in self.waiting:
                if type in waiting['keys']:
                    if waiting['prefix'] and not self.match(waiting['prefix'], prefix):
                        continue
                    if waiting['chan'] and not self.match(waiting['chan'], chan):
                        continue
                    if waiting['message'] and not self.match(waiting['message'], message):
                        continue

                    waiting['values'].append([(nick, ident, host), chan, params])

                    if type not in waiting['end']: break

                if type in waiting['end'] and waiting['values']:
                    self.waiting.remove(waiting)

                    break

            # do events

            if type in self.events:
                for func in self.events[type]:
                    # must be performed in specific channel
                    if hasattr(func, '_channel'):
                        if getattr(func, '_channel') != chan:
                            continue

                    self.thread(func, ((nick, ident, host), chan, params))

            # do commands
            if type == 'PRIVMSG' and params and params[0].startswith(self.config.get('prefix', '$')):
                command = params[0][1:]

                params.pop(0)

                ignore = self.config.get('ignore', [])

                if command in self.commands and not self.match(ignore, prefix):
                    if chan != self.config.get('log'):
                        self.log('%s %s called by %s in %s (%s)' % (
                            style.color('Command:', style.GREEN),
                            command,
                            nick,
                            chan,
                            ', '.join(params)
                            ))

                    if chan == self.nick:
                        chan = nick

                    for func in self.commands[command]:
                        self.thread(self.command, (func, chan, prefix, nick, ident, host, params))

        print('Exited parse loop.')
예제 #9
0
def get_submissions(num):

    global subs
    global resize


    r = praw.Reddit(user_agent = 'IRC SubWatch by /u/Dissimulate')

    try:

        r.refresh_access_information()

    except:

        print('Failed to refresh access information, exiting thread %s.' % num)

        return


    if r.user == None:

        print('Failed to auth, exiting thread %s.' % num)

        return


    print('Watch thread %s started.' % num)


    start = bot.load_time


    while not bot.connected and start == bot.load_time:

        time.sleep(3)


    while bot.connected and start == bot.load_time:

        try:

            shrink.get_nowait()

            break

        except: pass


        names = []

        tocheck = {}


        while len(tocheck) < min(subs.qsize(), 25) and bot.connected and start == bot.load_time:

            sub = subs.get()

            if sub['name'] in todel:

                continue


            elapsed = time.time() - sub['checked']

            if elapsed < 30:

                subs.put(sub)

                time.sleep(2)

                continue

            elif elapsed > 60 and elapsed < 1400000000:

                print('DELAY: %s' % elapsed)


            names.append(sub['name'])

            tocheck[sub['name']] = sub


        if not len(tocheck):

            time.sleep(5)

            continue


        try:

            new_threads = []

            multisub = r.get_subreddit('+'.join(tocheck.keys()))


            for sub in tocheck:

                tocheck[sub]['checked'] = time.time()


            for thread in reversed(list(multisub.get_new(limit = len(tocheck) * 4))):

                sub = thread.subreddit.display_name

                if thread.created_utc > tocheck[sub.lower()]['thread']:

                    new_threads.append(thread)

                    tocheck[sub.lower()]['thread'] = thread.created_utc


            for thread in new_threads:

                sub = thread.subreddit.display_name

                prefix = 'Self post:' if thread.is_self else 'Link post:'

                message = '%s "%s" posted in /r/%s by %s. ( %s )%s%s' % (
                    style.color(prefix, style.GREEN),
                    thread.title,
                    sub,
                    thread.author,
                    thread.short_link,
                    '' if thread.is_self else (' [ %s ]' % thread.url),
                    style.color(' NSFW', style.RED) if thread.over_18 else ''
                )

                for chan in bot.config['watch'][sub.lower()]:

                    if chan in bot.config['stopped']: continue

                    # channel has keywords set

                    if len(bot.config['watch'][sub.lower()][chan]):

                        words = bot.config['watch'][sub.lower()][chan]

                        minus = [x.lstrip('-') for x in words if x.startswith('-')]

                        if minus:

                            regex = re.compile(r'\b(%s)\b' % '|'.join(minus), re.I)

                            if re.search(regex, thread.title):

                                bot.say(chan, thread.title)

                                continue

                        plus = [x.lstrip('+') for x in words if x.startswith('+')]

                        if plus:

                            regex = re.compile(r'\b(%s)\b' % '|'.join(plus), re.I)

                            if re.search(regex, thread.title):

                                def repl(match):

                                    return style.bold(match.group(0))

                                new_title = re.sub(regex, repl, thread.title)

                                bot.say(chan, message.replace(thread.title, new_title))

                    else:

                        bot.say(chan, message)

        except:

            traceback.print_exc()

            print('Failed to fetch new posts. %s' % time.strftime('%H:%M:%S'))


        for sub in tocheck:

            subs.put(tocheck[sub])

        time.sleep(2)
예제 #10
0
import requests
import style
from os import *

print(style.square("ip tracker", "red"))
print(" ")
print(style.line())
print(style.color("green"))
p = input("ip :")

system("clear")
print(style.color("green"))

print(style.big("made by"))
print(style.big("Tricker"))

i = str(p)

ip = requests.get("https://ipinfo.io/"+i+"/ip")
city = requests.get("https://ipinfo.io/"+i+"/city")
region = requests.get("https://ipinfo.io/"+i+"/region")
country = requests.get("https://ipinfo.io/"+i+"/country")
loc = requests.get("https://ipinfo.io/"+i+"/loc")
time = requests.get("https://ipinfo.io/"+i+"/timezone")

print(style.color("blue"))
print("ip :",ip.text)
print("city :",city.text)
print("region :", region.text)
print("country :",country.text)
print("loc :",loc.text)