GithubHelp home page GithubHelp logo

bdim404 / hackernews-summarize-telegram-bot Goto Github PK

View Code? Open in Web Editor NEW
1.0 2.0 0.0 77 KB

This is a bot used with this [Hacker News Feed Telegram chnnel](https://t.me/hacker_news_feed), forword the message to the bot and return the summarize to you.

License: BSD 3-Clause "New" or "Revised" License

Python 100.00%
hackernews openai openai-api summarizer telegram telegram-bot

hackernews-summarize-telegram-bot's Introduction

HackerNews-Summarize-Telegram-Bot

Github Pages license PRs Welcome Hacker News

Introduce

This is a bot used with this Hacker News Feed Telegram chnnel, forword the message to the bot and return the summarize to you.

Quickstart

  1. Download and open this repository with git clone https://github.com/bdim404/HackerNews-Summarize-Telegram-Bot.git

  2. Customize the configuration by copying .env.example and renaming it to .env, then editing the required parameters as desired:

Parameter Description
OPENAI_API_KEY Your OpenAI API key, you can get it from here
TELEGRAM_BOT_TOKEN Your Telegram bot's token, obtained using BotFather (see tutorial)
ADMIN_USER_IDS Telegram user IDs of admins. These users have access to special admin commands, information and no budget restrictions. Admin IDs don't have to be added to ALLOWED_TELEGRAM_USER_IDS. Note: by default, no admin (-)
ALLOWED_TELEGRAM_USER_IDS A comma-separated list of Telegram user IDs that are allowed to interact with the bot (use getidsbot to find your user ID). Note: by default, everyone is allowed (*)
  1. Install the dependencies using requirements.txt file:
pip install -r requirements.txt
  1. Use the following command to start the bot:
python hackernewSummarizeBot.py

hackernews-summarize-telegram-bot's People

Contributors

bdim404 avatar fernvenue avatar

Stargazers

 avatar

Watchers

 avatar  avatar

hackernews-summarize-telegram-bot's Issues

Add requirements.

It will be helpful to add requirement file when the first time user deploy this bot.

Authentication support.

As above, summarize bot now can be accessed by everyone, need to add authentication feature, may related to #1.

There are some problems in some site.

Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/telegram/ext/_application.py", line 1195, in process_update
    await coroutine
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/telegram/ext/_basehandler.py", line 153, in handle_update
    return await self.callback(update, context)
  File "/Volumes/bdim'stonge/work_and_learn/python learning/hackernewSummarizeBot.py", line 102, in handle_message
    content = h2t.handle(html)
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/html2text/__init__.py", line 142, in handle
    self.feed(data)
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/html2text/__init__.py", line 139, in feed
    super().feed(data)
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/html/parser.py", line 110, in feed
    self.goahead(0)
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/html/parser.py", line 170, in goahead
    k = self.parse_starttag(i)
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/html/parser.py", line 344, in parse_starttag
    self.handle_starttag(tag, attrs)
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/html2text/__init__.py", line 191, in handle_starttag
    self.handle_tag(tag, dict(attrs), start=True)
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/html2text/__init__.py", line 327, in handle_tag
    tag_style = element_style(attrs, self.style_def, parent_style)
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/html2text/utils.py", line 72, in element_style
    assert attrs["class"] is not None
AssertionError

Something upgrade

I'm going to revamp the following two points:

On the one hand is to take only the first 10 comments in the comment section, if the token is too long it will return an error to the bot.

On the other hand add authentication, still using .env.

Add env and coding to the head.

Something like:

# !/usr/bin/env python
# -*- coding: utf-8 -*

I think it is always the best practice to write this statement :)

Add MAX_CHAR_LENGTH.

Sometimes retweeted articles and comments will exceed the tokens limit, plus a maximum character limit, if this limit is exceeded then the last content of the article will be deleted from the comments until the maximum character limit is met.

add stream

add "stream" when openai return the message.

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.