tootgroup.py
- emulate group accounts on Mastodon and PleromaSome social media platforms allow groups of users to post into a unified "group"timeline/instance/whatever you want to call it. This is currently not possibleon Mastodon or Pleroma without giving all members full login credentials to agroup. tootgroup.py
is an attempt to solve this specific use case.
tootgroup.py
has to be set up on a computer and run periodically. It reads thenotifications from the Mastodon/Pleroma account it is connected to and filtersthem for messages to repost. There are two methods of creating a group post. Oneor both of them can be enabled during the setup procedure.
Public mentions of group members are boosted if they preceed the group'sname with an Exclamation Mark like "!@mastodon"
tootgroup.py
can also look for direct messages from group members. If thegroup is @mentioned at the very beginning, The message will be reposted asa new public toot originating directly from the group account. The statustext as well as media files are included. The originating user will not beshown publicly. (It can still be seen by all group and instanceadministrators tough!)
If both repost methods are disabled, tootgroup.py
will still run but not repostanything.
Write a message that should be boosted by the group: Just include"!@group_name" anywhere in the toot.EXAMPLE: "OHAI! just found that !@mastodon thingie!"
Write a message that should appear as a new post from the group:Put "@group_name" at the very beginning of a direct/private message.EXAMPLE: "@mastodon HERE BE THE MESSAGE TEXT"
The easiest way to install tootgroup.py
is via PyPI, the Python Package Index.Use pip3 install tootgroup.py
to install it as well as all its dependencies.
It is also possible to download the script manually from the GitHub repository athttps://github.com/oe4dns/tootgroup.py In that case the necessary dependencieshave to be provided too:
tootgroup.py
requires https://github.com/halcy/Mastodon.py as well ashttps://github.com/ActiveState/appdirs to run. Install them via youroperating system's package manager, pip or even manually.
tootgroup.py
will guide you through setup by asking all information it needswhen you run it from the commandline for the first time. Being somewhatcomfortable with Python scripting and the commandline in general might helpif difficulties should appear.
You need an account on any Mastodon or Pleroma instance that will act asyour group account. Think about if you should mark it as a "Bot".
Run tootgroup.py
from the command line.
tootgroup.py
will ask you for all needed setup data and try to get themright by connecting to the Mastodon/Pleroma server. If it cannot do so, itwill tell you and you can retry. When successful, tootgroup.py
will writethe configuration to its tootgroup.conf file and read it from there nexttime you run the script.
The place for storing configuration is operating system dependent but will beshown during the first-run/setup phase. A local tootgroup.conf file placednext to the tootgroup.py
script will override these settings though and canbe used for development or testing purposes.
If you want to set up tootgroup.py
for more than one group, you can run itagain while specifying the "--group GROUP_HANDLE" flag. This will thengenerate an independent configuration that will be read each time you calltootgroup.py
using this name. If you don't specify any group name, thehandle "default" is created and used automatically
Test the funcionality by sending direct messages and "!@mentions" to yourgroup while running tootgroup.py
manually. See if things work as expected.The script will print an according message after each successful run.If everything works, run the script periodically via cron and enjoygroop-tooting!
Here is an example for a crontab entry that runs tootgroup.py
every two minutes:
*/2 * * * * /path/to/tootgroup.py --group default
There is also the "-d" or "--dry-run" commandline flag that prevents any toots.You can use it to test what would be posted by the script.
Use "-h" or "--help" for more information about all available options
Python itertools.groupby groupby()把迭代器中相邻的,指定特征重复的元素挑出来放在一起 list中:key相同的dict元素 通常使用itemgetter()参数规定分组依据 也可编写简单的lambda函数传入key参数,作为分组依据(key参数必须传入函数) from operator import itemgetter #itemgetter用来取dict中的k
将创建进程池对象放在子进程函数之前会产生 AttributeError: Can't get attribute 'worker' on <module '__main__' from '/home/tian/file/pool.py'> from multiprocessing import Pool from time import sleep,ctime #创建进程池对象 pool = P
j静态文件的copy python manage.py collectstatic
from operator import itemgetter from itertools import groupby 源数据为这样 _ = [ {'conf_id': 4, 'username': '.zhang'}, {'conf_id': 10, 'username': '.zhang'}, {'conf_id': 4, 'username': '.wang'}, {'conf
使用误点一: 误以为 groupby是按照key进行分组的: 例子 from random import choice lst = [ Student(choice(['M','F']),choice(range(10,100))) for i in range(20)] for k,items in itertools.groupby(lst,lambda x:x.sex): print
import re; from log_manager import *; from error_manager import *; class common_tools: __instance = None; def __init__(self): pass; @staticmethod def GetInstance():
ImportError: No module named ‘_tkinter’, please install the python3-tk package 这个问题的原因是使用的python3环境内没有tkinter 需要安装tkinter sudo apt-get install python3-tk
-1.类似字典的调用方式 groupby = df.groupby('id') # 遍历 for id,group in groupby: print(id) print(group) # 取其中一组 data = groupby.get_group('aaa') -2.单列函数 df_groupby = df.groupby('id')['salary'].sum() df_
itertools.groupby(iterable[, key]) 官网 from itertools import groupby input:[k for k, g in groupby('AAAABBBCCDAABBB')] output:['A', 'B', 'C', 'D', 'A', 'B'] input:[list(g) for k, g in groupby('AAAABB
对相邻相同key的元素进行分组,这样就会导致可能某些相同的key的组没有一步到位合并 如果先排序,可以直接完成分组合并 链接
1. train 在tools/train.py中找到以下表示开始训练的代码 # -----------------------start training--------------------------- logger.info('**********************Start training %s/%s(%s)**********************'
这个错误我遇到不止一次了,经常忘!!!这里记一下!!! 完整报错示意: Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/usr/local/lib/python2.7/dist-packages/azimuth/model_comparison.py", line 1, in <mo
ImportError: Couldn’t import Django. Are you sure it’s installed and available on your PYTHONPATH environment variable? Did you forget to activate a virtual environment? 可能未进入虚拟环境 (workon ****) 虚拟环境未激