Bağımlı kanallar

Bağımlı kanal, IM’nin API’si üzerindeki bir pakete benziyor, IM’den gelen iletileri uygun nesnelere ekler ve onu ana kanala teslim eder.

Bağımlı kanalın bir IM platformuyla eşleşmesi gerektiğini önermemize rağmen, bilgileri mesaj olarak iletebilen her şey için modellemeyi deneyebilirsiniz, ve sohbetlere ve sohbetlerden mesaj iletmek için son noktaların sınırlı bir listesine sahiptir.

In most of the cases, slave channels SHOULD be identified as one single user from the IM platform, instead of a bot. You should only use a bot for slave channels when:

  • IM platformu kullanıcı ve bot arasında fark etmez, veya

  • iM platformundaki botlar, aynı şeyleri bir kullanıcı olarak yapabilir, eğer daha fazla değilse, bir kullanıcı olarak, botlar kullanıcı hesabından daha kolay oluşturulabilir.

Ek özellikler

Bağımlı kanallar, EFB’nin ihtiyaç duyduğu grup oluşturma, arkadaş arama vb. gibi ek özellikler yoluyla daha fazla işlev sunabilir.

Such features are accessed by the user in a CLI-like style. An “additional feature” method MUST only take one string parameter aside from self, and wrap it with extra() decorator. The extra decorator takes 2 arguments: name – a short name of the feature, and desc – a description of the feature with its usage.

desc SHOULD describe what the feature does and how to use it. It’s more like the help text for an CLI program. Since method of invoking the feature depends on the implementation of the master channel, you SHOULD use "{function_name}" as its name in desc, and master channel will replace it with respective name depend on their implementation.

The method MUST in the end return a string, which will be shown to the user as its result, or None to notify the master channel there will be further interaction happen. Depending on the functionality of the feature, it may be just a simple success message, or a long chunk of results.

The callable MUST NOT raise any exception to its caller. Any exceptions occurred within should be expected and processed.

Callable name of such methods has a more strict standard than a normal Python 3 identifier name, for compatibility reason. An additional feature callable name MUST:

  • büyük/küçük harfe duyarlı

  • yalnız büyük ve küçük harfler, rakamlar ve altçizgi içerir.

  • bir basamakla başlamaz.

  • 1 ve 20 arasında bir uzunlukta olmalı

  • mümkün olduğunca kısa ve öz olun, fakat anlaşılabilir tutun

It can be expressed in a regular expression as:

^[A-Za-z][A-Za-z0-9_]{0,19}$

An example is as follows:

@extra(name="Echo",
       desc="Return back the same string from input.\n"
            "Usage:\n"
            "    {function_name} text")
def echo(self, arguments: str = "") -> str:
    return arguments

Mesaj komutları

Mesaj komutları genellikle bağımlı kanallar tarafından gönderilir, böylece kullanıcılar gerekli eylemlere sahip mesajlara cevap verebilir.

Mesaj komutlarının yararlı olabileceği olası durumlar:

  • Bir kartvizit alındığında arkadaş olarak ekleyin.

  • Arkadaş talebi alındığında kabul veya reddedin.

  • Vote to a voting message.

Bir mesaj, her biri aşağıdakileri içeren bir liste komutuyla eklenebilir:

  • insan dostu bir isim,

  • çağrılabilir bir isim,

  • konumsal argümanlardan oluşan bir list``( * args``), ve

  • anahtar kelime argümanlarından oluşan bir dict``(``**kwargs)

When the User clicked the button, the corresponding method of your channel will be called with provided arguments.

Note that all such methods MUST return a str as a respond to the action from user, and they MUST NOT raise any exception to its caller. Any exceptions occurred within MUST be expected and processed.

Mesaj teslimi

Slave channels SHOULD deliver all messages that the IM provides, including what the User sent outside of this channel. But it SHOULD NOT deliver message sent from the master channel again back to the master channel as a new message.

Implementation details

See SlaveChannel.