소스 검색

Oops, had config stuff here

master
noelle 5 년 전
부모
커밋
e5da39298c
1개의 변경된 파일0개의 추가작업 그리고 96개의 파일을 삭제
  1. 0
    96
      mushcord.py

+ 0
- 96
mushcord.py 파일 보기

@@ -1,96 +0,0 @@
import discord
import telnetlib as tn
from time import sleep
import sys, os

client = discord.Client()



class Mushcord:
VERSION = '0.1.3'
def __init__(self):
self.TOKEN = 'NDc1NzIzMTg2NTUwNjAzNzkz.DkjMAw.ZH9FM4VxY4lieOp_Fl3JmHovx_o'
self.server = 'saminga.oyving.org'
self.port = 6250
self.username = "mushcord"
self.password = "g3licht3n!"
@client.event
async def on_message(message):
if message.author == client.user:
return
if message.content.startswith('!hello'):
msg = 'Hello {0.author.mention}'.format(message)
await client.send_message(message.channel, msg)
if message.content.startswith('!say'):
author = message.author.nick or str(message.author).split('#')[0]
content = " ".join(message.content.split(" ")[1:])
msg = bytes(":| {0} says, \"{1}\".\n".format(author, content), "UTF-8")
mc.t.write(msg)
if message.content.startswith('!"'):
author = message.author.nick or str(message.author).split('#')[0]
content = message.content[2:]
msg = bytes(":| {0} says, \"{1}\".\n".format(author, content), "UTF-8")
mc.t.write(msg)
if message.content.startswith('!emote'):
author = message.author.nick or str(message.author).split('#')[0]
content = " ".join(message.content.split(" ")[1:])
msg = bytes(":| {0} {1}\n".format(author, content), "UTF-8")
mc.t.write(msg)
if message.content.startswith('!:'):
author = message.author.nick or str(message.author).split('#')[0]
content = message.content[2:]
msg = bytes(":| {0} {1}\n".format(author, content), "UTF-8")
mc.t.write(msg)
if message.content.startswith('!>:'):
author = message.author.nick or str(message.author).split('#')[0]
content = message.content[3:]
msg = bytes(">:| {0} {1}\n".format(author, content), "UTF-8")
mc.t.write(msg)
if message.content.startswith('!>') and not message.content.startswith('!>:'):
author = message.author.nick or str(message.author).split('#')[0]
content = message.content[2:]
msg = bytes(">:| {0} says, \"{1}\".\n".format(author, content), "UTF-8")
mc.t.write(msg)

@client.event
async def on_ready():
print('Logged in as')
print(client.user.name)
print(client.user.id)
print("--------")

def start(self):
self.t = tn.Telnet(self.server,self.port)
self.t.read_until(b"\"news\"")
self.t.write(bytes("connect {0} {1}\n".format(self.username, self.password),"UTF-8"))
client.run(self.TOKEN)

def listen(self):
while True:
try:
g = b''
g = self.t.read_until(b'\r\n', 1)
if g != b'':
try:
g = g.decode(encoding='iso-8859-1').strip()
except UnicodeDecodeError:
try:
g = g.decode(errors="replace").strip()
except:
g = g.decode(errors="ignore").strip()
client.send_message(message.channel, g)
g = b''
except KeyboardInterrupt:
break
except EOFError:
break
except:
continue

if __name__ == "__main__":
mc = Mushcord()
mc.start()
mc.listen()

Loading…
취소
저장