简体   繁体   English

多行发送消息

[英]Send message on multiple lines

Im trying to get my tool to send a message automatically in discord servers, However, My message is more than one line.我试图让我的工具在不和谐服务器中自动发送消息,但是,我的消息不止一行。 I tried using putting it all in one line and using '\n' to get a new line.我尝试将所有内容放在一行中并使用 '\n' 换行。 But that doesn't work.但这不起作用。 It only reads the bottom message of the entire message.它只读取整个消息的底部消息。 I have the message put in a message.txt so the user doesn't have to edit the programme.我将消息放在 message.txt 中,因此用户不必编辑程序。 Here's the definition of the function + the send message function, LMK if you need anything else这是函数的定义+发送消息函数,LMK如果你需要什么

#Message #信息

    def loadmessages():
lines = []
with open('messages.txt') as f:
    lines = f.readlines()
#had trouble formatting code

#Send message #发信息

def send_messages(message_data,):
connection = get_connection()
m=dumps(message_data)
with open("Channel ID's.txt","r") as f:
    ChannelIDs = f.read().split("\n")
for channel in ChannelIDs:
    send_message(connection, channel,m,)
    sleep(5)
    repeat()

You can always read a text of a file into variable.您始终可以将文件的文本读入变量。 For example:例如:

message = ""

with open('messages.txt', 'r+') as f:

  for line in f.readlines():
        message+=line

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM