Advertisement
Nuanda

fbchat message

Feb 24th, 2019
120
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.11 KB | None | 0 0
  1. # coding=utf-8
  2. from fbchat import Client
  3. from fbchat.models import *
  4. import ConfigParser # Module for configuration-file read.
  5. import sys
  6.  
  7. text = ''
  8. thread_id = ''
  9. thread_type = ''
  10.  
  11. def facebook_send(username, password, fthread_id, fthread_type, ftext, ftext_arg):
  12.     client = Client(username, password)
  13.     client.send(Message(text=str(ftext) + ' az ΓΊj anyag pedig:' + str(ftext_arg)), thread_id=1867812176612833, thread_type=ThreadType.GROUP)
  14.     client.logout()
  15.  
  16. config = ConfigParser.RawConfigParser()
  17. config.read('facebook.properties')
  18. for section_name in config.sections():
  19.     if config.has_option(section_name, 'USERNAME'):
  20.         username = config.get(section_name, 'USERNAME')
  21.         password = config.get(section_name, 'PASSWORD')
  22.         fthread_id = config.get(section_name, 'THREAD_ID')
  23.         fthread_type = config.get(section_name, 'THREAD_TYPE')
  24.         ftext = config.get(section_name, 'TEXT')
  25.         ftext_arg = sys.argv[1]
  26.         facebook_send(username, password, fthread_id, fthread_type, ftext, ftext_arg)
  27.     else:
  28.         print("The following parameter required:",section_name)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement