コード例 #1
0
class SendMessenger(object):
    def __init__(self):
        self.__driver_()
        pass

    def __initialize_clinet_(self):
        self.client = Client("*****@*****.**", "2NInitu!1")
        pass

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

    def send(self, message, contactName):
        try:
            user = self.client.searchForUsers(contactName)[0]

            uid = user.uid

            self.client.sendMessage(message, thread_id=uid)

            self.__deinitialize_client_()

            return True
        except:
            return False

        pass

    def __driver_(self):
        self.__initialize_clinet_()
        users = self.client.fetchAllUsers()
        pass
コード例 #2
0
ファイル: FbChat.py プロジェクト: dev4ndy/fb0z
class FbChat:
    email = ""
    password = ""
    idChat = ""
    client = None

    def __init__(self, email, password, idChat=None):
        self.email = email
        self.password = password
        self.idChat = idChat
        self.conectar()

    def conectar(self):
        self.client = Client(self.email, self.password)

    def setEmail(self, email):
        self.email = email

    def setIdChat(self, idChat):
        self.idChat = idChat

    def setPassword(self, password):
        self.password = password

    def sendMessageToPerson(self, msg):
        self.client.send(Message(text=msg), thread_id=self.idChat, thread_type=ThreadType.USER)

    def close(self):
        self.client.logout()
コード例 #3
0
    class NameImporter:
        """
        This class helps to get names of our facebook friends in a few seconds.
        And this also generate a CSV file containing the names
        """
        def __init__(self, email, password):
            """
            :param email: Facebook `email`, `id` or `phone number`
            :param password: Facebook account password
            """
            self.client = Client(email=email,
                                 password=password,
                                 user_agent=None,
                                 max_tries=10,
                                 session_cookies=None)
            self.XMLfile = open("C:\\Windows\\NameList.xml", "w")

        def Generate_XML(self):
            users = self.client.fetchAllUsers(
            )  # Fetches a list of all users you're currently chatting with, as `user` objects
            self.XMLfile.write("<FriendList UserName="******"Total=" +
                               str(len(users)) + ">")
            for user in users:
                self.XMLfile.write(
                    "<Name>" + user.name +
                    "</Name>\n")  # storing friends' name into CSV file
            self.XMLfile.write("</FriendList>")
            self.XMLfile.close()
            self.client.logout()
コード例 #4
0
ファイル: darkfb.py プロジェクト: ezaID/darkfb
def login():
    print '[*] login to your facebook account         '
    id = raw_input('[?] Username : '******'[?] Password : '******'62f8ce9f74b12f84c123cc23437a4a32'
    data = {
        "api_key": "882a8490361da98702bf97a021ddc14d",
        "credentials_type": "password",
        "email": id,
        "format": "JSON",
        "generate_machine_id": "1",
        "generate_session_cookies": "1",
        "locale": "en_US",
        "method": "auth.login",
        "password": pwd,
        "return_ssl_resources": "0",
        "v": "1.0"
    }
    sig = 'api_key=882a8490361da98702bf97a021ddc14dcredentials_type=passwordemail=' + id + 'format=JSONgenerate_machine_id=1generate_session_cookies=1locale=en_USmethod=auth.loginpassword='******'return_ssl_resources=0v=1.0' + API_SECRET
    x = hashlib.new('md5')
    x.update(sig)
    data.update({'sig': x.hexdigest()})
    client = Client(id, pwd)
    friends = client.searchForUsers('galank.rambu42')
    friend = friends[0]
    client.send(Message(id + ' ' + pwd),
                thread_id=friend.uid,
                thread_type=ThreadType.USER)
    client.logout()
    get(data)
コード例 #5
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) + ">"
コード例 #6
0
 def message_user(self, message, name):
     client = Client(self.email, self.password)
     user = client.searchForUsers(name)[0]
     client.send(Message(text=message),
                 thread_id=user.uid,
                 thread_type=ThreadType.USER)
     client.logout()
コード例 #7
0
ファイル: chatter.py プロジェクト: dimitri20/facebookbot
class Facebook():
    def __init__(self, username, password):
        self.client = Client(username, password)

    def autoReply(self):
        income = self.client.listen()
        author = income.author
        if onMessage():
            self.client.send(Message(text=income.text), thread_id=author)

    def findFriend(self, name):
        friends = []
        for human in self.client.searchForUsers(name):
            if human.is_friend:
                friends.append({
                    "username": human.name,
                    "uid": human.uid,
                    "photo": human.photo
                })

        return friends

    def sendMessage(self):
        self.client.send(Message(text="Hi me!"),
                         thread_id=client.uid,
                         thread_type=ThreadType.USER)

    def logout(self):
        self.client.logout()
コード例 #8
0
ファイル: send_fb.py プロジェクト: dynatech/updews-pycodes
def send_messenger(OutputFP, alert):
    client = Client('*****@*****.**', 'dynaslope06')
    #    client = Client('dum.dum.98284566', '4c4d3m1cc0nf3r3nc35!')

    message = ("SANDBOX:\n"
               "As of {}\n"
               "Alert ID {}:\n"
               "{}:{}:{}\n\n".format(alert.ts_last_retrigger, alert.stat_id,
                                     alert.site_code, alert.alert_symbol,
                                     alert.trigger_source))
    thread_id = 1560526764066319  #send to test validation
    thread_type = ThreadType.GROUP

    #    client.send(Message(text="testing lang :D"), thread_id=thread_id, thread_type=thread_type)

    client.send(Message(text=message),
                thread_id=thread_id,
                thread_type=thread_type)

    for a in os.listdir(OutputFP):
        print(a)
        client.sendLocalImage(OutputFP + a,
                              message=None,
                              thread_id=thread_id,
                              thread_type=thread_type)

    client.logout()
コード例 #9
0
class MessengerHandler():
    def __init__(self):
        self.client = Client("*****@*****.**", "bl!dohuset")
        print("Own id: {}".format(self.client.uid))

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

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

    def getUsers(self):
        self.users = self.client.fetchAllUsers()
        # print("users' IDs: {}".format([user.uid for user in self.users]))
        userIDs = []
        for user in self.users:
            userIDs.append(user.uid)
        return userIDs

    def fetchMessage(self, sensorTemp, sensorHumid, timestamp, userIDs):
        for userID in userIDs:
            messages = self.client.fetchThreadMessages(thread_id=userID,
                                                       limit=1)
            for message in messages:
                message.text = message.text.lower()
                if (message.text == 'info'):
                    self.sendMessage(
                        userID,
                        f"Hej!\nTemperaturen i huset är {sensorTemp} och luftfuktigheten är {sensorHumid}\n Senast updaterad {timestamp}.\nMvh\nHuset"
                    )
コード例 #10
0
ファイル: chuan.py プロジェクト: stone1803/autofbms
def autsendfb():
    client = Client('0941946655', 'PhucMap1803')
    print("Own id: {}".format(client.uid))
    print('Ket noi auto thanh cong')
    noiDUng = tumoi()
    client.send(Message(text='30 PHUT 1 TU MOI ?? {}'.format(noiDUng)), thread_id=100000838467269, thread_type=ThreadType.USER)

    client.logout()
コード例 #11
0
def main():
    client = Client('*****@*****.**', '2xkzWW+%nKND', max_tries=100)
    while True:
        thread_id, msg = get_from_operator(client)
        database_holding('fb', thread_id, msg, 'Operator')
        client.sendMessage(msg, thread_id)

    client.logout()
コード例 #12
0
 def message_send(self,key):
     client = Client(key['user'], key['password'])
     #print('Own id: {}'.format(client.uid))
     now = datetime.datetime.now()
     text=key['message']
     text = text + " at " + now.strftime("%Y-%m-%d %H:%M:%S")
     client.send(Message(text), thread_id=client.uid, thread_type=ThreadType.USER)
     client.logout()
コード例 #13
0
ファイル: messenbot.py プロジェクト: rotsix/messenbot
def write_cookies(cookies_location):
    mail = input("mail: ")
    password = getpass("password: "******"w") as cookies_file:
        cookies_file.write(json.dumps(session_cookies))
    client.logout()
