GithubHelp home page GithubHelp logo

oxlac / mr.dm Goto Github PK

View Code? Open in Web Editor NEW
23.0 1.0 2.0 1.54 MB

A quick and easy tool for automating your Instagram DMs.

Home Page: https://mr-dm.oxlac.com

License: MIT License

Python 93.14% kvlang 6.86%
instagram instagram-bot instagram-dm instagram-dm-bot python selenium-python trc-woc

mr.dm's People

Contributors

aadityaa2606 avatar guhan-sensam avatar sriramvaishnav avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

Forkers

guhan-sensam

mr.dm's Issues

Import Accounts if they have interacted with a particular post

Requirements

The ability to import target accounts based on their interactions with a post given the post URL.

This feature should allow the user to

  1. Enter an url for an Instagram post
  2. Validate this post actually exists on Instagram
  3. Present the user with the option to import accounts from the post likes or comments. Also give the user the ability to limit the amount of accounts that are imported
  4. Add these accounts to the list of imported accounts

Some References

https://instaloader.github.io/module/structures.html#instaloader.Post.get_comments
https://instaloader.github.io/module/structures.html#instaloader.Post.get_likes

Not able to Message

Hey Can you please help me with this error, the bot is getting stuck again and again. I don't know what is the reason but I think the UI of my instagram is a bit different from what I saw in screenshots. Please help
Screenshot 2024-01-12 215554

Exception in thread Thread-4 (_start_messages):
Traceback (most recent call last):
File "C:\Users\dashi\AppData\Local\Programs\Python\Python312\Lib\threading.py", line 1073, in _bootstrap_inner
self.run()
File "C:\Users\dashi\AppData\Local\Programs\Python\Python312\Lib\threading.py", line 1010, in run
self._target(self._args, **self._kwargs)
File "C:\Users\dashi\OneDrive\Documents\GitHub\MR.DM\src\ui\progressscreen\progressscreen.py", line 241, in _start_messages
self.start_message_loop()
File "C:\Users\dashi\OneDrive\Documents\GitHub\MR.DM\src\ui\progressscreen\progressscreen.py", line 252, in start_message_loop
self.find_element(SELECTORS["new_dm_btn"]).click()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\dashi\OneDrive\Documents\GitHub\MR.DM\src\ui\progressscreen\progressscreen.py", line 307, in find_element
return self.session.driver.find_element(By.XPATH, XPATH)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\dashi\AppData\Local\Programs\Python\Python312\Lib\site-packages\selenium\webdriver\remote\webdriver.py", line 742, in find_element
return self.execute(Command.FIND_ELEMENT, {"using": by, "value": value})["value"]
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\dashi\AppData\Local\Programs\Python\Python312\Lib\site-packages\selenium\webdriver\remote\webdriver.py", line 348, in execute
self.error_handler.check_response(response)
File "C:\Users\dashi\AppData\Local\Programs\Python\Python312\Lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 229, in check_response
raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.NoSuchElementException: Message: no such element: Unable to locate element: {"method":"xpath","selector":"//div[@ROLE= 'button'][.//div//
//*[text()='New message']]"}
(Session info: chrome=120.0.6099.217); For documentation on this error, please visit: https://www.selenium.dev/documentation/webdriver/troubleshooting/errors#no-such-element-exception
Stacktrace:
GetHandleVerifier [0x00007FF7EEFF2142+3514994]
(No symbol) [0x00007FF7EEC10CE2]
(No symbol) [0x00007FF7EEAB76AA]
(No symbol) [0x00007FF7EEB01860]
(No symbol) [0x00007FF7EEB0197C]
(No symbol) [0x00007FF7EEB44EE7]
(No symbol) [0x00007FF7EEB2602F]
(No symbol) [0x00007FF7EEB428F6]
(No symbol) [0x00007FF7EEB25D93]
(No symbol) [0x00007FF7EEAF4BDC]
(No symbol) [0x00007FF7EEAF5C64]
GetHandleVerifier [0x00007FF7EF01E16B+3695259]
GetHandleVerifier [0x00007FF7EF076737+4057191]
GetHandleVerifier [0x00007FF7EF06E4E3+4023827]
GetHandleVerifier [0x00007FF7EED404F9+689705]
(No symbol) [0x00007FF7EEC1C048]
(No symbol) [0x00007FF7EEC18044]
(No symbol) [0x00007FF7EEC181C9]
(No symbol) [0x00007FF7EEC088C4]
BaseThreadInitThunk [0x00007FFBC7D2257D+29]
RtlUserThreadStart [0x00007FFBC9ACAA58+40]

Application stops when an account sets "Message request" feature on.

Describe the bug
This bug happens when a user sets their "get only dm messages from connected accounts" feature true. When this happens, the app gets confused and does not turn anything back.

To Reproduce
Steps to reproduce the behavior:

  1. Go to 'add users' and add an user with the feature I said enabled and add normal accounts for testing purpose.
  2. Start sending a message to all the accounts we added.
  3. Then application will send message to the account that have "get dms from only connected accounts"
  4. And you will see our error, which is raise exception_class(message, screen, stacktrace)
    selenium.common.exceptions.StaleElementReferenceException: Message: stale element reference: stale element not found

Expected behavior
We could expect application sending dm to that account and still send dms to other accounts we added.

Desktop (please complete the following information):

  • OS: Windows
  • Version 10

Additional context
This happens when an account we DM'd uses an instagram feature called "message requests". This means the person we DM'd should accept our message invite then see our message. This thing causes the problem in the application.

Bot gets stuck after it inputs the Username

Describe the bug
I am not sure if it's something that has to do with the selectors. The Bot is supposed to proceed with the DM, but gets stuck after entering name of User.

To Reproduce
Steps to reproduce the behavior:

  1. After it inputs the Username, it gets stuck with the procedure.

Expected behavior
After input its supposed to send the DM.

Screenshots

This is the Log im getting:
screenshot

[DEBUG  ] Finished Request
 Exception in thread Thread-5 (_start_messages):
 Traceback (most recent call last):
   File "C:\Program Files\Python312\Lib\threading.py", line 1052, in _bootstrap_inner
     self.run()
   File "C:\Program Files\Python312\Lib\threading.py", line 989, in run
     self._target(*self._args, **self._kwargs)
   File "C:\Users\Wombaterino\Desktop\MR.IG\MR.DM\src\ui\progressscreen\progressscreen.py", line 245, in _start_messages
     self.start_message_loop()
   File "C:\Users\Wombaterino\Desktop\MR.IG\MR.DM\src\ui\progressscreen\progressscreen.py", line 266, in start_message_loop
     self.find_element(SELECTORS["dm_select_user"].format(user[1])).click()
   File "C:\Users\Wombaterino\AppData\Roaming\Python\Python312\site-packages\selenium\webdriver\remote\webelement.py", line 94, in click
     self._execute(Command.CLICK_ELEMENT)
   File "C:\Users\Wombaterino\AppData\Roaming\Python\Python312\site-packages\selenium\webdriver\remote\webelement.py", line 395, in _execute
     return self._parent.execute(command, params)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   File "C:\Users\Wombaterino\AppData\Roaming\Python\Python312\site-packages\selenium\webdriver\remote\webdriver.py", line 347, in execute
     self.error_handler.check_response(response)
   File "C:\Users\Wombaterino\AppData\Roaming\Python\Python312\site-packages\selenium\webdriver\remote\errorhandler.py", line 229, in check_response
     raise exception_class(message, screen, stacktrace)
 selenium.common.exceptions.ElementClickInterceptedException: Message: element click intercepted: Element <span class="x1lliihq x193iq5w x6ikm8r x10wlt62 xlyipyv xuxw1ft">...</span> is not clickable at point (193, 286). Other element would receive the click: <div class="x1qjc9v5 x9f619 x78zum5 xdt5ytf x1iyjqo2 xl56j7k" style="--card-background: rgb(var(--ig-primary-background)); --comment-background: rgb(var(--ig-highlight-background)); --filter-primary-icon: invert(100%); --messenger-card-background: rgb(var(--ig-primary-background)); --mwp-message-list-actions-width: 96px; --mwp-message-row-background: rgb(var(--ig-primary-background)); --primary-text: rgb(var(--ig-primary-text));">...</div>
   (Session info: chrome=121.0.6167.184)
 Stacktrace:
        GetHandleVerifier [0x00007FF789277012+3522402]
        (No symbol) [0x00007FF788E98352]
        (No symbol) [0x00007FF788D45ABB]
        (No symbol) [0x00007FF788D93390]
        (No symbol) [0x00007FF788D910D2]
        (No symbol) [0x00007FF788D8E834]
        (No symbol) [0x00007FF788D8D569]
        (No symbol) [0x00007FF788D81910]
        (No symbol) [0x00007FF788DAF05A]
        (No symbol) [0x00007FF788D8120A]
        (No symbol) [0x00007FF788DAF270]
        (No symbol) [0x00007FF788DCBDA3]
        (No symbol) [0x00007FF788DAEE03]
        (No symbol) [0x00007FF788D7F4D4]
        (No symbol) [0x00007FF788D805F1]
        GetHandleVerifier [0x00007FF7892A9B9D+3730157]
        GetHandleVerifier [0x00007FF7892FF02D+4079485]
        GetHandleVerifier [0x00007FF7892F75D3+4048163]
        GetHandleVerifier [0x00007FF788FCA649+718233]
        (No symbol) [0x00007FF788EA4A3F]
        (No symbol) [0x00007FF788E9FA94]
        (No symbol) [0x00007FF788E9FBC2]
        (No symbol) [0x00007FF788E8F2E4]
        BaseThreadInitThunk [0x00007FF82B8E7344+20]
        RtlUserThreadStart [0x00007FF82D8426B1+33]

AFTER I CLOSE THE SCRIPT LOG:

[INFO   ] [Base        ] Leaving application in progress...
 Traceback (most recent call last):
   File "C:\Users\Wombaterino\Desktop\MR.IG\MR.DM\src\main.py", line 67, in <module>
     MyApp().run()
   File "C:\Users\Wombaterino\AppData\Roaming\Python\Python312\site-packages\kivy\app.py", line 956, in run
     runTouchApp()
   File "C:\Users\Wombaterino\AppData\Roaming\Python\Python312\site-packages\kivy\base.py", line 574, in runTouchApp
     EventLoop.mainloop()
   File "C:\Users\Wombaterino\AppData\Roaming\Python\Python312\site-packages\kivy\base.py", line 339, in mainloop
     self.idle()
   File "C:\Users\Wombaterino\AppData\Roaming\Python\Python312\site-packages\kivy\base.py", line 379, in idle
     Clock.tick()
   File "C:\Users\Wombaterino\AppData\Roaming\Python\Python312\site-packages\kivy\clock.py", line 733, in tick
     self.post_idle(ts, self.idle())
                        ^^^^^^^^^^^
   File "C:\Users\Wombaterino\AppData\Roaming\Python\Python312\site-packages\kivy\clock.py", line 689, in idle
     usleep(1000000 * sleeptime)
   File "C:\Users\Wombaterino\AppData\Roaming\Python\Python312\site-packages\kivy\clock.py", line 965, in usleep
     _usleep(microseconds, self._sleep_obj)
   File "C:\Users\Wombaterino\AppData\Roaming\Python\Python312\site-packages\kivy\clock.py", line 504, in _usleep
     _kernel32.WaitForSingleObject(obj, 0xffffffff)
 KeyboardInterrupt

Desktop (please complete the following information):
Any

[EASY] Update All Class Documentation

Only the classes inside the backend module has been properly documented. The other classes inside the ui module and its submodules need to be documented.

This is a contribution that anyone can do with even minimal python knowledge. You need to read the code referencing various documentations of the used libraries and write documentation for the respective code block.

An example documentation block is

"""

    .. image:: https://raw.githubusercontent.com/Oxlac/MR.DM/main/docs/images/login-screen.png


    Welcome Screen/Login Screen Class. This screen contains methods that deal with adding new users and logging in existing users.
    When an user launches the program for the first time,this scren will display no accounts.
    """
def get_user(self, userid: str) -> Tuple[str, str, str, str]:
        """
        Gets the Instagram user from the database with the given userid.

        :param userid: The userid of the user to get

        :return: The user with the given userid
        """

        c = self.conn.cursor()
        c.execute("SELECT * FROM users WHERE userid=?", (userid,))
        return c.fetchone()

How to write Docs

MR.DM uses Sphinx AutoApi to generate documentation for all internal classes and functions. You can read more here.

In order for AutoApi to generate proper documentation it needs to know the datatypes of any function parameters, return values and class members. This can be done by using the python type hints definition. More info here

  1. Find something that hasn't been documented
  2. First check if you can define any types for the python code you want to document
  3. Write a description of what the function, class or class member does.
  4. See if your changes mirror the style of the rest of the docs by building the docs
cd docs
./make html
  1. You should see the main docs file inside the directory docs/_build/html/docs.html

Does not work

Installed, added the account and selected the users to send the message. Then it pops up a new window of my browser with IG and logs in but that's it. Never gets to sending any dm whatsoever.

Allow Importing Accounts from a hashtag

There needs to be a way for the application to import accounts from a particular hashtag. This includes two types of options:

  1. Retrieving accounts that have posted under a particular hashtag
  2. Retrieving accounts that have interacted (i.e liked or commented) under the first few posts of a particular hashtag

There also needs to be a system in place that allows the user to enter the number the maximum number of posts they wish to target. This number also needs to be quite small (1-5) for the second kind of account imports(This is to prevent Insta from temp banning the bot's ip)

This can be implemented by using the instaloader hashtag classes and functionality. Fort reference:
Reference

Update to IG broke the script, must update selector probably

Describe the bug

Update to IG broke the script, must update selector probably

To Reproduce

Try to send a DM and:

[DEBUG  ] Finished Request
 Exception in thread Thread-4 (_start_messages):
 Traceback (most recent call last):
   File "/opt/homebrew/Cellar/[email protected]/3.11.7_1/Frameworks/Python.framework/Versions/3.11/lib/python3.11/threading.py", line 1045, in _bootstrap_inner
     self.run()
   File "/opt/homebrew/Cellar/[email protected]/3.11.7_1/Frameworks/Python.framework/Versions/3.11/lib/python3.11/threading.py", line 982, in run
     self._target(*self._args, **self._kwargs)
   File "/Users/danilopanzano/Desktop/git/mr.dm/src/ui/progressscreen/progressscreen.py", line 232, in _start_messages
     if self.find_element(SELECTORS["save_login_info"]):
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   File "/Users/danilopanzano/Desktop/git/mr.dm/src/ui/progressscreen/progressscreen.py", line 311, in find_element
     return self.session.driver.find_element(By.XPATH, XPATH)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   File "/opt/homebrew/lib/python3.11/site-packages/selenium/webdriver/remote/webdriver.py", line 742, in find_element
     return self.execute(Command.FIND_ELEMENT, {"using": by, "value": value})["value"]
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   File "/opt/homebrew/lib/python3.11/site-packages/selenium/webdriver/remote/webdriver.py", line 348, in execute
     self.error_handler.check_response(response)
   File "/opt/homebrew/lib/python3.11/site-packages/selenium/webdriver/remote/errorhandler.py", line 229, in check_response
     raise exception_class(message, screen, stacktrace)
 selenium.common.exceptions.NoSuchElementException: Message: no such element: Unable to locate element: {"method":"xpath","selector":"//button[text()='Save info']"}
   (Session info: chrome=121.0.6167.85); For documentation on this error, please visit: https://www.selenium.dev/documentation/webdriver/troubleshooting/errors#no-such-element-exception

Expected behavior
a DM should be sent

Desktop (please complete the following information):
any

python: can't open file 'C:\\Users\\Admin\\mr.dm\\main.py': [Errno 2] No such file or directory

Describe the bug
A clear and concise description of what the bug is.

To Reproduce
Steps to reproduce the behavior:

  1. Go to '...'
  2. Click on '....'
  3. Scroll down to '....'
  4. See error

Expected behavior
A clear and concise description of what you expected to happen.

Screenshots
If applicable, add screenshots to help explain your problem.

Desktop (please complete the following information):

  • OS: [e.g. Windows, Linux]
  • Version [e.g. 22]

Additional context
Add any other context about the problem here.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.