discord 自动水群脚本

原理:从你加入的channel里获取到历史消息随机选择一条发送至目标channel
需要先登录网页版获取authorization

# -*- coding: utf-8 -*-
"""
@Time : 2021/10/3 19:18
@Auth : d1rrick@scientistDAO
@File :autochat.py
@IDE :PyCharm

"""
import requests
import json
import random
import time
import re

def gen_context():
    context_list = [
    "hello bro","let's go !","to the moon!","nice","project","have a good day",
    "good","luck","how's going","so do i","yeah","same to me","1","cool","so far so good",
    "hi~","of course","really","cool~","ok","what?","why?","not bad","well done","great",
    "perferct","thanks","ture","yes","no","here","interesting","it's funny","i am tired"
    ]
    text = random.choice(context_list)
    return text

def get_context():
    chanel_list = []
    headr = {
        "Authorization": "",
        "Content-Type": "application/json",
        "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/94.0.4606.61 Safari/537.36"
    }
    chanel_id = random.choice(chanel_list)
    url = "https://discord.com/api/v9/channels/{}/messages?limit=100".format(chanel_id)
    res = requests.get(url=url, headers=headr)
    result = json.loads(res.content)
    result_list = []
    for context in result:
        if ('<') not in context['content'] :
            if ('@') not in context['content'] :
                if ('http') not in context['content']:
                    if ('?') not in context['content']:
                        result_list.append(context['content'])

    return random.choice(result_list)


def chat():
    chanel_list = ['']
    authorization_list = ['']
    for authorization in authorization_list:
        header = {
            "Authorization":authorization,
            "Content-Type":"application/json",
            "User-Agent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/94.0.4606.61 Safari/537.36"
        }
        for chanel_id in chanel_list:
            msg = {

                "content": get_context(),
                "nonce": "82329451214{}33232234".format(random.randrange(0, 1000)),
                "tts": False

            }
            url = 'https://discord.com/api/v9/channels/{}/messages'.format(chanel_id)
            try:
                res = requests.post(url=url, headers=header, data=json.dumps(msg))
                print(res.content)
            except:
                pass
            continue
        time.sleep(random.randrange(30,50))



if __name__ == '__main__':
    while True:
        try:
            chat()
            sleeptime = random.randrange(180, 240)
            time.sleep(sleeptime)
        except:
            pass
        continue
  • 1
    点赞
  • 12
    收藏
    觉得还不错? 一键收藏
  • 2
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值