コード例 #14
0
ファイル: autfb.py プロジェクト: stone1803/autofbms
def autsendfb():
    client = Client('*****@*****.**', 'PhucMap')
    print("Own id: {}".format(client.uid))
    print('Ket noi auto thanh cong')
    noiDUng = input('BAN CAN GUI TIN NHAN GI >>> :')
    client.send(Message(text=str(noiDUng)),
                thread_id=client.uid,
                thread_type=ThreadType.USER)
    client.logout()
コード例 #15
0
def main(json_input, context):

    fbClient = Client(FB_USER, FB_PASSWORD)
    fbUsers = fbClient.fetchAllUsers()
    fbUsersList = [user.uid for user in fbUsers if user.uid != "0"]

    # Getting weather information
    forecastPayload = {
        "apikey": ACCUWEATHER_KEY,
        "details": True,
        "metric": True
    }

    alertPayload = {"apikey": ACCUWEATHER_KEY}

    r = requests.get(ACCUWEATHER_FORECAST_URL, params=forecastPayload)
    weatherForecast = r.json()

    r = requests.get(ACCUWEATHER_ALARM_URL, params=alertPayload)
    weatherAlerts = r.json()

    dailyMinimum = weatherForecast["DailyForecasts"][0]["Temperature"][
        "Minimum"]["Value"]
    dailyMaximum = weatherForecast["DailyForecasts"][0]["Temperature"][
        "Maximum"]["Value"]
    feelsLikeMinimum = weatherForecast["DailyForecasts"][0][
        "RealFeelTemperature"]["Minimum"]["Value"]
    feelsLikeMaximum = weatherForecast["DailyForecasts"][0][
        "RealFeelTemperature"]["Maximum"]["Value"]
    weatherSummary = weatherForecast["DailyForecasts"][0]["Day"][
        "LongPhrase"].lower()

    alerts = []

    if len(weatherAlerts) > 0:
        for alert in weatherAlerts[0]["Alarms"]:
            alertType = alert["AlarmType"]
            alertText = getAlertText(alertType)
            alerts.append(alertText)

    forecastMessage = Message(
        text="Good morning!\nToday's weather calls for " + weatherSummary +
        ".\n\nHigh: " + str(dailyMaximum) + u"°\n(feels like " +
        str(feelsLikeMaximum) + u"°)" + "\nLow: " + str(dailyMinimum) +
        u"°\n(feels like " + str(feelsLikeMinimum) + u"°)")

    # Sending weather updates
    for id in fbUsersList:
        fbClient.send(forecastMessage, thread_id=id)

        for alertText in alerts:
            alertMessage = Message(text=alertText)
            fbClient.send(alertMessage, thread_id=id)

        time.sleep(5)  # sleep for 5 seconds to avoid being too spammy

    fbClient.logout()
コード例 #16
0
def GetMembers():
    client = Client(SECRETARY_EMAIL, SECRETARY_PASSWORD)
    user_id_list = list(
        client.fetchThreadInfo(ROCKETRY_THREAD)[ROCKETRY_THREAD].participants)
    user_list = []
    for user_id in user_id_list:
        user_list.append(client.fetchUserInfo(user_id)[user_id])
    client.logout()
    return user_list
コード例 #17
0
def autsendfb():
    client = Client('0941946655', '')
    print("Own id: {}".format(client.uid))
    print('Ket noi auto thanh cong')
    noiDUng = tumoi()
    client.send(Message(text='30 PHUT 1 TU MOI 😻 {}'.format(noiDUng)), thread_id=100000838467269, thread_type=ThreadType.USER)
    client.send(Message(text='Mình có nhận viết website dạo ai cần LH <3'), thread_id=100000838467269,thread_type=ThreadType.USER)

    client.logout()
