Ejemplo n.º 1
0
class Messenger(object):
    def __init__(self, email, pwd=None):
        self.email = email
        self.pwd = pwd
        self.client = None
        if pwd is not None:
            self.client = Client(email, pwd)

    def isOnline(self):
        return self.client.isLoggedIn()

    def login(self, pwd=None):
        if pwd is None:
            self.client.login(self.email, self.pwd)
        else:
            self.pwd = pwd
            self.client = Client(self.email, self.pwd)

    def searchUsers(self, search_query):
        return self.client.searchForUsers(search_query, limit=5)

    def send(self, messenger_id, message):
        return self.client.send(Message(text=message),
                                thread_id=messenger_id,
                                thread_type=ThreadType.USER)

    def getLast(self, th):
        return self.client.fetchThreadMessages(thread_id=th, limit=1)[0]

    def logout(self):
        self.client.logout()

    def __str__(self):
        return "Messenger<uid:" + str(self.client.uid) + ">"
Ejemplo n.º 2
0
def message(text):
    email = os.environ['E-MAIL']
    password = os.environ['FBPASSWORD']
    thread_type = ThreadType.USER
    client = Client(email, password)

    if not client.isLoggedIn():
        client.login(email, password)

    client.send(Message(text=text),
                thread_id=client.uid,
                thread_type=thread_type)
Ejemplo n.º 3
0
def send_message(bear, item, current_price):
    try:
        client = Client(USER, PASSWORD)
        if not client.isLoggedIn():
            client.login(USER, PASSWORD)
        current_price = current_price if current_price is not None else ''

        client.send(Message(
            text=
            '{}: {} volume: {} max_volume: {} bull_market: {} current_price: {}'
            .format(bear.time, item.symbol, bear.volume, bear.max_volume,
                    item.bull_market, current_price)),
                    thread_id='100000518793275',
                    thread_type=ThreadType.USER)
        # client.logout()
    except Exception as error:
        logging.info('Send message error: {}'.format(error))
Ejemplo n.º 4
0
class TrackerClient:
    def __init__(self, options, logger, config):
        self.options = options
        self.logger = logger
        self.trackerLogger = TrackerLogger.TrackerLogger(config['db'])
        self.config = config

        # let's try to login into that account
        self.client = Client(self.options['username'],
                             self.options['password'], None, 5, None,
                             logging.CRITICAL)

    # I'm not sure why, but Facebook API sometimes does return a "historical" data (2-3 hours old)

    def onChatTimestamp(self, **kwargs):
        updatedUsers = kwargs['buddylist'].items()
        self.trackerLogger.log(updatedUsers)

        for user, timestamp in updatedUsers:
            userInfo = self.client.fetchUserInfo(user)[user]
            self.trackerLogger.userdata(userInfo)

            if (
                    self.config['env'] == 'dev'
            ):  #and time.time() - int(timestamp) < 60): # to save some unneeded requests
                self.logger.info('{}: {} updated: {}'.format(
                    self.options['username'], userInfo.name,
                    datetime.datetime.fromtimestamp(
                        int(timestamp)).strftime('%Y-%m-%d %H:%M:%S')))

    def listen(self):
        if (not self.client):
            self.logger.error('%s: FBChat client not detected!',
                              self.options['username'])
            return False

        if (not self.client.isLoggedIn()):
            self.client.login(self.options['username'],
                              self.options['password'])

        # monkey patching. not sure if this is a good idea
        self.client.onChatTimestamp = self.onChatTimestamp

        self.client.listen()
Ejemplo n.º 5
0
def sendReddit(post_list):
    cl = Client(usr_email, usr_pass)
    if not cl.isLoggedIn():
        cl.login(usr_email, usr_pass)
    with open("reddit.txt", "a+") as f_reddit:
        content = f_reddit.readlines()
        content = [x.strip() for x in content]
        print content

        for post in post_list:
            #Check if post has been sent yet or not
            if post["link"] not in content:
                msg_txt = "NEW JOB ON REDDIT : " + post[
                    "title"] + " - link : " + post["link"]
                msg = Message(text=msg_txt)
                message_id = cl.send(msg,
                                     thread_id=cl.uid,
                                     thread_type=ThreadType.USER)
                f_reddit.write(post["link"] + "\n")
                print "Job " + post["title"] + " Has been sent"
            else:
                continue
from fbchat import Client
from fbchat.models import Message

sentence = 'Been working so hard I'm punching my card Eight hours, for what? Oh, tell me what I got I gotten this feeling That time's just holding me down I'll hit the ceiling Or else I'll tear up this town Tonight I gotta cut loose, footloose Kick off your Sunday shoes Please, Louise Pull me up off my knees Jack, get back C'mon, before we crack Lose your blues Everybody cut footloose You're playing so cool Obeying every rule Dig way down in your heart You're burning, yearning for some Somebody to tell you That life ain't passing you by I'm trying to tell you It will if you don't even try You can fly if you'd only cut loose, footloose Kick off your Sunday shoes Ooh-wee, Marie Shake it, shake it for me Whoa, Milo C'mon, c'mon let's go Lose your blues Everybody cut footloose'
sentence = sentence.split(' ')

username = "******"
password = "******"
# login
client = Client(username, password)
personToSpam = 'friendsName'
#just making sure
if not client.isLoggedIn():
    client.login(username, password)


print('fetching most recent users u talked too...')
users = client.fetchThreadList()
detailed_users = [ list(client.fetchThreadInfo(user.uid).values())[0] for user in users ]

#sorting them by message count
sorted_detailed_users = sorted(detailed_users, key=lambda u: u.message_count, reverse=True)

print('looking for',personToSpam)
for friend in sorted_detailed_users:
    if personToSpam in friend.name :
        personToSpam = friend
        break

print('sending aannoying spam to:',personToSpam.name)
for word in sentence:
Ejemplo n.º 7
0
from fbchat import Client
from Auth.credentials import user, password, person

client = Client(user, password)
if not client.isLoggedIn():
    client.login(user, password)
    print("Login successful...")

user = client.searchForUsers(person)[0]
userid = user.uid
thread_id = userid
messages = []

me = client.fetchThreadMessages(thread_id=thread_id, limit=500)
me.reverse()
print(len(me))
for m in me:
    u = client.fetchUserInfo(m.author)[m.author]
    print(u.name, m.text)

client.logout()
Ejemplo n.º 8
0
from fbchat import Client
from fbchat.models import *
client = Client('*****@*****.**', 'shakilnsu2018')
import time

if not client.isLoggedIn():
    client.login('*****@*****.**', 'shakilnsu2018')
#
# print('Own id: {}'.format(client.uid))
# client.send(Message(text='valo tui?'), thread_id='100007826251418', thread_type=ThreadType.USER)

# users = client.searchForUsers('MD Musa Islam')
# user = users[0]
# print("User's ID: {}".format(user.uid))
# print("User's name: {}".format(user.name))
# print("User's profile picture url: {}".format(user.photo))
# print("User's main url: {}".format(user.url))

# client.send(Message(text='<message>'), thread_id='<group id>', thread_type=ThreadType.GROUP)
# client.logout();

# Fetches a list of the 20 top threads you're currently chatting with

threads = client.fetchThreadList()
print("Threads: {}".format(client.fetchUnread()[0]))

# client.listen()

#!/usr/local/bin/python

from fbchat import Client
Ejemplo n.º 9
0
    givers.remove(givers[rand])

file = open(path + "/ Master List.txt", "w")
file.write(master_list)

#send out files
from fbchat import Client
from fbchat.models import *
email = raw_input("What is your Facebook email? : ")
password = raw_input("What is your Facebook password? : ")
client = Client(email, password)

