forked from sch/Slixfeed
Containerized configurations (step towards a portable software. SeeTPFC portablefreeware.com)
This commit is contained in:
parent
0512e14738
commit
c4ccdd1f9d
9 changed files with 74 additions and 18 deletions
14
README.md
14
README.md
|
@ -46,6 +46,18 @@ Slixfeed is designed to handle multiple contacts, including groupchats, Simultan
|
||||||
|
|
||||||
### Install
|
### Install
|
||||||
|
|
||||||
|
Choose one of the following installation methods.
|
||||||
|
|
||||||
|
#### Using pip inside venv
|
||||||
|
|
||||||
|
```
|
||||||
|
$ python3 -m venv .venv
|
||||||
|
$ source .venv/bin/activate
|
||||||
|
$ pip install git+https://gitgud.io/sjehuda/slixfeed
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Using pipx
|
||||||
|
|
||||||
```
|
```
|
||||||
$ pipx install git+https://gitgud.io/sjehuda/slixfeed
|
$ pipx install git+https://gitgud.io/sjehuda/slixfeed
|
||||||
```
|
```
|
||||||
|
@ -58,7 +70,7 @@ $ slixfeed
|
||||||
|
|
||||||
### Usage
|
### Usage
|
||||||
|
|
||||||
- Start a chat with the bot and follow it instructions.
|
- Add the bot to contact list and follow it instructions.
|
||||||
- Send command `help` or `commands` for a list of commands.
|
- Send command `help` or `commands` for a list of commands.
|
||||||
|
|
||||||
## Roadmap
|
## Roadmap
|
||||||
|
|
|
@ -44,6 +44,13 @@ dependencies = [
|
||||||
"feedparser",
|
"feedparser",
|
||||||
"lxml",
|
"lxml",
|
||||||
"slixmpp",
|
"slixmpp",
|
||||||
|
|
||||||
|
# Optional dependencies
|
||||||
|
# listed here (testing)
|
||||||
|
"html2text",
|
||||||
|
"pdfkit",
|
||||||
|
"pysocks",
|
||||||
|
"readability-lxml",
|
||||||
]
|
]
|
||||||
|
|
||||||
[project.urls]
|
[project.urls]
|
||||||
|
@ -53,8 +60,8 @@ Issues = "https://gitgud.io/sjehuda/slixfeed/issues"
|
||||||
|
|
||||||
|
|
||||||
[project.optional-dependencies]
|
[project.optional-dependencies]
|
||||||
# socks = ["PySocks"]
|
|
||||||
file-export = ["html2text", "pdfkit"]
|
file-export = ["html2text", "pdfkit"]
|
||||||
|
proxy = ["pysocks"]
|
||||||
readability = ["readability-lxml"]
|
readability = ["readability-lxml"]
|
||||||
|
|
||||||
# This section returns pep508-identifier error
|
# This section returns pep508-identifier error
|
||||||
|
|
|
@ -70,6 +70,8 @@ TODO
|
||||||
activities every X minutes.
|
activities every X minutes.
|
||||||
When a suspicious activity is detected, it will be reported immediately.
|
When a suspicious activity is detected, it will be reported immediately.
|
||||||
|
|
||||||
|
19) Communicate to messages of new contacts (not subscribed and not in roster)
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
# vars and their meanings:
|
# vars and their meanings:
|
||||||
|
@ -99,6 +101,9 @@ from slixfeed.config import get_value
|
||||||
from slixfeed.xmpp.client import Slixfeed
|
from slixfeed.xmpp.client import Slixfeed
|
||||||
#import slixfeed.matrixhandler
|
#import slixfeed.matrixhandler
|
||||||
|
|
||||||
|
import socks
|
||||||
|
import socket
|
||||||
|
|
||||||
|
|
||||||
class Jabber:
|
class Jabber:
|
||||||
def __init__(self, jid, password, nick):
|
def __init__(self, jid, password, nick):
|
||||||
|
@ -116,6 +121,7 @@ class Jabber:
|
||||||
xmpp.register_plugin('xep_0066') # Out of Band Data
|
xmpp.register_plugin('xep_0066') # Out of Band Data
|
||||||
xmpp.register_plugin('xep_0071') # XHTML-IM
|
xmpp.register_plugin('xep_0071') # XHTML-IM
|
||||||
xmpp.register_plugin('xep_0084') # User Avatar
|
xmpp.register_plugin('xep_0084') # User Avatar
|
||||||
|
# xmpp.register_plugin('xep_0085') # Chat State Notifications
|
||||||
xmpp.register_plugin('xep_0153') # vCard-Based Avatars
|
xmpp.register_plugin('xep_0153') # vCard-Based Avatars
|
||||||
xmpp.register_plugin('xep_0199', {'keepalive': True}) # XMPP Ping
|
xmpp.register_plugin('xep_0199', {'keepalive': True}) # XMPP Ping
|
||||||
xmpp.register_plugin('xep_0249') # Multi-User Chat
|
xmpp.register_plugin('xep_0249') # Multi-User Chat
|
||||||
|
@ -142,10 +148,28 @@ class Jabber:
|
||||||
# xmpp.proxy = {'socks5': ('localhost', 9050)}
|
# xmpp.proxy = {'socks5': ('localhost', 9050)}
|
||||||
|
|
||||||
# Connect to the XMPP server and start processing XMPP stanzas.
|
# Connect to the XMPP server and start processing XMPP stanzas.
|
||||||
xmpp.connect()
|
|
||||||
|
address = get_value(
|
||||||
|
"accounts", "XMPP", ["address", "port"])
|
||||||
|
if address[0] and address[1]:
|
||||||
|
xmpp.connect(tuple(address))
|
||||||
|
else:
|
||||||
|
xmpp.connect()
|
||||||
xmpp.process()
|
xmpp.process()
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
|
|
||||||
|
values = get_value(
|
||||||
|
"accounts", "XMPP Proxy", ["socks5_host", "socks5_port"])
|
||||||
|
if values[0] and values[1]:
|
||||||
|
host = values[0]
|
||||||
|
port = values[1]
|
||||||
|
s = socks.socksocket()
|
||||||
|
s.set_proxy(socks.SOCKS5, host, port)
|
||||||
|
# socks.set_default_proxy(socks.SOCKS5, host, port)
|
||||||
|
# socket.socket = socks.socksocket
|
||||||
|
|
||||||
# Setup the command line arguments.
|
# Setup the command line arguments.
|
||||||
parser = ArgumentParser(description=Slixfeed.__doc__)
|
parser = ArgumentParser(description=Slixfeed.__doc__)
|
||||||
|
|
||||||
|
|
|
@ -267,7 +267,7 @@ def list_feeds_by_query(query, results):
|
||||||
async def get_setting_value(db_file, key):
|
async def get_setting_value(db_file, key):
|
||||||
value = (
|
value = (
|
||||||
await sqlite.get_settings_value(db_file, key) or
|
await sqlite.get_settings_value(db_file, key) or
|
||||||
config.get_value_default("settings", "Settings", key)
|
config.get_value("settings", "Settings", key)
|
||||||
)
|
)
|
||||||
return value
|
return value
|
||||||
|
|
||||||
|
@ -1084,6 +1084,8 @@ async def extract_image_from_html(url):
|
||||||
'contains(@src, "emoji") or '
|
'contains(@src, "emoji") or '
|
||||||
'contains(@src, "icon") or '
|
'contains(@src, "icon") or '
|
||||||
'contains(@src, "logo") or '
|
'contains(@src, "logo") or '
|
||||||
|
'contains(@src, "search") or '
|
||||||
|
'contains(@src, "share") or '
|
||||||
'contains(@src, "smiley")'
|
'contains(@src, "smiley")'
|
||||||
')]/@src')
|
')]/@src')
|
||||||
if len(images):
|
if len(images):
|
||||||
|
|
|
@ -49,10 +49,10 @@ def get_value(filename, section, keys):
|
||||||
result = None
|
result = None
|
||||||
config_res = configparser.RawConfigParser()
|
config_res = configparser.RawConfigParser()
|
||||||
config_dir = get_default_config_directory()
|
config_dir = get_default_config_directory()
|
||||||
# if not os.path.isdir(config_dir):
|
|
||||||
# config_dir = '/usr/share/slixfeed/'
|
|
||||||
if not os.path.isdir(config_dir):
|
if not os.path.isdir(config_dir):
|
||||||
os.mkdir(config_dir)
|
config_dir = '/usr/share/slixfeed/'
|
||||||
|
if not os.path.isdir(config_dir):
|
||||||
|
config_dir = os.path.dirname(__file__) + "/assets"
|
||||||
config_file = os.path.join(config_dir, filename + ".ini")
|
config_file = os.path.join(config_dir, filename + ".ini")
|
||||||
config_res.read(config_file)
|
config_res.read(config_file)
|
||||||
if config_res.has_section(section):
|
if config_res.has_section(section):
|
||||||
|
@ -137,6 +137,8 @@ def get_list(filename, key):
|
||||||
config_dir = get_default_config_directory()
|
config_dir = get_default_config_directory()
|
||||||
if not os.path.isdir(config_dir):
|
if not os.path.isdir(config_dir):
|
||||||
config_dir = '/usr/share/slixfeed/'
|
config_dir = '/usr/share/slixfeed/'
|
||||||
|
if not os.path.isdir(config_dir):
|
||||||
|
config_dir = os.path.dirname(__file__) + "/assets"
|
||||||
config_file = os.path.join(config_dir, filename)
|
config_file = os.path.join(config_dir, filename)
|
||||||
with open(config_file) as defaults:
|
with open(config_file) as defaults:
|
||||||
# default = yaml.safe_load(defaults)
|
# default = yaml.safe_load(defaults)
|
||||||
|
|
|
@ -48,7 +48,7 @@ import slixfeed.action as action
|
||||||
from slixfeed.config import (
|
from slixfeed.config import (
|
||||||
get_pathname_to_database,
|
get_pathname_to_database,
|
||||||
get_default_data_directory,
|
get_default_data_directory,
|
||||||
get_value_default)
|
get_value)
|
||||||
# from slixfeed.dt import current_time
|
# from slixfeed.dt import current_time
|
||||||
from slixfeed.sqlite import (
|
from slixfeed.sqlite import (
|
||||||
get_feed_title,
|
get_feed_title,
|
||||||
|
@ -155,7 +155,7 @@ async def task_jid(self, jid):
|
||||||
await get_settings_value(
|
await get_settings_value(
|
||||||
db_file, "enabled")
|
db_file, "enabled")
|
||||||
) or (
|
) or (
|
||||||
get_value_default(
|
get_value(
|
||||||
"settings", "Settings", "enabled")
|
"settings", "Settings", "enabled")
|
||||||
)
|
)
|
||||||
if enabled:
|
if enabled:
|
||||||
|
@ -211,7 +211,7 @@ async def send_update(self, jid, num=None):
|
||||||
await get_settings_value(
|
await get_settings_value(
|
||||||
db_file, "enabled")
|
db_file, "enabled")
|
||||||
) or (
|
) or (
|
||||||
get_value_default(
|
get_value(
|
||||||
"settings", "Settings", "enabled")
|
"settings", "Settings", "enabled")
|
||||||
)
|
)
|
||||||
if enabled:
|
if enabled:
|
||||||
|
@ -220,7 +220,7 @@ async def send_update(self, jid, num=None):
|
||||||
await get_settings_value(
|
await get_settings_value(
|
||||||
db_file, "quantum")
|
db_file, "quantum")
|
||||||
) or (
|
) or (
|
||||||
get_value_default(
|
get_value(
|
||||||
"settings", "Settings", "quantum")
|
"settings", "Settings", "quantum")
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
|
@ -329,7 +329,7 @@ async def send_status(self, jid):
|
||||||
await get_settings_value(
|
await get_settings_value(
|
||||||
db_file, "enabled")
|
db_file, "enabled")
|
||||||
) or (
|
) or (
|
||||||
get_value_default(
|
get_value(
|
||||||
"settings", "Settings", "enabled")
|
"settings", "Settings", "enabled")
|
||||||
)
|
)
|
||||||
if not enabled:
|
if not enabled:
|
||||||
|
@ -403,7 +403,7 @@ async def refresh_task(self, jid, callback, key, val=None):
|
||||||
await get_settings_value(
|
await get_settings_value(
|
||||||
db_file, key)
|
db_file, key)
|
||||||
) or (
|
) or (
|
||||||
get_value_default(
|
get_value(
|
||||||
"settings", "Settings", key)
|
"settings", "Settings", key)
|
||||||
)
|
)
|
||||||
# if task_manager[jid][key]:
|
# if task_manager[jid][key]:
|
||||||
|
@ -460,7 +460,7 @@ async def check_updates(jid):
|
||||||
urls = await get_feeds_url(db_file)
|
urls = await get_feeds_url(db_file)
|
||||||
for url in urls:
|
for url in urls:
|
||||||
await action.scan(db_file, url)
|
await action.scan(db_file, url)
|
||||||
val = get_value_default(
|
val = get_value(
|
||||||
"settings", "Settings", "check")
|
"settings", "Settings", "check")
|
||||||
await asyncio.sleep(60 * float(val))
|
await asyncio.sleep(60 * float(val))
|
||||||
# Schedule to call this function again in 90 minutes
|
# Schedule to call this function again in 90 minutes
|
||||||
|
|
|
@ -208,9 +208,8 @@ class Slixfeed(slixmpp.ClientXMPP):
|
||||||
|
|
||||||
|
|
||||||
async def on_presence_available(self, presence):
|
async def on_presence_available(self, presence):
|
||||||
|
# TODO Add function to check whether task is already running or not
|
||||||
await task.start_tasks(self, presence)
|
await task.start_tasks(self, presence)
|
||||||
print("on_presence_available")
|
|
||||||
print(presence)
|
|
||||||
|
|
||||||
|
|
||||||
async def on_presence_unsubscribed(self, presence):
|
async def on_presence_unsubscribed(self, presence):
|
||||||
|
|
|
@ -519,7 +519,7 @@ async def message(self, message):
|
||||||
await send_oob_message(self, jid, url)
|
await send_oob_message(self, jid, url)
|
||||||
else:
|
else:
|
||||||
response = (
|
response = (
|
||||||
"Failed to fetch {}. Reason: {}"
|
"Failed to fetch {} Reason: {}"
|
||||||
).format(url, code)
|
).format(url, code)
|
||||||
await task.start_tasks_xmpp(
|
await task.start_tasks_xmpp(
|
||||||
self, jid, ["status"])
|
self, jid, ["status"])
|
||||||
|
|
|
@ -44,7 +44,17 @@ async def set_avatar(self):
|
||||||
config_dir = get_default_config_directory()
|
config_dir = get_default_config_directory()
|
||||||
if not os.path.isdir(config_dir):
|
if not os.path.isdir(config_dir):
|
||||||
config_dir = '/usr/share/slixfeed/'
|
config_dir = '/usr/share/slixfeed/'
|
||||||
filename = glob.glob(config_dir + "/image.*")[0]
|
filename = glob.glob(config_dir + "/image.*")
|
||||||
|
if not filename and os.path.isdir('/usr/share/slixfeed/'):
|
||||||
|
# filename = '/usr/share/slixfeed/image.svg'
|
||||||
|
filename = glob.glob("/usr/share/slixfeed/image.*")
|
||||||
|
else:
|
||||||
|
config_dir = os.path.dirname(__file__)
|
||||||
|
config_dir = config_dir.split("/")
|
||||||
|
config_dir.pop()
|
||||||
|
config_dir = "/".join(config_dir)
|
||||||
|
filename = glob.glob(config_dir + "/assets/image.*")
|
||||||
|
filename = filename[0]
|
||||||
image_file = os.path.join(config_dir, filename)
|
image_file = os.path.join(config_dir, filename)
|
||||||
with open(image_file, "rb") as avatar_file:
|
with open(image_file, "rb") as avatar_file:
|
||||||
avatar = avatar_file.read()
|
avatar = avatar_file.read()
|
||||||
|
|
Loading…
Reference in a new issue