Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: create_vote #212

Merged
merged 9 commits into from
Feb 24, 2023
Merged

feat: create_vote #212

merged 9 commits into from
Feb 24, 2023

Conversation

z0z0r4
Copy link
Collaborator

@z0z0r4 z0z0r4 commented Feb 23, 2023

新建 data/api/vote.json ...

@z0z0r4
Copy link
Collaborator Author

z0z0r4 commented Feb 23, 2023

from bilibili_api import dynamic, sync, Credential, vote

choices = vote.VoteChoices().add_choice(desc="1 choice").add_choice(desc="2 choice")
print(sync(vote.create_vote(title="title", _type=vote.VoteType.TEXT, choice_cnt=2, duration=604800, choices=choices, credential=c)))
_vote = sync(vote.Vote(vote_id=5322590).get_vote_info())

image

@z0z0r4
Copy link
Collaborator Author

z0z0r4 commented Feb 23, 2023

文档明天再写...

@@ -0,0 +1,26 @@
{
"info": {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这里少了一层,参考 live.json

QQ截图20230223224738

最外层应该是 info 表示获取信息的接口 operate 表示操作的接口。

这里建议现在的 info 改为 info.vote_infocreate 改为 operate.create_vote

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sorry,已经改了

@Drelf2018
Copy link
Collaborator

顺带问一下你是高中生吗

@z0z0r4
Copy link
Collaborator Author

z0z0r4 commented Feb 23, 2023

顺带问一下你是高中生吗

高一呢,有啥问题吗?很乐意聊聊

今天放假,我可不是翘课的2333,不过在校也有办法半夜 PR 就是了~~

@Drelf2018
Copy link
Collaborator

喜欢编程我擦 这个拦不住的👍

@z0z0r4
Copy link
Collaborator Author

z0z0r4 commented Feb 23, 2023

喜欢编程我擦 这个拦不住的👍

emmm,随便吧,业余。不过另一方面外快赚挺多的

@z0z0r4
Copy link
Collaborator Author

z0z0r4 commented Feb 23, 2023

文档明天再写...

Finished,刚好到明天了

Copy link
Collaborator

@Drelf2018 Drelf2018 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

辛苦

@z0z0r4
Copy link
Collaborator Author

z0z0r4 commented Feb 24, 2023

@Nemo2011 先把这个 merge 了?

用的web端接口
@z0z0r4
Copy link
Collaborator Author

z0z0r4 commented Feb 24, 2023

动态重构完了,文档下午再写

@@ -0,0 +1,12942 @@
{
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个文件是做什么用的?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

看到你有个这样的函数,应该是在动态插入表情用的。但是这里使用 ID 插入的,实际使用的时候没有人会去记表情的数字 ID 吧。我觉得应该是直接用中括号的文字表情作为参数,然后那个文件也不用了。

def add_emoji(self, emoji_id: int) -> "BuildDynmaic":
    """
    添加表情
    Args:
        emoji_id (int): 表情ID
    """
    with open(os.path.join(os.path.dirname(__file__), "data/emote.json"), encoding="UTF-8") as f:
        emote_info = json.load(f)
    if str(emoji_id) not in emote_info:
        raise ValueError("不存在此表情")
    self.contents.append({
        "biz_id": "",
        "type": DynmaicContentType.EMOJI.value,
        "raw_text": emote_info[str(emoji_id)]
    }
    )
    return self

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

关于表情包其实有个文件了 emoji.py 或许可以在这里建一个类 Emoji ,然后 add_emoji 的参数改成 emoji: Emoji

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

看到你有个这样的函数,应该是在动态插入表情用的。但是这里使用 ID 插入的,实际使用的时候没有人会去记表情的数字 ID 吧。我觉得应该是直接用中括号的文字表情作为参数,然后那个文件也不用了。

def add_emoji(self, emoji_id: int) -> "BuildDynmaic":
    """
    添加表情
    Args:
        emoji_id (int): 表情ID
    """
    with open(os.path.join(os.path.dirname(__file__), "data/emote.json"), encoding="UTF-8") as f:
        emote_info = json.load(f)
    if str(emoji_id) not in emote_info:
        raise ValueError("不存在此表情")
    self.contents.append({
        "biz_id": "",
        "type": DynmaicContentType.EMOJI.value,
        "raw_text": emote_info[str(emoji_id)]
    }
    )
    return self

是这样的emm,都怪B站.jpg
动态发送的后端都tm不知道谁写的...用中文表情名做根据

我待会和文档一块 pr,现在在体验樱之刻,不想动呜呜呜呜呜呜呜呜

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

关于表情包其实有个文件了 emoji.py 或许可以在这里建一个类 Emoji ,然后 add_emoji 的参数改成 emoji: Emoji

agree,顺便这个 emoji 类要不你来?谁提出谁干qeq

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

不...根本找不到创建 emoji 类的理由,一方面这玩意在哪都是 [emoji_name],另一方面也没有任何 operate 可用,纯粹充数的
我无语了,从动态到回复B站用的都是中文名

@Nemo2011 Nemo2011 merged commit 5224e17 into Nemo2011:dev Feb 24, 2023
z0z0r4 added a commit to z0z0r4/bilibili-api that referenced this pull request Feb 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants