Bitcoin Forum
April 19, 2024, 12:01:39 AM *
News: Latest Bitcoin Core release: 26.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: Quote/Keyword/Reply/Topic Notifier  (Read 581 times)
edgycorner (OP)
Sr. Member
****
Offline Offline

Activity: 1064
Merit: 382

Hurrah for Karamazov!


View Profile
May 24, 2019, 03:14:48 PM
Last edit: May 04, 2022, 08:27:31 PM by edgycorner
Merited by Welsh (5), dbshck (5), elda34b (5), Halab (4), ABCbits (3), TryNinja (3), PryptoMontreal (3), hugeblack (2), Harlot (2), LeGaulois (1), stomachgrowls (1), morvillz7z (1), Piggy (1), sncc (1)
 #1

A bot which will notifies you about:

  • Any new reply to your post
  • If anyone quotes you or mentions your username
  • If any new topic or reply contains your keywords

It uses pushbullet app(available on both iPhone and android), or Telegram to send notifications.

Like this:



Make sure to pip install these two libraries:
pushbullet.py
bs4

After installing these two libraries, copy/paste and run the code


Here is the code:
No need to edit anything in the script.

Code:

notifm=input("Choose notification method.\nEnter 1 for Telegram Bot\nEnter 2 for Pushbullet")
if (notifm=='2'):
 token=input("Enter Token: ")

if (notifm=='1'):
 btoken=input("Enter Bot Token: ")
 chatid=input("Enter Your CHAT ID: ")


keywords=[]
topics=[]
cc='y'
vv=0
while cc=='y' or cc=='Y' or cc=='yes' or cc=='Yes' or cc=='YES':
 vva=vv+1
 vva=str(vva)
 kw=input("Enter #"+vva+" Keyword/username(Just Press enter if no keyword) ")
 keywords.insert(vv,kw)
 vv+=1
 cc=input("Add more keyword/username? y/n ")

vv=0
cc1='y'
while cc1=='y' or cc1=='Y' or cc1=='yes' or cc1=='Yes' or cc1=='YES':
 vva=vv+1
 vva=str(vva)
 kw=input("Enter #"+vva+" Topic title(Just Press enter if none) ")
 kw=kw.lstrip()
 topics.insert(vv,kw)
 vv+=1
 cc1=input("Add more Topics? y/n ")

import requests

import re

from bs4 import BeautifulSoup

from datetime import datetime

from pushbullet import Pushbullet

from time import sleep

url="https://bitcointalk.org/index.php?action=recent"

headers = {'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3729.157 Safari/537.36'}

if (notifm=='2'):
 pb= Pushbullet(token)

done=[]
i=0
key=0
print('Working..')

while True:

 page = requests.get(url, headers=headers)
 soup=BeautifulSoup(page.content, 'html.parser')
 if topics[0] != "":
   for s in topics:
    s='Re: '+s
    for a in soup.findAll('a', text=s):
      if not a.get('href') in done:
       done.insert(i,a.get('href'))
       i+=1
       ptitle='New Reply on your topic'
       ptext='Link: '+a.get('href')
       if(notifm=='2'):
        push = pb.push_note(ptitle,ptext)
       if(notifm=='1'):
        push = "https://api.telegram.org/bot"+btoken+"/sendMessage?chat_id="+chatid+"&text="+ptitle+" "+ptext
        requests.get(push, headers=headers)
       print('New topic found, sending message')
       sleep(300)
 if keywords[0] != "":
  for x in keywords:
   table=soup.find_all('table',attrs={'class':'bordercolor'})
   for t in table:
     results=t.find(string=re.compile('.*{0}.*'.format(x)))
     if results!=None:
      s=t.find('b')
      title=s.text
      li=s.find('a')
      if not li.get('href') in done:
        done.insert(i,li.get('href'))
        i+=1
        ptext='Title: '+title+' Link:'+li.get('href')
        ptitle='Post with keyword: *'+x+'* Found'
        if(notifm=='2'):
         push = pb.push_note(ptitle,ptext)
        if(notifm=='1'):
         push = "https://api.telegram.org/bot"+btoken+"/sendMessage?chat_id="+chatid+"&text="+ptitle+" "+ptext
         requests.get(push, headers=headers)
        print("Keyword found, sending message")
        sleep(300)
    
  

 sleep(20)
 



You can find API token of your pushbullet account here:
https://www.pushbullet.com/#settings/account

If you are using telegram as notification method instead of Pusbullet, you will need a Bot token ID and your CHAT ID.
Here's how to procure these two things:
 1.)Use godfather to create a new bot and note down its token ID. Make sure to send a /start message to that bot.
 2.)Send a message to @RawDataBot, it will reply back with your Chat ID. See pic https://i.imgur.com/TsFUsFB.png


You can install Termux on your phone, to run this script 24*7 by using termux-wake-lock (Haven't tested it yet but should work, it might drain your battery)

It's better to use the script on your PC, by installing python on it.

I will be adding a new update for sock usage, so that you can run it on a VPS. You won't be able to run this script on a VPS for now because cloudflare won't let a datacenter IP address to scrap recent pages.



Reply here, if you face any problem.

1713484899
Hero Member
*
Offline Offline

Posts: 1713484899

View Profile Personal Message (Offline)

Ignore
1713484899
Reply with quote  #2

1713484899
Report to moderator
1713484899
Hero Member
*
Offline Offline

Posts: 1713484899

View Profile Personal Message (Offline)

Ignore
1713484899
Reply with quote  #2

1713484899
Report to moderator
1713484899
Hero Member
*
Offline Offline

Posts: 1713484899

View Profile Personal Message (Offline)

Ignore
1713484899
Reply with quote  #2

1713484899
Report to moderator
Once a transaction has 6 confirmations, it is extremely unlikely that an attacker without at least 50% of the network's computation power would be able to reverse it.
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction.
1713484899
Hero Member
*
Offline Offline

Posts: 1713484899

View Profile Personal Message (Offline)

Ignore
1713484899
Reply with quote  #2

1713484899
Report to moderator
TryNinja
Legendary
*
Offline Offline

Activity: 2814
Merit: 6956



View Profile WWW
May 24, 2019, 04:00:47 PM
Merited by edgycorner (3)
 #2

Great Job! I actually prefer Pushbullet over Telegram (which most people use).

Could you add an option to scrape posts in the “recent” page? That would allow to search for keywords direclty on posts instead of just thread titles.

.
.HUGE.
▄██████████▄▄
▄█████████████████▄
▄█████████████████████▄
▄███████████████████████▄
▄█████████████████████████▄
███████▌██▌▐██▐██▐████▄███
████▐██▐████▌██▌██▌██▌██
█████▀███▀███▀▐██▐██▐█████

▀█████████████████████████▀

▀███████████████████████▀

▀█████████████████████▀

▀█████████████████▀

▀██████████▀▀
█▀▀▀▀











█▄▄▄▄
▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
.
CASINSPORTSBOOK
▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄
▀▀▀▀█











▄▄▄▄█
edgycorner (OP)
Sr. Member
****
Offline Offline

Activity: 1064
Merit: 382

Hurrah for Karamazov!


View Profile
May 24, 2019, 06:44:46 PM
 #3

Great Job! I actually prefer Pushbullet over Telegram (which most people use).
And People won't be comfortable to use their bots key on someone else's script, if they don't know programming.

Could you add an option to scrape posts in the “recent” page? That would allow to search for keywords direclty on posts instead of just thread titles.
Very good suggestion, I didn't even think about it.Will add it someday, for sure.
TryNinja
Legendary
*
Offline Offline

Activity: 2814
Merit: 6956



View Profile WWW
May 24, 2019, 07:29:01 PM
 #4

Nice job! But looks like it requires users need computer/server which run 24/7 if you need continuous notification, right?

I wonder if the script would run on QPython3/Pydroid 3 out-of-the-box?
I’m not sure if it would work, but you can try “hosting” your python script with PythonAnywhere[1]. It’s free and you can make the script work without having your PC on all day.

[1] https://www.pythonanywhere.com/

.
.HUGE.
▄██████████▄▄
▄█████████████████▄
▄█████████████████████▄
▄███████████████████████▄
▄█████████████████████████▄
███████▌██▌▐██▐██▐████▄███
████▐██▐████▌██▌██▌██▌██
█████▀███▀███▀▐██▐██▐█████

▀█████████████████████████▀

▀███████████████████████▀

▀█████████████████████▀

▀█████████████████▀

▀██████████▀▀
█▀▀▀▀











█▄▄▄▄
▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
.
CASINSPORTSBOOK
▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄
▀▀▀▀█











▄▄▄▄█
edgycorner (OP)
Sr. Member
****
Offline Offline

Activity: 1064
Merit: 382

Hurrah for Karamazov!


View Profile
May 25, 2019, 12:08:22 PM
 #5

Unfortunately, pythonanywhere has blacklisted bitcointalk.

Nice job! But looks like it requires users need computer/server which run 24/7 if you need continuous notification, right?

I wonder if the script would run on QPython3/Pydroid 3 out-of-the-box?
It worked with Pydroid 3, just make sure to pip install bs4 and pushbullet.py
edgycorner (OP)
Sr. Member
****
Offline Offline

Activity: 1064
Merit: 382

Hurrah for Karamazov!


View Profile
May 29, 2019, 07:20:00 PM
Last edit: May 29, 2019, 08:02:34 PM by edgycorner
 #6

The bot has been updated.

Updates:

  • Anyone can use the script, even with no knowledge about programming
  • The bot now checks recent posts section for updates
  • Notifies when your username is mentioned(or quoted) in any post
  • Pydrioid3 compatibility, to run the script 24*7 through your phone


You can PM me or reply here, if you are unable to run the script.
wwzsocki
Legendary
*
Offline Offline

Activity: 2730
Merit: 1706


First 100% Liquid Stablecoin Backed by Gold


View Profile WWW
December 14, 2019, 08:12:59 AM
 #7

...Anyone can use the script, even with no knowledge about programming...

I am not so sure.

I was using it until now Maggiordomo bot from member Piggy but lately stopped to work so I started to look for an alternative and of course, found your thread.

Maggirordomo bot was very easy to set up (just look in the thread), anyways many times multiple people found even this setup too hard and were confused.

Once I even made a short tutorial with screens because there were so many questions and confused members who couldn't get the bot to run and this required only to send a message, to be honest.

I will be happy to know if there is any way to get your bot working with the Telegram desktop app to receive notifications or is it only possible on the phone?

edgycorner (OP)
Sr. Member
****
Offline Offline

Activity: 1064
Merit: 382

Hurrah for Karamazov!


View Profile
May 04, 2022, 07:15:26 PM
Merited by DaveF (2)
 #8

I had to use this script again, so made some changes to make it more efficient and updated the original post with it.

Changes made:
>Added Telegram as a notification mode
>The bot will now scrap recent pages after ever 20 seconds compared to 2 seconds in previous version, to eliminate any bot like behavior and reduce unnecessary load on bitcointalk server.
>Bot will go into sleep for 5 minutes after making a notification. Again, did this to reduce any unnecessary scrapping of bitcointalk
>A few changes in how the bot reads title input

Might add in future:
Socks5 usage

 Cheesy
Welsh
Staff
Legendary
*
Offline Offline

Activity: 3248
Merit: 4110


View Profile
May 13, 2022, 10:29:03 AM
 #9

>The bot will now scrap recent pages after ever 20 seconds compared to 2 seconds in previous version, to eliminate any bot like behavior and reduce unnecessary load on bitcointalk server.
I think reducing that even further by default probably wouldn't be an issue. Not many users here need to be notified that quickly. You could probably ramp it up to two minutes, five minutes or even ten minutes. For example, when I go on expeditions, and use a satellite communicator, that has the option for two minutes, ten minutes, and 30 minutes, and I usually stick it on the ten minute one as it doesn't kill the battery too quickly, and is still decent enough. I know this is slightly different, but how many times does someone reply to your thread or post within a minute? Probably not often.

Also, while this might have worked for a while now, changing the time to wait would likely help future proof it, if theymos ever decides to change the request rate limit, since to me twenty seconds is quite quick, and doesn't give you much leeway. Although, is definitely an improvement over the two second limit.
edgycorner (OP)
Sr. Member
****
Offline Offline

Activity: 1064
Merit: 382

Hurrah for Karamazov!


View Profile
May 13, 2022, 05:17:17 PM
Merited by Welsh (1)
 #10

>The bot will now scrap recent pages after ever 20 seconds compared to 2 seconds in previous version, to eliminate any bot like behavior and reduce unnecessary load on bitcointalk server.
I think reducing that even further by default probably wouldn't be an issue. Not many users here need to be notified that quickly. You could probably ramp it up to two minutes, five minutes or even ten minutes. For example, when I go on expeditions, and use a satellite communicator, that has the option for two minutes, ten minutes, and 30 minutes, and I usually stick it on the ten minute one as it doesn't kill the battery too quickly, and is still decent enough. I know this is slightly different, but how many times does someone reply to your thread or post within a minute? Probably not often.

Also, while this might have worked for a while now, changing the time to wait would likely help future proof it, if theymos ever decides to change the request rate limit, since to me twenty seconds is quite quick, and doesn't give you much leeway. Although, is definitely an improvement over the two second limit.
Yup, 20 seconds is still too frequent for an update check.
Will replace it with 3 minutes next week Cheesy
TryNinja
Legendary
*
Offline Offline

Activity: 2814
Merit: 6956



View Profile WWW
July 28, 2022, 10:01:24 PM
 #11

Yup, 20 seconds is still too frequent for an update check.
Will replace it with 3 minutes next week Cheesy
If you only check the "recent posts" page every 3 minutes, won't you miss out on a lot of posts, as it only shows the last 10 posts (unless you go through the 10 pages = last 100 posts)? How does that work?

.
.HUGE.
▄██████████▄▄
▄█████████████████▄
▄█████████████████████▄
▄███████████████████████▄
▄█████████████████████████▄
███████▌██▌▐██▐██▐████▄███
████▐██▐████▌██▌██▌██▌██
█████▀███▀███▀▐██▐██▐█████

▀█████████████████████████▀

▀███████████████████████▀

▀█████████████████████▀

▀█████████████████▀

▀██████████▀▀
█▀▀▀▀











█▄▄▄▄
▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
.
CASINSPORTSBOOK
▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄
▀▀▀▀█











▄▄▄▄█
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!