for key in receivers:
    if not client.isLoggedIn():
        client.login(email, password)

    #Dumb people with no facebook accounts, but messenger accounts.
    #find ID by "Right Click > View Page Source" on www.facebook.com, search name
    if key == "Bob":  #123456789
        client.sendLocalFiles(
            path + "/" + key + "/" + key + ".txt",
            message=Message(text="Merry Christmas!"),
            thread_id="123456789",
            thread_type=ThreadType.USER,
        )
        continue

    #people who changed names
    if key == "Alice":
        key = "Alex"
Ejemplo n.º 10
0
        userid = {
            'abrar auntakib': '100052754273527',
            'emran nader': '100043127960705',
            'mohammed kalam': '100002460758668'
        }
        b = True
        while b == True:
            search = input("Write here:")
            if search == 'log in':
                import win32com.client as wincl

                speak = wincl.Dispatch("SAPI.SpVoice")
                speak.Speak("logging in")
                client = Client('*****@*****.**', 'shahriar')

                client.login('*****@*****.**', 'shahriar')
                import win32com.client as wincl

                speak = wincl.Dispatch("SAPI.SpVoice")
                speak.Speak('logged in successfully')
            if search == 'send message':
                try:
                    userid = {
                        'abrar muntakib': '100052754273527',
                        'emran nader': '100043127960705',
                        'mohammed kalam': '100002460758668',
                        'farhan saeed': '100044099033695',
                        'awlad rahim': '100023223665820',
                        'helal sir': '100049397701683',
                        '500 tk apu': '100043423841363'
                    }