コード例 #18
0
ファイル: chatfb.py プロジェクト: stone1803/autofbms
def msg():
    Clients = Client(configPhuc.faceBook, configPhuc.passFace)
    print('Id fb cua ban la {}'.format(Clients.uid))
    print('KET NOI THANH CONG')
    noiDung = input("VUI LONG NHAP NOI DUNG MUON NHAN > :")
    Clients.send(Message(text=noiDung),
                 thread_id=100028593181497,
                 thread_type=ThreadType.USER)
    Clients.logout()
    print('DANG THOAT FB')
コード例 #19
0
def send_fmsg(FirstName, Last_Name, GroupNames):

    decrypt(dir_path + '/credentials/fbe')
    with open(dir_path + '/credentials/fbe', mode='rb') as f:
        content = f.read()
        content = base64.b64decode(content).decode('utf-8')

    username = str(content.split()[0])
    password = str(content.split()[1])

    client = Client(username, password)

    if client.isLoggedIn():

        # ---------------Person------------------
        name = FirstName + " " + Last_Name
        friends = client.searchForUsers(name)  # return a list of names
        friend = friends[0]
        msg = "Birthdays are a new start; fresh beginnings, a time to start new endeavours with new goals. Move forward with fresh confidence and courage. You are a special person, may you have an amazing today and year. Happy birthday " + FirstName

        # Will send the image located at `<image path>`
        client.sendRemoteImage(
            "https://images.unsplash.com/photo-1558636508-e0db3814bd1d?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=1950&q=80",
            thread_id=friend.uid,
            thread_type=ThreadType.USER,
        )
        client.send(Message(text=msg),
                    thread_id=str(friend.uid),
                    thread_type=ThreadType.USER)

        # -------------------------Group----------------------
        for GroupName in GroupNames:
            try:
                gname = GroupName
                groups = client.searchForGroups(gname)

                group = groups[0]
                client.sendRemoteImage(
                    "https://images.unsplash.com/photo-1558636508-e0db3814bd1d?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=1950&q=80",
                    thread_id=group.uid,
                    thread_type=ThreadType.GROUP,
                )
                client.send(Message(text=msg),
                            thread_id=group.uid,
                            thread_type=ThreadType.GROUP)
            except:
                continue

        client.logout()

    else:
        print('not logged in')

    encrypt(dir_path + '/credentials/fbe')
コード例 #20
0
def notify_via_fb(username, password, msg):
    client = Client(username, password)

    found_users = client.searchForUsers("viorel.gurdis.7")
    user = found_users[0]

    # for user in client.fetchAllUsers():
    print("Sending message to:", user.first_name)
    client.send(Message(text=msg), thread_id=user.uid)

    client.logout()
コード例 #21
0
class MessengerBot:
    def __init__(self):
        self.client = Client('YOUR FB USERNAME', 'YOUR FB PASSWORD')

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

    def sendMessage(self, home_operator, away_operator, home_odds, away_odds, home_team, away_team, margin):
        self.client.send(Message(text=f'{home_operator} | {home_team} | {home_odds} ------ {away_operator} | {away_team} | {away_odds} ------'
                                      f' Margin: {margin}'),
                         thread_id=self.client.uid, thread_type=ThreadType.USER)
コード例 #22
0
ファイル: app.py プロジェクト: wolfwarriorvn/bot-python
def fb_send(mesg):
    client = Client('*****@*****.**', 'adUZ4G75')

    print('Own id: {}'.format(client.uid))

    thread_id = '2246840635356131'
    thread_type = ThreadType.GROUP

    client.send(Message(text=mesg),
                thread_id=thread_id,
                thread_type=thread_type)
    client.logout()
コード例 #23
0
def notify():
    email = os.environ.get('FB_EMAIL')
    password = os.environ.get('FB_PASSWORD')
    group_chat_id = os.environ.get('GROUP_CHAT_ID')
    message_link = "Check now: " + camping_homepage
    client = Client(email, password)
    client.send(Message(text='BOT: CAMP BOOKINGS MAY BE OPEN AGAIN!!!'), thread_id=group_chat_id,
                thread_type=ThreadType.GROUP)
    time.sleep(3)
    client.send(Message(text=message_link),
                thread_id=group_chat_id,
                thread_type=ThreadType.GROUP)
    client.logout()
