-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.py
85 lines (76 loc) · 4.18 KB
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
# -*- coding: utf-8 -*-
import asyncio
import discord
import subprocess
import os
entry_id = 736628061289578496
server_id = 736622331178254426
hello_id = 737068025253200069
server_id = int(server_id)
entry_id = int(entry_id)
hello_id = int(hello_id)
client = discord.Client()
async def send(channel,*args, **kwargs): return await channel.send(*args, **kwargs)
@client.event
async def on_ready():
# print(client.user.id)
await client.change_presence(activity=discord.Game(name='権限付与準備完了....'))
# print('It is ready')
# channel = client.get_channel(hello_id)
# embed = discord.Embed(title="ただ今起動しました",description="動作していない場合は管理者に問い合わせてください", color=0x00ccff)
# embed = embed.set_author(name="CotTyanからのお知らせ",icon_url="https://www.repo.approvers.dev/g2058.png")
# embed = embed.set_thumbnail(url="https://www.repo.approvers.dev/g2058.png")
# embed = embed.set_footer(text="ふぇぇ、恥ずかしいよぅ(*ノωノ)")
# await channel.send(embed=embed)
@client.event
async def on_member_join(member):
lrn = []
for role in member.roles:
lrn.append(role.name)
if len(lrn) == 2:
break
m = "Hi!<@"+str(member.id)+">,\nPlease read <#736628061289578496> and type [ok]. \nIf you are going to to be able to do it, please introduse yourself in <#736627134604378143>.\n"
channel = client.get_channel(737576896476348447)
await member.channel.send(m)
# @client.event
# async def on_message(command):
# if command.author.bot:
# return
# else
# a = command.author
# print(a)
@client.event
async def on_message(message):
if message.author.bot:
return
# if message.content == '*cot.help!':
# embed = discord.Embed(title="CotTyanへるぷ", description="このヘルプを表示 `*cot.help!`\nボットについての情報を見る`*cot.about!`\n現在時刻を表示[Ruby]`*cot.daemon.time!`\n 機能追加はまだまだこれからですので気を長くしてお待ちください", color=0x00ccff)
# embed = embed.set_author(name="COTTYAN MARK II by laminne", url="https://github.com/laminne", icon_url="https://www.repo.approvers.dev/g2058.png")
# embed = embed.set_thumbnail(url="https://www.repo.approvers.dev/g2058.png")
# embed = embed.set_footer(text="ふぇぇ、恥ずかしいよぅ(*ノωノ)")
# await channel.send(embed=embed)
# if message.content == '*cot.about!':
# embed = discord.Embed(title="CotTyanについて", description="Laminne33569がコマンド部分をPython、コマンド実行部分をRubyで書いたボットです\n仕組みとしてはコマンドを取得し\nRubyのコードを実行、出力の成形を行い、\nそれをPythonで受け取り送信しています\nデプロイ先はVPSですのでいろいろできます", color=0x00ccff)
# embed = embed.set_author(name="COTTYAN MARK II by laminne", url="https://github.com/laminne", icon_url="https://www.repo.approvers.dev/g2058.png")
# embed = embed.set_thumbnail(url="https://www.repo.approvers.dev/g2058.png")
# embed = embed.set_footer(text="ちゃんと自己紹介できるもん!")
# await channel.send(embed=embed)
# if message.content == '*cot.daemon.time!':
# ruby = subprocess.check_output(['/root/.rbenv/shims/ruby', '/root/cottyan-mark2/main.rb'])
# m = ruby.decode()
# ruby = m.replace('"','')
# await message.channel.send(ruby.replace('"',''))
if message.guild.id == server_id:
if message.content == "ok":
lrn = []
for role in message.author.roles:
lrn.append(role.name)
if len(lrn) == 2:
return
message_to = "<@"+str(member.id)+">,\nPlease introduse yourself in <#736627134604378143>.\n"
channel = client.get_channel(737576896476348447)
return await channel.send(message_to)
role = discord.utils.get(message.guild.roles, name="自己紹介してね")
return await message.author.add_roles(role)
if __name__ == "__main__":
client.run(os.environ['MARK1_TOKEN'])