Ejemplo n.º 11
0
class GeneralDbQueriesUsed:
    def __init__(self):
        self.faceadminemail = ''
        self.faceadminpassword = ''
        self.client = Client(self.faceadminemail, self.faceadminpassword)

    def eventcheck(self, creator, event_name, pk):
        return EventsModel.objects.all().filter(creator=creator,
                                                eventname=event_name,
                                                pk=pk).first()

    def getattendees(self, event):
        return EventAttendeeModel.objects.all().filter(event=event)

    """def getfile(self,event):
		return FileAttendeeModel.objects.all().filter(event=event).first()"""

    def sendlinks(self, request, event):
        attendees = general_query.getattendees(event)
        for person in attendees:
            if not self.client.isLoggedIn():
                self.client.login(self.faceadminemail,
                                  self.faceadminpassword,
                                  max_tries=1)
            if not person.is_link_sended:
                if person.email:
                    send_mail(
                        subject=event.eventname,
                        message=strip_tags(
                            render_to_string(
                                "eventinvitation.html", {
                                    'invitor':
                                    request.user.email,
                                    'attendee':
                                    person.name,
                                    'domain':
                                    get_current_site(request).domain,
                                    'event':
                                    event,
                                    'event_pk':
                                    urlsafe_base64_encode(force_bytes(
                                        event.pk)),
                                    'user_pk':
                                    urlsafe_base64_encode(
                                        force_bytes(person.pk)),
                                    'statusyes':
                                    urlsafe_base64_encode(force_bytes("yes")),
                                    'statusno':
                                    urlsafe_base64_encode(force_bytes("no")),
                                    'event_name':
                                    urlsafe_base64_encode(
                                        force_bytes(event.eventname)),
                                })),
                        from_email=settings.EMAIL_HOST_USER,
                        recipient_list=[person.email],
                        html_message=render_to_string(
                            "eventinvitation.html", {
                                'invitor':
                                request.user.email,
                                'attendee':
                                person.name,
                                'domain':
                                get_current_site(request).domain,
                                'event':
                                event,
                                'event_pk':
                                urlsafe_base64_encode(force_bytes(event.pk)),
                                'user_pk':
                                urlsafe_base64_encode(force_bytes(person.pk)),
                                'statusyes':
                                urlsafe_base64_encode(force_bytes("yes")),
                                'statusno':
                                urlsafe_base64_encode(force_bytes("no")),
                                'event_name':
                                urlsafe_base64_encode(
                                    force_bytes(event.eventname)),
                            }),
                        fail_silently=False,
                    )
                    person.is_link_sended = True
                if person.facebook_address:
                    try:
                        if "profile.php?id=" in person.facebook_address:
                            user = person.facebook_address.rsplit(
                                'profile.php?id=', 1).pop()
                            self.client.send(Message(text=strip_tags(
                                render_to_string(
                                    "eventinvitation.html", {
                                        'invitor':
                                        request.user.email,
                                        'attendee':
                                        person.name,
                                        'domain':
                                        get_current_site(request).domain,
                                        'event':
                                        event,
                                        'event_pk':
                                        urlsafe_base64_encode(
                                            force_bytes(event.pk)),
                                        'user_pk':
                                        urlsafe_base64_encode(
                                            force_bytes(person.pk)),
                                        'statusyes':
                                        urlsafe_base64_encode(
                                            force_bytes("yes")),
                                        'statusno':
                                        urlsafe_base64_encode(force_bytes(
                                            "no")),
                                        'event_name':
                                        urlsafe_base64_encode(
                                            force_bytes(event.eventname)),
                                    }))),
                                             thread_id=user,
                                             thread_type=ThreadType.USER)
                            print("me too")
                            person.is_link_sended = True
                        else:
                            userid = person.facebook_address.rsplit('/',
                                                                    1).pop()
                            users = self.client.searchForUsers(userid)
                            print(users)
                            user = users[0]
                            print("User's ID: {}".format(user.uid))
                            print("User's name: {}".format(user.name))
                            print("User's profile picture URL: {}".format(
                                user.photo))
                            print("User's main URL: {}".format(user.url))
                            self.client.send(Message(text=strip_tags(
                                render_to_string(
                                    "eventinvitation.html", {
                                        'invitor':
                                        request.user.email,
                                        'attendee':
                                        person.name,
                                        'domain':
                                        get_current_site(request).domain,
                                        'event':
                                        event,
                                        'event_pk':
                                        urlsafe_base64_encode(
                                            force_bytes(event.pk)),
                                        'user_pk':
                                        urlsafe_base64_encode(
                                            force_bytes(person.pk)),
                                        'statusyes':
                                        urlsafe_base64_encode(
                                            force_bytes("yes")),
                                        'statusno':
                                        urlsafe_base64_encode(force_bytes(
                                            "no")),
                                        'event_name':
                                        urlsafe_base64_encode(
                                            force_bytes(event.eventname)),
                                    }))),
                                             thread_id=user.uid,
                                             thread_type=ThreadType.USER)
                        person.is_link_sended = True
                    except:
                        pass
                person.save()
Ejemplo n.º 12
0
import time, random
from fbchat import Client
from fbchat.models import *
client = Client('acc', 'pass')
if not client.isLoggedIn():
    client.login('acc', 'pass')


def countdown(t, x):
    while t:
        mins, secs = divmod(t, 60)
        timeformat = '{:02d}:{:02d}'.format(mins, secs)
        print(timeformat, end='\r')
        time.sleep(1)
        t -= 1
    client.send(Message(text=x),
                thread_id='100000415757550',
                thread_type=ThreadType.USER)


for i in range(200):
    y = ''
    x = random.sample(
        ('anh', 'Anh', 'aNh', 'anH', 'AnH', 'ANH', 'ANh'), 1) + random.sample(
            ('xin', 'Xin', 'XIn', 'XIN', 'XiN', 'xIN', 'xIn'),
            1) + random.sample(
                ('lỗi', 'Lỗi', 'lỖi', 'LỗI', 'LỖi', 'lỖI', 'LỗI'),
                1) + random.sample(
                    ('nha', 'nHa', 'nhA', 'NHA', 'Nha', 'nHA'), 1)
    for j in range(len(x)):
        y = y + ' ' + x[j]