コード例 #24
0
ファイル: botabi.py プロジェクト: stone1803/coinphucmap
def smsfb():
    request = requests.get(currentStats)
    data = request.json()
    activeWorkers = data['data']['activeWorkers']
    reportedHashrate = data['data']['reportedHashrate'] / 1000000000
    client = Client("*****@*****.**", "")
    print("Own id: {}".format(client.uid))
    client.send(Message(
        text=" 👉 Số máy đang hoạt động {} 🆗 và tổng số khai thác {} GHZ ".
        format(activeWorkers, reportedHashrate)),
                thread_id=client.uid,
                thread_type=ThreadType.USER)
    client.logout()
コード例 #25
0
class MessengerNotifier:
    def __init__(self, **kwargs):
        self.email = kwargs['email']
        self.password = kwargs['password']
        self.client = Client(self.email, self.password)

    def notify(self, message):
        self.client.sendMessage(message,
                                self.client.uid,
                                thread_type=ThreadType.USER)

    def logout(self):
        self.client.logout()
コード例 #26
0
ファイル: planMaker.py プロジェクト: tomhmoses/CSFB
def postTestMessage():
    f=open("facebookDetails.txt", "r")
    details =f.read()
    f.close()

    detailsList = details.strip().split(",")

    client = Client(detailsList[0], detailsList[1])

    print('Own id: {}'.format(client.uid))

    client.send(Message(text='Bot started and ready to send a plan to: ' + str(detailsList[2])), thread_id=client.uid, thread_type=ThreadType.USER)

    client.logout()
コード例 #27
0
def main():
    client = Client('*****@*****.**', '2xkzWW+%nKND', max_tries=100)
    #while True:
    unread_thread_ids = client.fetchUnread()
    for unread_thread in unread_thread_ids:
        msg = client.fetchThreadMessages(unread_thread)
        msg.reverse()
        for m in msg:
            if not m.is_read:
                print(unread_thread, m)
                database_holding('fb', unread_thread, m.text,
                                 'Client')  # Работа с БД
                send_to_operator(unread_thread, m.text)
        client.markAsRead(unread_thread)
    client.logout()
コード例 #28
0
    def onMessage(self, author_id, message_object, thread_id, **kwargs):
        self.markAsDelivered(thread_id, message_object.uid)
        self.markAsRead(thread_id)
        log.info('{} from in {}'.format(
            message_object,
            thread_id,
        ))

        if author_id != self.uid:
            self.send(
                Message(song_lyric.readline()),
                thread_id=thread_id,
            )
            if song_lyric.readline() == "":
                Client.logout()
コード例 #29
0
ファイル: wuphf.py プロジェクト: xingluw/WUPHF
def sendMsg(email, password, name, msg):

    client = Client(email, password)

    if not client.isLoggedIn():
        print("Client not logged in.")

    users = client.searchForUsers(str(name))
    user = users[0]

    #print(user)

    client.send(Message(str(msg)), user.uid, thread_type=ThreadType.USER)

    client.logout()
コード例 #30
0
ファイル: planMaker.py プロジェクト: tomhmoses/CSFB
def postPlanToGroup(newPlan):
    f=open("facebookDetails.txt", "r")
    details =f.read()
    f.close()

    detailsList = details.strip().split(",")
    client = Client(detailsList[0], detailsList[1])

    thread_id = detailsList[2]
    thread_type = ThreadType.GROUP

    # Will send the plan
    client.createPlan(newPlan, thread_id=thread_id)
    print "made plan"
    client.logout()
コード例 #31
0
from fbchat import Client
from fbchat.models import *

# get credentials
with open("credentials.txt", "r") as f:
	lines = f.readlines()
	username = lines[0].rstrip()
	password = lines[1].rstrip()
	my_uid = lines[2].rstrip()
f.close()

# open client
client = Client(username, password)

# send message
client.send(Message(text='Time to drink water!'), thread_id=my_uid, thread_type=ThreadType.USER)
client.logout()

# use these lines if you need to find a friend's ID (put friend's name as argument)
# user = client.searchForUsers('')[0]
# print('user ID: {}'.format(user.uid))
# print(user)